-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile.emscripten
More file actions
57 lines (40 loc) · 1.92 KB
/
Makefile.emscripten
File metadata and controls
57 lines (40 loc) · 1.92 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
CC := emcc
CXX := em++
DEBUG ?= 0
ifeq ($(DEBUG),1)
OPTFLAGS := -O0 -g3 -flto
ASSERTIONS := 2
DEBUG_EMFLAGS := -s SAFE_HEAP=1
else
OPTFLAGS := -O3 -flto
ASSERTIONS := 0
DEBUG_EMFLAGS :=
endif
# Emscripten stuff
EMFLAGS := --bind -s WASM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME="'TIVarsLib'" -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=$(ASSERTIONS) -s DISABLE_EXCEPTION_CATCHING=0 -s EXPORTED_RUNTIME_METHODS="['FS','getExceptionMessage','decrementExceptionRefcount']" $(DEBUG_EMFLAGS)
CXXFLAGS := $(OPTFLAGS) -std=c++2a -DTH_GDB_SUPPORT=1 -Ivendor/pugixml -W -Wall -Wextra -fexceptions
CFLAGS := $(OPTFLAGS) -std=c2x -W -Wall -Wextra
LFLAGS := $(OPTFLAGS) $(EMFLAGS)
SOURCES := $(wildcard src/*.cpp) $(wildcard src/TypeHandlers/*.cpp) $(wildcard src/TypeHandlers/*.c) vendor/pugixml/pugixml.cpp
OBJS = $(patsubst %.c, %.bc, $(patsubst %.cpp, %.bc, $(SOURCES)))
OUTPUT := TIVarsLib
TEST_OUTPUT := tivars_tests_wasm
wasm: $(OUTPUT).js
all: wasm
wasm-tests: $(TEST_OUTPUT).js
node --no-warnings scripts/run_wasm_tests.mjs
%.bc: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
%.bc: %.c
$(CC) $(CFLAGS) -c $< -o $@
$(OUTPUT).js: $(OBJS)
$(CXX) $(CXXFLAGS) $(LFLAGS) $^ -o $@
tests_wasm.bc: tests.cpp
$(CXX) $(CXXFLAGS) -Dmain=tivars_tests_main -c $< -o $@
scripts/wasm_tests_main.bc: scripts/wasm_tests_main.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
$(TEST_OUTPUT).js: $(filter-out src/main_emscripten.bc,$(OBJS)) tests_wasm.bc scripts/wasm_tests_main.bc
$(CXX) $(CXXFLAGS) $(OPTFLAGS) --bind -s WASM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME="'TIVarsTests'" -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s ASSERTIONS=$(ASSERTIONS) -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_RUNTIME_METHODS="['callMain','getExceptionMessage','decrementExceptionRefcount']" $^ -o $@
clean:
$(RM) -f $(OBJS) tests_wasm.bc scripts/wasm_tests_main.bc $(OUTPUT).js* $(OUTPUT).was* $(TEST_OUTPUT).js* $(TEST_OUTPUT).was*
.PHONY: all clean wasm wasm-tests