-
Notifications
You must be signed in to change notification settings - Fork 26
/
build.sh
executable file
·101 lines (94 loc) · 3.62 KB
/
build.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
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
96
97
98
99
100
101
# For testing ports only, unused for actual build process
function test_headers() {
echo "testing headers..."
$CC include/prmacros.h -o out/prmacros.pch
$CC include/prtypes.h -o out/prtypes.pch
$CC include/mo_pubtd.h -o out/mo_pubtd.pch
$CC include/mo_prvtd.h -o out/mo_prvtd.pch
$CC include/mochaapi.h -o out/mochaapi.pch
$CC include/mo_bcode.h -o out/mo_bcode.pch
$CC include/mo_parse.h -o out/mo_parse.pch
$CC include/mo_emit.h -o out/mo_emit.pch
$CC include/mo_scan.h -o out/mo_scan.pch
$CC include/prhash.h -o out/prhash.pch
$CC include/mo_atom.h -o out/mo_atom.pch
$CC include/mo_scope.h -o out/mo_scope.pch
$CC include/mochalib.h -o out/mochalib.pch
$CC include/mocha.h -o out/mocha.pch
$CC include/prarena.h -o out/prarena.pch
$CC include/prclist.h -o out/prclist.pch
$CC include/mo_cntxt.h -o out/mo_cntxt.pch
$CC src/alloca.h -o out/alloca.pch
$CC include/prprf.h -o out/prprf.pch
$CC include/prglobal.h -o out/prglobal.pch
$CC include/prlog.h -o out/prlog.pch
$CC include/prmem.h -o out/prmem.pch
$CC include/prmjtime.h -o out/prmjtime.pch
$CC include/prtime.h -o out/prtime.pch
$CC include/prlong.h -o out/prlong.pch
$CC include/prosdep.h -o out/prosdep.pch
$CC include/prunixos.h -o out/prunixos.pch
$CC include/prsync.h -o out/prsync.pch
}
function compile_objs() {
echo "compiling OBJS..."
$CC -Iinclude src/mo_array.c -c -o out/mo_array.o
$CC -Iinclude src/mo_atom.c -c -o out/mo_atom.o
$CC -Iinclude src/mo_bcode.c -c -o out/mo_bcode.o
$CC -Iinclude src/mo_bool.c -c -o out/mo_bool.o
$CC -Iinclude src/mo_cntxt.c -c -o out/mo_cntxt.o
$CC -Iinclude src/mo_date.c -Wno-dangling-else -c -o out/mo_date.o
$CC -Iinclude src/mo_emit.c -c -o out/mo_emit.o
$CC -Iinclude src/mo_fun.c -c -o out/mo_fun.o
$CC -Iinclude src/mo_math.c -c -o out/mo_math.o
$CC -Iinclude src/mo_num.c -Wno-non-literal-null-conversion -c -o out/mo_num.o
$CC -Iinclude src/mo_obj.c -c -o out/mo_obj.o
$CC -Iinclude src/mo_parse.c -c -o out/mo_parse.o
$CC -Iinclude src/mo_scan.c -c -o out/mo_scan.o
$CC -Iinclude src/mo_scope.c -c -o out/mo_scope.o
$CC -Iinclude src/mo_str.c -Wno-non-literal-null-conversion -c -o out/mo_str.o
$CC -Iinclude src/mocha.c -c -o out/mocha.o
$CC -Iinclude src/mochaapi.c -Wno-non-literal-null-conversion -c -o out/mochaapi.o
$CC -Iinclude src/mochalib.c -c -o out/mochalib.o
$CC -Iinclude src/prmjtime.c -c -o out/prmjtime.o
$CC -Iinclude src/prtime.c -c -o out/prtime.o
$CC -Iinclude src/prarena.c -c -o out/prarena.o
$CC -Iinclude src/prhash.c -c -o out/prhash.o
$CC -Iinclude src/prprf.c -c -o out/prprf.o
$CC -Iinclude src/prdtoa.c \
-Wno-logical-not-parentheses \
-Wno-shift-op-parentheses \
-Wno-parentheses \
-c -o out/prdtoa.o
$CC -Iinclude src/log2.c -c -o out/log2.o
$CC -Iinclude src/longlong.c -c -o out/longlong.o
}
function compile_native() {
export CC=clang
export AR=ar
compile_objs
echo "linking..."
$CC -Iinclude -Lout -lm tests/mo_shell.c out/*.o -o out/mo_shell
echo "mocha shell compiled!"
}
function compile_web() {
export CC=emcc
export AR=emar
compile_objs
echo "linking..."
$AR -rcs out/libmocha.a out/*.o
$CC -Iinclude -Lout -lmocha tests/mo_shell.c \
--shell-file src/shell.html \
-s NO_EXIT_RUNTIME=0 \
-s WASM=$1 \
-O2 \
-o $2
echo "mocha shell compiled!"
}
function compile_js() {
compile_web 0 out/mocha_shell_js.html
}
function compile_wasm() {
compile_web 1 out/mocha_shell_wasm.html
}
mkdir -p out