-
Notifications
You must be signed in to change notification settings - Fork 5
/
compile
executable file
·95 lines (86 loc) · 2.5 KB
/
compile
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
# compile with SIMD:
# ./compile.sh -asd
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;
TESTS=
CFLAGS="-std=c11 -O3 -Isrc -Iext"
EMFLAGS="-s ASM_JS=1 -s ASSERTIONS=0 -s INVOKE_RUN=0 -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s MODULARIZE=1 -s NO_EXIT_RUNTIME=1 -s TOTAL_MEMORY='48*1024*1024' --js-library src/rt_cthing.js"
OUT=cthing.js
MIN=cthing.min.js
usage()
{
cat <<EOF
Usage:
-a : separate asm.js output
-c : enable Closure compiler step
-d : remove duplicate functions
-e : disable function export
-D SYM : add define
-h : show this help
-k : enable runtime checks
-m : enable memory checks
-s : enable SSE (SIMD.js)
-t : include tests
EOF
exit 1
}
while getopts acdehkmstD: opt; do
case $opt in
s) CFLAGS="$CFLAGS -DCT_FEATURE_SSE -fslp-vectorize -msse2"
EMFLAGS="$EMFLAGS -s SIMD=1"
;;
a) EMFLAGS="$EMFLAGS --separate-asm"
;;
c) EMFLAGS="$EMFLAGS --closure 1"
;;
d) EMFLAGS="$EMFLAGS -s ELIMINATE_DUPLICATE_FUNCTIONS=1"
# EMFLAGS="$EMFLAGS -s ELIMINATE_DUPLICATE_FUNCTIONS_PASSES=5"
EMFLAGS="$EMFLAGS -s ELIMINATE_DUPLICATE_FUNCTIONS_DUMP_EQUIVALENT_FUNCTIONS=1"
;;
e) CFLAGS="$CFLAGS -DCT_NO_EXPORT"
;;
k) CFLAGS="$CFLAGS -DCT_FEATURE_CHECKS"
;;
m) CFLAGS="$CFLAGS -DCT_FEATURE_CHECK_MEM"
;;
t) CFLAGS="$CFLAGS -DNDEBUG -DCT_FEATURE_LOG"
TESTS="ext/ct-head/test.c"
for f in `ls test/*.c`; do TESTS="$TESTS $f"; done;
;;
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"
echo "test: $TESTS"
time emcc $CFLAGS \
--memory-init-file 0 \
--emit-symbol-map \
$EMFLAGS \
-s "TOTAL_STACK=1*1024*1024" \
-s "EXPORT_NAME='cthing'" \
-o $OUT \
$SRC \
$TESTS
ls -la $OUT
echo "postprocessing... $OUT -> $MIN"
node postprocess.js $OUT $MIN
ls -la $MIN
cp $OUT geom-cljs/resources/public/js/
cp $MIN geom-cljs/resources/public/js/
# -s [email protected]
# -s ELIMINATE_DUPLICATE_FUNCTIONS_DUMP_EQUIVALENT_FUNCTIONS=1