Skip to content

Commit 690794b

Browse files
Use lc-compile's dependency tracking when building extensions
1 parent 2307da8 commit 690794b

File tree

3 files changed

+62
-46
lines changed

3 files changed

+62
-46
lines changed

extensions/extensions.gyp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,23 @@
5656
},
5757
},
5858

59-
'rules':
59+
'actions':
6060
[
6161
{
62-
'rule_name': 'build_extension',
63-
'extension': 'lcb',
62+
'action_name': 'build_extensions',
6463

6564
'inputs':
6665
[
67-
'../util/build-widget.sh',
66+
'../util/build-extensions.sh',
67+
'<@(_sources)',
6868
],
6969

7070
'outputs':
7171
[
72-
'<(PRODUCT_DIR)/packaged_extensions/com.livecode.extensions.livecode.<(RULE_INPUT_ROOT)/module.lcb',
72+
'<(PRODUCT_DIR)/packaged_extensions',
7373
],
7474

75-
'message': 'Building extension <(RULE_INPUT_ROOT)',
75+
'message': 'Building extensions',
7676

7777
'conditions':
7878
[
@@ -81,13 +81,13 @@
8181
{
8282
'variables':
8383
{
84-
'build_command': [ '$(ProjectDir)../../../util/invoke-unix.bat', '$(ProjectDir)../../../util/build-widget.sh' ],
84+
'build_command': [ '$(ProjectDir)../../../util/invoke-unix.bat', '$(ProjectDir)../../../util/build-extensions.sh' ],
8585
},
8686
},
8787
{
8888
'variables':
8989
{
90-
'build_command': [ '../util/build-widget.sh' ],
90+
'build_command': [ '../util/build-extensions.sh' ],
9191
},
9292
},
9393
],
@@ -96,10 +96,10 @@
9696
'action':
9797
[
9898
'<@(build_command)',
99-
'<(RULE_INPUT_DIRNAME)',
100-
'<(PRODUCT_DIR)',
99+
'<(PRODUCT_DIR)/packaged_extensions',
101100
'<(PRODUCT_DIR)/modules/lci',
102101
'>(lc-compile_host)',
102+
'<@(_sources)',
103103
],
104104
},
105105
],

util/build-extensions.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
# Utility script called by the build system to compile extensions
4+
5+
set -e
6+
7+
function build_widget {
8+
WIDGET_DIR=$1
9+
WIDGET_NAME=$(basename $1)
10+
TARGET_DIR="com.livecode.extensions.livecode.${WIDGET_NAME}"
11+
BUILD_DIR=$2
12+
MODULE_DIR=$3
13+
LC_COMPILE=$4
14+
15+
"${LC_COMPILE}" \
16+
--modulepath "${MODULE_DIR}" \
17+
--manifest "${WIDGET_DIR}/manifest.xml" \
18+
--output "${WIDGET_DIR}/module.lcm" \
19+
"${WIDGET_DIR}/${WIDGET_NAME}.lcb"
20+
21+
pushd "${WIDGET_DIR}" 1>/dev/null
22+
zip -q -r "${TARGET_DIR}.lce" *
23+
popd 1>/dev/null
24+
25+
mkdir -p "${BUILD_DIR}/${TARGET_DIR}"
26+
27+
unzip -q \
28+
-o "${WIDGET_DIR}/${TARGET_DIR}.lce" \
29+
-d "${BUILD_DIR}/${TARGET_DIR}"
30+
31+
rm "${WIDGET_DIR}/${TARGET_DIR}.lce"
32+
33+
return 0
34+
}
35+
36+
# Arguments 4 and above are the list of extensions to compile
37+
destination_dir=$1
38+
module_dir=$2
39+
lc_compile=$3
40+
shift 3
41+
42+
# Find the dependency/build ordering of the extensions
43+
build_order=$(${lc_compile} --modulepath ${module_dir} --deps changed-order -- $@)
44+
45+
# Loop over the extensions that need to be (re-)built
46+
for ext in ${build_order} ; do
47+
# Create the output directory
48+
mkdir -p "${destination_dir}"/com.livecode.extensions.livecode.$(basename -s .lcb "${ext}")
49+
50+
# Build this extension
51+
build_widget $(dirname "${ext}") "${destination_dir}" "${module_dir}" "${lc_compile}"
52+
done

util/build-widget.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)