-
Notifications
You must be signed in to change notification settings - Fork 18
/
tool.sh
executable file
·42 lines (33 loc) · 1.05 KB
/
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
39
40
41
42
#!/bin/bash
# Helper script to invoke `bindgen.cr`
if [[ "$OSTYPE" == "darwin"* ]]; then
BASE="$(dirname "$(greadlink -f "$0")")"
else
BASE="$(dirname "$(readlink -f "$0")")"
fi
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' in clang/ for debugging this issue."
echo " Full path to clang/: $CLANG_DIR"
exit 1
}
if [ ! -f "$CLANG_DIR/parser" ]; then
echo "** clang/parser not found. Building now."
cd "$CLANG_DIR"
( cmake . && make ) || 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