-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild_playground.sh
executable file
·55 lines (44 loc) · 1.35 KB
/
build_playground.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
47
48
49
50
51
52
53
54
#!/bin/sh
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd $SCRIPT_DIR
EMS_PATH=/usr/lib/emscripten;
USE_DOCKER=false;
SHOW_HELP=false;
usage()
{
echo "Usage: $0 [option]..."
echo " options:"
echo " -e, --emscripten-path=LIB_PATH emscripten lib path."
echo " default: '$EMS_PATH'"
echo " -d, --docker run emscripten via docker even"
echo " if it is installed locally."
echo " -h, --help, show help.";
exit 1;
}
PARSED_ARGS=$(getopt -n "$0" -o e:dh --long emscripten-path:docker,help -- "$@");
[ $? -ne 0 ] && usage;
eval set -- "$PARSED_ARGS";
while true; do
case "$1" in
-e|--emscripten-path) EMS_PATH="$2"; shift 2 ;;
-d|--docker) USE_DOCKER=true; shift ;;
-h|--help) SHOW_HELP=true; shift ;;
--) shift; break ;;
*) printf "Option '$1' is not valid!\n"; usage ;;
esac
done
[ "$SHOW_HELP" = true ] && usage;
build_aborted()
{
echo "Build aborted.";
exit 1;
}
echo "Building tree-sitter-c3.wasm in '$SCRIPT_DIR/docs/tree-sitter-c3.wasm"
if [ "$USE_DOCKER" = true ] ; then
tree-sitter build -d -w -o ./docs/playground/tree-sitter-c3.wasm;
[ $? -ne 0 ] && build_aborted;
else
PATH=$PATH:$EMS_PATH tree-sitter build -w -o ./docs/playground/tree-sitter-c3.wasm;
[ $? -ne 0 ] && build_aborted;
fi
exit 0;