From 690794b52cb98beeaa4fdbc3dc238e60a4e73bee Mon Sep 17 00:00:00 2001 From: "Fraser J. Gordon" Date: Wed, 24 Jun 2015 15:17:18 +0100 Subject: [PATCH] Use lc-compile's dependency tracking when building extensions --- extensions/extensions.gyp | 20 +++++++-------- util/build-extensions.sh | 52 +++++++++++++++++++++++++++++++++++++++ util/build-widget.sh | 36 --------------------------- 3 files changed, 62 insertions(+), 46 deletions(-) create mode 100755 util/build-extensions.sh delete mode 100755 util/build-widget.sh diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp index e159b54e391..bcc78cb1f2b 100644 --- a/extensions/extensions.gyp +++ b/extensions/extensions.gyp @@ -56,23 +56,23 @@ }, }, - 'rules': + 'actions': [ { - 'rule_name': 'build_extension', - 'extension': 'lcb', + 'action_name': 'build_extensions', 'inputs': [ - '../util/build-widget.sh', + '../util/build-extensions.sh', + '<@(_sources)', ], 'outputs': [ - '<(PRODUCT_DIR)/packaged_extensions/com.livecode.extensions.livecode.<(RULE_INPUT_ROOT)/module.lcb', + '<(PRODUCT_DIR)/packaged_extensions', ], - 'message': 'Building extension <(RULE_INPUT_ROOT)', + 'message': 'Building extensions', 'conditions': [ @@ -81,13 +81,13 @@ { 'variables': { - 'build_command': [ '$(ProjectDir)../../../util/invoke-unix.bat', '$(ProjectDir)../../../util/build-widget.sh' ], + 'build_command': [ '$(ProjectDir)../../../util/invoke-unix.bat', '$(ProjectDir)../../../util/build-extensions.sh' ], }, }, { 'variables': { - 'build_command': [ '../util/build-widget.sh' ], + 'build_command': [ '../util/build-extensions.sh' ], }, }, ], @@ -96,10 +96,10 @@ 'action': [ '<@(build_command)', - '<(RULE_INPUT_DIRNAME)', - '<(PRODUCT_DIR)', + '<(PRODUCT_DIR)/packaged_extensions', '<(PRODUCT_DIR)/modules/lci', '>(lc-compile_host)', + '<@(_sources)', ], }, ], diff --git a/util/build-extensions.sh b/util/build-extensions.sh new file mode 100755 index 00000000000..583d33abd54 --- /dev/null +++ b/util/build-extensions.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Utility script called by the build system to compile extensions + +set -e + +function build_widget { + WIDGET_DIR=$1 + WIDGET_NAME=$(basename $1) + TARGET_DIR="com.livecode.extensions.livecode.${WIDGET_NAME}" + BUILD_DIR=$2 + MODULE_DIR=$3 + LC_COMPILE=$4 + + "${LC_COMPILE}" \ + --modulepath "${MODULE_DIR}" \ + --manifest "${WIDGET_DIR}/manifest.xml" \ + --output "${WIDGET_DIR}/module.lcm" \ + "${WIDGET_DIR}/${WIDGET_NAME}.lcb" + + pushd "${WIDGET_DIR}" 1>/dev/null + zip -q -r "${TARGET_DIR}.lce" * + popd 1>/dev/null + + mkdir -p "${BUILD_DIR}/${TARGET_DIR}" + + unzip -q \ + -o "${WIDGET_DIR}/${TARGET_DIR}.lce" \ + -d "${BUILD_DIR}/${TARGET_DIR}" + + rm "${WIDGET_DIR}/${TARGET_DIR}.lce" + + return 0 +} + +# Arguments 4 and above are the list of extensions to compile +destination_dir=$1 +module_dir=$2 +lc_compile=$3 +shift 3 + +# Find the dependency/build ordering of the extensions +build_order=$(${lc_compile} --modulepath ${module_dir} --deps changed-order -- $@) + +# Loop over the extensions that need to be (re-)built +for ext in ${build_order} ; do + # Create the output directory + mkdir -p "${destination_dir}"/com.livecode.extensions.livecode.$(basename -s .lcb "${ext}") + + # Build this extension + build_widget $(dirname "${ext}") "${destination_dir}" "${module_dir}" "${lc_compile}" +done diff --git a/util/build-widget.sh b/util/build-widget.sh deleted file mode 100755 index de0a2d4a253..00000000000 --- a/util/build-widget.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# Utility script called by the build system to compile extensions - -set -e - -function build_widget { - WIDGET_DIR=$1 - WIDGET_NAME=$(basename $1) - TARGET_DIR="com.livecode.extensions.livecode.${WIDGET_NAME}" - BUILD_DIR=$2 - MODULE_DIR=$3 - LC_COMPILE=$4 - - "${LC_COMPILE}" \ - --modulepath "${MODULE_DIR}" \ - --manifest "${WIDGET_DIR}/manifest.xml" \ - --output "${WIDGET_DIR}/module.lcm" \ - "${WIDGET_DIR}/${WIDGET_NAME}.lcb" - - pushd "${WIDGET_DIR}" 1>/dev/null - zip -q -r "${TARGET_DIR}.lce" * - popd 1>/dev/null - - mkdir -p "${BUILD_DIR}/packaged_extensions/${TARGET_DIR}" - - unzip -q \ - -o "${WIDGET_DIR}/${TARGET_DIR}.lce" \ - -d "${BUILD_DIR}/packaged_extensions/${TARGET_DIR}" - - rm "${WIDGET_DIR}/${TARGET_DIR}.lce" - - return 0 -} - -build_widget $@