diff --git a/binding.gyp b/binding.gyp index bb22d6ae..cdbcc274 100644 --- a/binding.gyp +++ b/binding.gyp @@ -1,6 +1,7 @@ { "variables": { - "realm_node_build_as_library%": "0" + "realm_node_build_as_library%": "0", + "realm_download_binaries%": "1" }, "includes": [ "src/node/gyp/target_defaults.gypi", diff --git a/scripts/download-core.sh b/scripts/download-core.sh index 4d0ab6c9..6c83d962 100755 --- a/scripts/download-core.sh +++ b/scripts/download-core.sh @@ -16,6 +16,7 @@ fi # The 'node' argument will result in realm-node build being downloaded. if [ "$1" = 'node' ]; then + ENABLE_SYNC="$2" CORE_DIR="core-node" SYNC_DIR='node-sync' @@ -34,6 +35,8 @@ if [ "$1" = 'node' ]; then SYNC_EXTRACT="unzip" EXTRACTED_DIR="realm-sync-node-cocoa-$REALM_SYNC_VERSION" else + ENABLE_SYNC="yes" # FIXME: This means that both core and sync will be downloaded for non "node" targets. + # Should be 0 or 1. We do not need to download both CORE_DIR='core' PLATFORM_TAG="" SYNC_DIR='sync' @@ -94,7 +97,19 @@ check_release_notes() { grep -Fqi "$REALM_CORE_VERSION RELEASE NOTES" "$@" } -if [ -z "$REALM_CORE_PREFIX" ]; then +DOWNLOAD_CORE=1 + +if ! [ -z "$REALM_CORE_PREFIX" ]; then +DOWNLOAD_CORE=0 +echo "Skipping the core download because REALM_CORE_PREFIX is defined." +fi + +if [ "$ENABLE_SYNC" == 1 ]; then +DOWNLOAD_CORE=0 +echo "Skipping the core download because ENABLE_SYNC is true." +fi + +if [ "$DOWNLOAD_CORE" == 1 ]; then if [ ! -e "vendor/$CORE_DIR" ]; then download_core $CORE_DIR $REALM_CORE_VERSION $CORE_DOWNLOAD_FILE core "tar -xzf" core elif [ -d "vendor/$CORE_DIR" -a -d ../realm-core -a ! -L "vendor/$CORE_DIR" ]; then @@ -117,11 +132,20 @@ if [ -z "$REALM_CORE_PREFIX" ]; then else echo "The core library seems to be up to date." fi -else - echo "Skipping core the download because REALM_CORE_PREFIX is defined." fi -if [ -z "$REALM_SYNC_PREFIX" ]; then +DOWNLOAD_SYNC=1 +if ! [ -z "$REALM_SYNC_PREFIX" ]; then +DOWNLOAD_SYNC=0 +echo "Skipping the sync download because REALM_SYNC_PREFIX is defined." +fi + +if [ "$ENABLE_SYNC" == 0 ]; then +DOWNLOAD_SYNC=0 +echo "Skipping the sync download because ENABLE_SYNC is false." +fi + +if [ "$DOWNLOAD_SYNC" == 1 ]; then if [ -n "$SYNC_DOWNLOAD_FILE" ];then if [ ! -e "vendor/$SYNC_DIR" ]; then download_core $SYNC_DIR $REALM_SYNC_VERSION $SYNC_DOWNLOAD_FILE sync "$SYNC_EXTRACT" $EXTRACTED_DIR @@ -146,6 +170,4 @@ if [ -z "$REALM_SYNC_PREFIX" ]; then echo "The sync library seems to be up to date." fi fi -else - echo "Skipping the sync download because REALM_SYNC_PREFIX is defined." fi diff --git a/src/node/gyp/realm.gyp b/src/node/gyp/realm.gyp index e89775f3..96c200f4 100644 --- a/src/node/gyp/realm.gyp +++ b/src/node/gyp/realm.gyp @@ -82,14 +82,6 @@ }, "target_name": "vendored-realm", "type": "none", - "actions": [ - { - "action_name": "download-realm", - "inputs": [ ], - "outputs": [ "<(module_root_dir)/vendor/core-node" ], - "action": [ "<(module_root_dir)/scripts/download-core.sh", "node" ] - } - ], "conditions": [ ["realm_enable_sync", { "all_dependent_settings": { @@ -102,9 +94,18 @@ "library_dirs": [ "<(module_root_dir)/vendor/core-node" ] }, + }], + ["realm_download_binaries", { + "actions": [ + { + "action_name": "download-realm", + "inputs": [ ], + "outputs": [ "<(module_root_dir)/vendor/core-node" ], + "action": [ "<(module_root_dir)/scripts/download-core.sh", "node", "<(realm_enable_sync)" ] + } + ] }] ] - } ] }