forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-extensions.sh
More file actions
executable file
·55 lines (42 loc) · 1.34 KB
/
build-extensions.sh
File metadata and controls
executable file
·55 lines (42 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Utility script called by the build system to compile extensions
set -e
function extract_name {
# Extract an e.g. "module foo.bar.baz" line from an LCB source file
sed -nEe 's/^([[:space:]]*(module|widget|library)[[:space:]]*)([-_\.[:alnum:]]*)[[:space:]]*$/\3/p' < "$1"
}
function build_widget {
WIDGET_DIR=$1
WIDGET_NAME=$(basename $1)
WIDGET_LCB="${WIDGET_DIR}/${WIDGET_NAME}.lcb"
TARGET_DIR=$(extract_name "${WIDGET_LCB}")
BUILD_DIR=$2
MODULE_DIR=$3
LC_COMPILE=$4
"${LC_COMPILE}" \
-Werror \
--modulepath "${MODULE_DIR}" \
--manifest "${WIDGET_DIR}/manifest.xml" \
--output "${WIDGET_DIR}/module.lcm" \
"${WIDGET_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
build_widget $(dirname "${ext}") "${destination_dir}" "${module_dir}" "${lc_compile}"
done