-
Notifications
You must be signed in to change notification settings - Fork 0
/
emcc-rules.mk
41 lines (34 loc) · 1.69 KB
/
emcc-rules.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
# Build rules to create a javascript library using emscripten
#
# Required variables
# - TARGET_NAME - Output file name
#
# Optional variables
# - LIBRARIES_DEBUG - Space separated list of all debug *.bc files that will be compiled
# - LIBRARIES_SHIP - Space separated list of all ship *.bc files that will be compiled
# - LIBRARIES_FLAGS_DEBUG - Space separated list of all debug -I and -L flags to pass to the compiler
# - LIBRARIES_FLAGS_SHIP - Space separated list of all ship -I and -L flags to pass to the compiler
# Outputs
TARGET_NAME_ES6 = $(TARGET_NAME).es6.js
TARGET_NAME_ES6_DEBUG = $(call FixPath,debug/$(TARGET_NAME_ES6))
TARGET_NAME_ES6_SHIP = $(call FixPath,ship/$(TARGET_NAME_ES6))
TARGET_NAME_GCC = $(TARGET_NAME).js
TARGET_NAME_GCC_DEBUG = $(call FixPath,debug/$(TARGET_NAME_GCC))
TARGET_NAME_GCC_SHIP = $(call FixPath,ship/$(TARGET_NAME_GCC))
# emcc flags
EMCC_JS_WRAPPER = -s MODULARIZE=1 -s SINGLE_FILE=1 -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0
all: debug ship
debug: $(TARGET_NAME_GCC_DEBUG)
ship: $(TARGET_NAME_GCC_SHIP)
# Required because EXPORT_ES6 outputs ES6 specific code and most libraries export ES5
$(TARGET_NAME_GCC_DEBUG): $(NPM_SUCCESS) $(TARGET_NAME_ES6_DEBUG)
npm run build-debug
# Required because EXPORT_ES6 outputs ES6 specific code and most libraries export ES5
$(TARGET_NAME_GCC_SHIP): $(NPM_SUCCESS) $(TARGET_NAME_ES6_SHIP)
npm run build-ship
$(TARGET_NAME_ES6_DEBUG): $(LIBRARIES_DEBUG)
$(call MakeDir,$(dir $@))
emcc --bind $(LIBRARIES_DEBUG) -o $(TARGET_NAME_ES6_DEBUG) $(EMCC_FLAGS_DEBUG) $(EMCC_JS_WRAPPER)
$(TARGET_NAME_ES6_SHIP): $(LIBRARIES_SHIP)
$(call MakeDir,$(dir $@))
emcc --bind $(LIBRARIES_SHIP) -o $(TARGET_NAME_ES6_SHIP) $(EMCC_FLAGS_SHIP) $(EMCC_JS_WRAPPER)