forked from microsoft/devicescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (92 loc) · 3.16 KB
/
Makefile
File metadata and controls
120 lines (92 loc) · 3.16 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
CC = gcc
INC = -Ijacdac-c/inc -Iinc -I. -Ijacdac-c -Ijacdac-c/jacscript
Q ?= @
CFLAGS = $(DEFINES) $(INC) \
-O0 -g3 \
-Wall -Wextra -Wno-unused-parameter -Wno-shift-negative-value -Wstrict-prototypes -Werror \
-Wno-strict-aliasing -Wno-error=unused-function -Wno-error=cpp \
-Wno-error=unused-variable
_IGNORE1 := $(shell test -f jacdac-c/README.md || git submodule update --init --recursive 1>&2)
_IGNORE2 := $(shell test -f jacdac-c/jacscript/sha-2/README.md || (cd jacdac-c && git submodule update --init --recursive 1>&2))
DEPS = $(wildcard \
inc/*.h \
jacdac-c/jacdac/dist/c/*.h \
jacdac-c/inc/*.h \
jacdac-c/jacscript/*.h \
jacdac-c/inc/interfaces/*.h \
jacdac-c/services/*.h \
jacdac-c/services/interfaces/*.h \
)
DEPS += Makefile
LDFLAGS = -flto -g3
BUILT = built
JDS = jacdac-c/source
SRC = $(wildcard posix/*.c) \
$(wildcard jacdac-c/client/*.c) \
$(wildcard jacdac-c/jacscript/*.c) \
$(wildcard jacdac-c/network/*.c) \
jacdac-c/jacdac/dist/c/jd_spec_pack.c \
$(wildcard $(JDS)/*.c) \
$(wildcard $(JDS)/interfaces/*.c) \
jacdac-c/storage/crc32.c \
jacdac-c/storage/lstore.c \
OBJ = $(addprefix $(BUILT)/,$(SRC:.c=.o))
all: native em comp
native:
$(Q)$(MAKE) -j16 $(BUILT)/jdcli
$(BUILT)/jdcli: $(OBJ)
@echo LD $@
$(Q)$(CC) $(LDFLAGS) -o $@ $(OBJ) -lm -lpthread
$(BUILT)/%.o: %.c $(DEPS)
@echo CC $<
@mkdir -p $(dir $@)
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -rf $(BUILT) vm/built compiler/built
full-clean: clean
rm -rf vm/node_modules compiler/node_modules
gdb: native
gdb -x scripts/gdbinit
vg: native
valgrind --suppressions=scripts/valgrind.supp --show-reachable=yes --leak-check=full --gen-suppressions=all ./built/jdcli samples/ex-test.jacs
EMCC_OPTS = $(DEFINES) $(INC) \
-g2 -O1 \
-s WASM=1 \
-s MODULARIZE=1 \
-s SINGLE_FILE=1 \
-s ASSERTIONS=1 \
-s EXPORTED_FUNCTIONS=_malloc,_free \
-s ENVIRONMENT=web,webview,worker,node \
--no-entry
vm/built/wasmpre.js: vm/wasmpre.ts vm/node_modules/typescript
cd vm && yarn build
sed -e 's/export default factory/export = factory/' vm/built/wasmpre.d.ts > vm/dist/types.d.ts
vm/node_modules/typescript:
cd vm && yarn install
compiler/node_modules/typescript:
cd compiler && yarn install
VM_TMP_FILE = vm/built/jacscript-vm.js
VM_FILE = vm/dist/jacscript-vm.js
$(VM_TMP_FILE): vm/built/wasmpre.js $(SRC) $(DEPS)
@mkdir -p vm/dist
sed -e 's/^export var/var/' $< | grep -v '^export ' > $(BUILT)/pre.js
emcc $(EMCC_OPTS) -o $@ --pre-js $(BUILT)/pre.js $(SRC) -lwebsocket.js
$(VM_FILE): $(VM_TMP_FILE)
@mkdir -p vm/dist
cp $(VM_TMP_FILE) $(VM_FILE)
em: $(VM_TMP_FILE)
comp: compiler/node_modules/typescript compiler/built/compiler/src/jacscript.js
compiler/built/compiler/src/jacscript.js: $(wildcard compiler/src/*.ts) $(wildcard compiler/lib/*.ts)
cd compiler && node build.js
comp-fast:
@mkdir -p built
cd compiler && node build.js --fast
test-c: native comp
node run -c -t compiler/run-tests/basic.ts
test-em: em comp
node run test
test: test-c test-em
update-dist: $(VM_FILE)
git add $(VM_FILE) vm/dist/types.d.ts
if [ "X$$GITHUB_WORKFLOW" != "X" ] ; then git config user.email "<>" && git config user.name "GitHub Bot" ; fi
if git commit -m "[skip ci] rebuild $(VM_FILE)" ; then git push ; fi