-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
70 lines (48 loc) · 1.33 KB
/
Makefile
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
TOOLS_OUT = tools/out
WASM_OUT = web/public/wasm
BINTOSYX = bintosyx
SYXTOBIN = syxtobin
FWGEN = fwgen
GPP_FLAGS = -std=c++11 -O2 -I common
ifeq ($(OS),Windows_NT)
EMSDK_ENV = "%USERPROFILE%/emsdk/emsdk_env.bat"
define rmdir
if exist "$(1)" rd /s /q "$(1)"
endef
MKDIR = md
define tools
echo Building CLI tools via make is not supported on Windows. Use Visual Studio.
endef
else
EMSDK_ENV = . ~/emsdk/emsdk_env.sh
define rmdir
rm -rf "$(1)"
endef
MKDIR = mkdir -p
define tools
cd tools && g++ $(GPP_FLAGS) -o ../$(TOOLS_OUT)/$(1) common/common.cpp common/cli.cpp $(1)/parse.cpp $(1)/$(1).cpp
endef
endif
define wasm
$(MKDIR) "$(WASM_OUT)"
cd tools && $(EMSDK_ENV) --build=Release && emcc $(GPP_FLAGS) $(1) \
-o ../$(WASM_OUT)/$(FWGEN).js common/common.cpp $(BINTOSYX)/$(BINTOSYX).cpp $(SYXTOBIN)/$(SYXTOBIN).cpp web-$(FWGEN)/patches.cpp web-$(FWGEN)/wasm.cpp \
-s "EXTRA_EXPORTED_RUNTIME_METHODS=['cwrap']" \
--embed-file ../firmware/stock@firmware
endef
all: clean tools wasm web
clean_tools:
$(call rmdir,$(TOOLS_OUT))
clean_wasm:
$(call rmdir,$(WASM_OUT))
clean: clean_tools clean_wasm
tools: clean_tools
$(MKDIR) "$(TOOLS_OUT)"
$(call tools,$(BINTOSYX))
$(call tools,$(SYXTOBIN))
wasm: clean_wasm
$(call wasm,)
wasm-debug: clean_wasm
$(call wasm,-g4 -s ASSERTIONS=1)
web: wasm
cd web && pnpm install && pnpm build