-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·46 lines (33 loc) · 976 Bytes
/
run.sh
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
#!/bin/sh
# Usage: run.sh [debug|release] program arguments
#
# Runs a program from one of the build directories, with
# LD_LIBRARY_PATH set correctly so that it can find all of the shared
# libraries before they're installed.
# Check that there are enough command-line parameters.
if [ $# -lt 1 ]; then
echo "Usage: run.sh [debug|release] program arguments"
exit 1
fi
# Verify that the user chose a valid build type.
BUILD="$1"
shift
case "$BUILD" in
debug)
;;
release)
;;
*)
echo "Unknown build type $BUILD"
exit 1
;;
esac
# Find all of the src subdirectories in the build directory, and use
# those as the LD_LIBRARY_PATH.
SRC_DIRS=$(find build/$BUILD -name src)
JOINED=$(echo $SRC_DIRS | perl -ne 'print join(":", split)')
# Run the desired program, and pass on any command-line arguments
# as-is.
LD_LIBRARY_PATH="$JOINED:$LD_LIBRARY_PATH" \
DYLD_LIBRARY_PATH="$JOINED:$DYLD_LIBRARY_PATH" \
"$@"