forked from Papierkorb/bindgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tool.sh
executable file
·38 lines (29 loc) · 991 Bytes
/
tool.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
#!/bin/bash
# Helper script to invoke `bindgen.cr`
BASE="$(dirname "$(readlink -f "$0")")"
CLANG_DIR="$BASE/clang/"
SOURCE_FILE="$BASE/src/bindgen.cr"
function print_clang_error {
echo " Bindgen requires a full installation of Clang, its libraries and development"
echo " headers. Please install these first, and restart this script."
echo " You can also manually run 'cmake .; make -j' in clang/ for debugging this issue."
echo " Full path to clang/: $CLANG_DIR"
exit 1
}
if [ ! -f "$CLANG_DIR/bindgen" ]; then
echo "** clang/parser not found. Building now."
cd "$CLANG_DIR"
( cmake . && make -j ) || print_clang_error
cd -
fi
OLD_PWD="$PWD"
cd "$BASE"
if [[ "$@" == *"--chdir"* ]]; then
exec crystal run "$SOURCE_FILE" -- $@
else
exec crystal run "$SOURCE_FILE" -- --chdir "$OLD_PWD" $@
fi
echo 'If you see this, something went horribly wrong.'
echo ' 1) Make sure you have crystal installed'
echo ' 2) Make sure `crystal` is in your $PATH'
exit 127