-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwasm.mk
73 lines (57 loc) · 2.05 KB
/
wasm.mk
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
X_CFLAGS += -std=gnu11 -O3 -g -ggdb $(W_FLAGS)
X_INCDIRS += include
SRC += src/*.c src/element/*.c src/bind/*.c src/bind/element/*.c src/cache/*.c src/utils/*.c
# stb
X_INCDIRS += lib/stb/include
SRC += lib/stb/*.c
# pulogovg
X_INCDIRS += lib/plutovg/include lib/plutovg/3rdparty/software
SRC += lib/plutovg/source/*.c lib/plutovg/3rdparty/software/*.c
# pulogosvg
X_INCDIRS += lib/plutosvg/include
SRC += lib/plutosvg/source/*.c
# flex
X_INCDIRS += lib/flex/include
SRC += lib/flex/*.c
# QuickJS
X_INCDIRS += lib/QuickJS
X_DEFINES += _GNU_SOURCE CONFIG_VERSION=\"$(shell cat $(obj)/lib/QuickJS/VERSION)\" alloca=__builtin_alloca
SRC += lib/QuickJS/quickjs.c lib/QuickJS/libregexp.c lib/QuickJS/libunicode.c lib/QuickJS/cutils.c
# hashmap
X_INCDIRS += lib/hashmap/include
SRC += lib/hashmap/src/*.c
# pqueue
X_INCDIRS += lib/pqueue
SRC += lib/pqueue/*.c
SRC += src/platform/sdl2-core-wasm/*.c
X_LDFLAGS += -lSDL2
X_OUTPUT = meui.wasm
# OPTIMIZE = -DCONFIG_VERSION=\"1.0.0\" -DEMSCRIPTEN -lm -Oz -Wall --llvm-lto 1 -fno-exceptions
X_SOURCE := $(foreach f,$(filter-out %/, $(SRC)),$(wildcard $(f)))
X_CPPFLAGS := $(patsubst %, -I %, $(foreach d,$(X_INCDIRS),$(wildcard $(d))))
# CFLAGS = --target=wasm32-unknown-wasi -O0 \
# $(X_CPPFLAGS) \
# -Wl,--import-memory \
# -Wl,--export-all -Wl,--no-entry \
# -DCONFIG_VERSION=\"1.0.0\" -nostartfiles -DEMSCRIPTEN -D_WASI_EMULATED_SIGNAL
# all:
# clang $(CFLAGS) -o $(X_OUTPUT) $(X_SOURCE)
CFLAGS = $(X_CPPFLAGS) -DCONFIG_VERSION=\"1.0.0\" \
-s LLD_REPORT_UNDEFINED \
-s STRICT_JS=1 \
-s SINGLE_FILE=0 \
-s EXPORT_ES6=1 \
-s ASSERTIONS \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s EXIT_RUNTIME=0 \
-s EXPORTED_FUNCTIONS="['_js_cancel_main_loop', '_main']" \
-s EXPORTED_RUNTIME_METHODS="['FS', 'callMain', 'abort', 'ccall', 'cwrap']" \
-DEMSCRIPTEN -lm -Oz -Wall --llvm-lto 1 -fno-exceptions -s USE_SDL=2
all:
mkdir -p browser/gen
mkdir -p browser/public
emcc $(CFLAGS) -o browser/gen/meui.js $(X_SOURCE)
rm -rf browser/public/*
cp res browser/public -r
cp framework/polyfill.js browser/gen -r