summaryrefslogtreecommitdiffstats
path: root/scripts/build-presets.sh
diff options
context:
space:
mode:
authorBradley Sepos <[email protected]>2016-06-04 08:34:41 -0400
committerBradley Sepos <[email protected]>2016-06-25 22:50:50 -0400
commit5b43db247f754310f61bd85222115f140fbbfcbf (patch)
treef7a494c5638afa5621a3da29f7dc28a139d130c7 /scripts/build-presets.sh
parentf11a0107743903c2f074fc3b0e88527d61d24bb1 (diff)
scripts: Improve presets building script.
Diffstat (limited to 'scripts/build-presets.sh')
-rwxr-xr-xscripts/build-presets.sh29
1 files changed, 16 insertions, 13 deletions
diff --git a/scripts/build-presets.sh b/scripts/build-presets.sh
index c89da2d35..1ea5c2dca 100755
--- a/scripts/build-presets.sh
+++ b/scripts/build-presets.sh
@@ -2,26 +2,29 @@
# usage: build-presets
SELF="${BASH_SOURCE[0]}"
-BASE_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)
-BASE_DIR="${BASE_DIR:-$(pwd)}"
-LIBHB_DIR="${BASE_DIR}/../libhb"
-PRESETS_DIR="${BASE_DIR}/../preset"
+SELF_DIR=$(cd $(dirname "${SELF}") && pwd -P)
+SELF_DIR="${SELF_DIR:-$(pwd)}"
+LIBHB_DIR="${SELF_DIR}/../libhb"
+PRESETS_DIR="${SELF_DIR}/../preset"
if ! cd "${PRESETS_DIR}"; then
+ echo "unable to access directory: ${PRESETS_DIR}" >2
exit 1
fi
-JSON_TEMP=$(mktemp hb_builtin_presets.json.XXX)
-C_TEMP=$(mktemp hb_builtin_presets.h.XXX)
+JSON_TEMP=$(mktemp preset_builtin.json.XXX)
+C_TEMP=$(mktemp preset_builtin.h.XXX)
if [[ "${JSON_TEMP:-}" == "" ]] || [[ "${C_TEMP:-}" == "" ]]; then
- echo "unable to create temporary file" >2
+ echo "unable to create temporary files" >2
exit 1
fi
-"${BASE_DIR}/create_resources.py" preset_builtin.list "${JSON_TEMP}" \
-&& echo 'const char hb_builtin_presets_json[] =' > "${C_TEMP}" \
-&& "${BASE_DIR}/quotestring.py" "${JSON_TEMP}" >> "${C_TEMP}" \
-&& echo ';' >> "${C_TEMP}" \
-&& cp "${C_TEMP}" "${LIBHB_DIR}/preset_builtin.h"
-rm "${JSON_TEMP}" "${C_TEMP}"
+
+trap "rm ${JSON_TEMP} ${C_TEMP}" EXIT INT TERM
+
+"${SELF_DIR}/create_resources.py" preset_builtin.list "${JSON_TEMP}"
+echo 'const char hb_builtin_presets_json[] =' > "${C_TEMP}"
+"${SELF_DIR}/quotestring.py" "${JSON_TEMP}" >> "${C_TEMP}"
+echo ';' >> "${C_TEMP}"
+cp "${C_TEMP}" "${LIBHB_DIR}/preset_builtin.h"
exit 0