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
·84 lines (64 loc) · 1.88 KB
/
build-extensions.sh
File metadata and controls
executable file
·84 lines (64 loc) · 1.88 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# Utility script called by the build system to compile extensions
set -eu
function err() {
echo "ERROR: $@" >&2
}
function extract_name {
# Extract an e.g. "module foo.bar.baz" line from an LCB source file
sed -nEe 's,^([[:space:]]*<name>(.*)</name>[[:space:]]*)$,\2,p' < "$1"
}
function do_cmd {
if [[ ! -z "${V}" ]]; then
echo "$@"
fi
"$@"
}
function build_widget {
local WIDGET_DIR=$1
local WIDGET_NAME=$(basename $1)
local WIDGET_LCB="${WIDGET_DIR}/${WIDGET_NAME}.lcb"
local BUILD_DIR=$2
local MODULE_DIR=$3
local LC_COMPILE=$4
local REMOVE_SRC=$5
echo " LC_COMPILE ${WIDGET_DIR}/module.lcm"
do_cmd "${LC_COMPILE}" \
-Werror \
--modulepath "${MODULE_DIR}" \
--manifest "${WIDGET_DIR}/manifest.xml" \
--output "${WIDGET_DIR}/module.lcm" \
"${WIDGET_LCB}"
local TARGET_DIR=$(extract_name "${WIDGET_DIR}/manifest.xml")
if [[ -z "${TARGET_DIR}" ]]; then
err "Could not find canonical name of ${WIDGET_NAME}"
return 1
fi
echo " PACKAGE ${TARGET_DIR}"
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"
if [[ "${REMOVE_SRC}" = "true" ]]; then
rm "${BUILD_DIR}/${TARGET_DIR}/${WIDGET_NAME}.lcb"
fi
return 0
}
# Detect verbose mode
V=${V:-}
# Arguments 5 and above are the list of extensions to compile
readonly destination_dir=$1
readonly module_dir=$2
readonly lc_compile=$3
readonly remove_src=$4
shift 4
# Find the dependency/build ordering of the extensions
readonly build_order=$(${lc_compile} --modulepath ${module_dir} --deps 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}" "${remove_src}"
done