Skip to content

Commit e34135a

Browse files
committed
tools/faust2appls/faust2lv2: Adding -eou pipefail bash options to have stricter handling of return codes and potentially undefined variables. Guarding all potentially undefined variables. Removing debug echo for dspname.
1 parent e3b504e commit e34135a

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

tools/faust2appls/faust2lv2

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
#!/usr/bin/env bash
22

3-
#set -x
3+
set -eou pipefail
44

55
# Default qmake setup (for GUI compilation). This requires Qt5. If qmake-qt5 or
66
# qmake can not be located in PATH, you can also set the QMAKE environment
77
# variable explicitly, or use the -qt5 option below.
8-
[ -z "$QMAKE" ] && QMAKE=$(command -v qmake-qt5 || command -v qmake)
8+
[ -z "${QMAKE:-}" ] && QMAKE=$(command -v qmake-qt5 || command -v qmake)
99

1010
# Where the Faust includes live. We assume that this is under the prefix of
1111
# whatever Faust binary 'which' locates. You can also specify this explicitly
1212
# by setting the FAUSTINC environment variable accordingly.
13-
[ -z "$FAUSTINC" ] && FAUSTINC=$(command -v faust 2>/dev/null | sed -e 's?/bin/faust?/include/faust?')
13+
[ -z "${FAUSTINC:-}" ] && FAUSTINC=$(command -v faust 2>/dev/null | sed -e 's?/bin/faust?/include/faust?')
1414

1515
# Where our own Faust library files are. This may be under a different prefix
1616
# or not installed anywhere. We try 'ls' on lv2ui.cpp in some common locations
1717
# here, and fall back to the current directory if the file isn't found, so
1818
# that you can run the script from the faust-lv2 source directory. You can
1919
# also specify this explicitly by setting the FAUSTLIB environment variable
2020
# accordingly.
21-
[ -z "$FAUSTLIB" ] && FAUSTLIB="$(dirname "$((ls -f /usr/share/faust/lv2ui.cpp /usr/local/share/faust/lv2ui.cpp /opt/local/share/faust/lv2ui.cpp "$PWD/lv2ui.cpp" 2>/dev/null) | tail -1)")"
22-
[ -z "$FAUSTLIB" ] && FAUSTLIB="$PWD"
21+
[ -z "${FAUSTLIB:-}" ] && FAUSTLIB="$(dirname "$((ls -f /usr/share/faust/lv2ui.cpp /usr/local/share/faust/lv2ui.cpp /opt/local/share/faust/lv2ui.cpp "$PWD/lv2ui.cpp" 2>/dev/null) | tail -1)")"
22+
[ -z "${FAUSTLIB:-}" ] && FAUSTLIB="$PWD"
2323
2424
# defaults (these can be changed with the options listed below)
2525
URI_PREFIX=https://faustlv2.bitbucket.io
@@ -149,7 +149,6 @@ if [ ! -f "$FAUSTLIB/lv2ui.cpp" ]; then echo "$0: faust-lv2 library files not fo
149149
arch=lv2.cpp
150150
archui=lv2ui.cpp
151151
dspname="${FILES[0]}"
152-
echo "dspname: $dspname"
153152
SRCDIR=$(dirname "$dspname")
154153
ABSDIR=$(cd "$SRCDIR" && pwd)
155154
CURDIR=$(pwd)
@@ -186,13 +185,13 @@ else
186185
faust -i -a "$FAUSTLIB/$arch" -cn "$clsname" "$dspname" -o "$tmpdir/$cppname" || exit 1
187186
fi
188187
189-
if [ -n "$FAUSTTOOLSFLAGS" ]; then
190-
"$CXX" -shared "${CXXFLAGS[@]}" -DDLLEXT="\"$dllext\"" "$FAUSTTOOLSFLAGS" "$PROCARCH" -I"$ABSDIR" "${CPPFLAGS[@]}" "$tmpdir/$cppname" -o "$tmpdir/$lv2name/$soname" || exit 1
188+
if [ -n "${FAUSTTOOLSFLAGS:-}" ]; then
189+
"$CXX" -shared "${CXXFLAGS[@]}" -DDLLEXT="\"$dllext\"" "${FAUSTTOOLSFLAGS:-}" "$PROCARCH" -I"$ABSDIR" "${CPPFLAGS[@]}" "$tmpdir/$cppname" -o "$tmpdir/$lv2name/$soname" || exit 1
191190
else
192191
"$CXX" -shared "${CXXFLAGS[@]}" -DDLLEXT="\"$dllext\"" "$PROCARCH" -I"$ABSDIR" "${CPPFLAGS[@]}" "$tmpdir/$cppname" -o "$tmpdir/$lv2name/$soname" || exit 1
193192
fi
194193
195-
if [ -n "$plugin_gui" ]; then
194+
if [ -n "${plugin_gui:-}" ]; then
196195
# Compile the UI module.
197196
mkdir -p "$uitmpdir"
198197
if [ "${#OPTIONS[@]}" -gt 0 ]; then
@@ -210,9 +209,9 @@ mkdir -p "$uitmpdir"
210209
fi
211210
# Generate the manifest. There are four different variations of the manifest,
212211
# depending on whether dynamic manifests and the plugin gui is enabled or not.
213-
if [ -n "$dyn_manifest" ]; then
212+
if [ -n "${dyn_manifest:-}" ]; then
214213
# Use a dynamic manifest.
215-
if [ -n "$plugin_gui" ]; then
214+
if [ -n "${plugin_gui:-}" ]; then
216215
sed -e"s?@name@?$clsname?g" -e"s?@uri@?$URI_PREFIX/$clsname?g" -e"s?@dllext@?$dllext?g" > "$tmpdir/$lv2name/manifest.ttl" <<EOF
217216
218217
########## @uri@ ##########
@@ -288,7 +287,7 @@ EOF
288287
fi
289288
else
290289
# Use a static manifest.
291-
if [ -n "$plugin_gui" ]; then
290+
if [ -n "${plugin_gui:-}" ]; then
292291
sed -e"s?@name@?$clsname?g" -e"s?@uri@?$URI_PREFIX/$clsname?g" -e"s?@dllext@?$dllext?g" > "$tmpdir/$lv2name/manifest.ttl" <<EOF
293292
294293
########## @uri@ ##########
@@ -366,8 +365,8 @@ EOF
366365
fi
367366
# This compiles the plugin to an executable which is run to generate the
368367
# plugin-specific part of the manifest.
369-
if [ -n "$FAUSTTOOLSFLAGS" ]; then
370-
"$CXX" "${CXXFLAGS[@]}" -DDLLEXT="\"$dllext\"" "$FAUSTTOOLSFLAGS" -I"$ABSDIR" "${CPPFLAGS[@]}" "$tmpdir/$cppname" -o "$tmpdir/$clsname" || exit 1
368+
if [ -n "${FAUSTTOOLSFLAGS:-}" ]; then
369+
"$CXX" "${CXXFLAGS[@]}" -DDLLEXT="\"$dllext\"" "${FAUSTTOOLSFLAGS:-}" -I"$ABSDIR" "${CPPFLAGS[@]}" "$tmpdir/$cppname" -o "$tmpdir/$clsname" || exit 1
371370
else
372371
"$CXX" "${CXXFLAGS[@]}" -DDLLEXT="\"$dllext\"" -I"$ABSDIR" "${CPPFLAGS[@]}" "$tmpdir/$cppname" -o "$tmpdir/$clsname" || exit 1
373372
fi

0 commit comments

Comments
 (0)