-
Notifications
You must be signed in to change notification settings - Fork 5
/
compile-bc
executable file
·55 lines (48 loc) · 1.17 KB
/
compile-bc
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
55
#!/bin/sh
SRC=;
SRC_DIRS="src/data src/geom src/geom/clip src/math src/mem src/sim"
for d in $SRC_DIRS; do for f in `ls $d/*.c`; do SRC="$SRC $f"; done; done;
CFLAGS="-std=c11 -Os -Isrc -Iext -DCT_NO_EXPORT"
EMFLAGS="-s ASM_JS=1 -s ASSERTIONS=0 --js-library src/rt_cthing.js"
BUILD_DIR=obj
OUT=$BUILD_DIR/libcthing.bc
usage()
{
cat <<EOF
Usage:
-d : remove duplicate functions
-D SYM : add define
-h : show this help
-k : enable runtime checks
-m : enable memory checks
EOF
exit 1
}
while getopts dhkmD: opt; do
case $opt in
d) EMFLAGS="$EMFLAGS -s ELIMINATE_DUPLICATE_FUNCTIONS=1"
;;
k) CFLAGS="$CFLAGS -DCT_FEATURE_CHECKS"
;;
m) CFLAGS="$CFLAGS -DCT_FEATURE_CHECK_MEM"
;;
h) usage
;;
D) CFLAGS="$CFLAGS -D$OPTARG"
;;
\?) echo "invalid option: $opt" >&2
usage
exit 1
;;
:) echo "$opt missing argument" >&2
usage
exit 1
;;
esac
done
echo "cflags: $CFLAGS"
echo "emflags: $EMFLAGS"
echo "src: $SRC"
mkdir -p $BUILD_DIR
time emcc $CFLAGS $EMFLAGS -o $OUT $SRC
ls -la $OUT