This repository has been archived by the owner on Nov 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile
executable file
·92 lines (83 loc) · 2.32 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
#!/bin/sh
# compile with SIMD:
# ./compile.sh -asd
SRC=;
SRC_DIRS="src src/types src/protos"
for d in $SRC_DIRS; do for f in `ls $d/*.c`; do SRC="$SRC $f"; done; done;
TESTS=
CFLAGS="-std=c11 -Os -Isrc -I../geom-c/src"
EMFLAGS="-s ASM_JS=1 -s ASSERTIONS=0 -s INVOKE_RUN=1 -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s MODULARIZE=1 -s NO_EXIT_RUNTIME=1 -s TOTAL_MEMORY='16*1024*1024'"
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
-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 acdhkmstD: 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"
;;
k) CFLAGS="$CFLAGS -DCT_FEATURE_CHECKS"
;;
m) CFLAGS="$CFLAGS -DCT_FEATURE_CHECK_MEM"
;;
t) CFLAGS="$CFLAGS -DDEBUG -DCT_FEATURE_LOG"
TESTS=""
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..."
node postprocess.js
ls -la $MIN
#cp $OUT geom-cljs/resources/public/js/
#cp $MIN geom-cljs/resources/public/js/
# -s EXPORTED_FUNCTIONS=@exports.json
# -s ELIMINATE_DUPLICATE_FUNCTIONS_DUMP_EQUIVALENT_FUNCTIONS=1