summaryrefslogtreecommitdiffstats
path: root/scripts/build-presets.sh
blob: c89da2d35f37b0ac0e60b6405177180fbee9e770 (plain)
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
#!/bin/bash
# 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"

if ! cd "${PRESETS_DIR}"; then
    exit 1
fi

JSON_TEMP=$(mktemp hb_builtin_presets.json.XXX)
C_TEMP=$(mktemp hb_builtin_presets.h.XXX)
if [[ "${JSON_TEMP:-}" == "" ]] || [[ "${C_TEMP:-}" == "" ]]; then
    echo "unable to create temporary file" >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}"

exit 0