-
Notifications
You must be signed in to change notification settings - Fork 88
/
Makefile
154 lines (131 loc) · 3.6 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# if you are using windows, comment line 5, 6 and 7 and uncomment line 8, 9 and 10
# leave it as it was before committing as travis uses linux
SRCDIR := src
TESTDIR := test
SRCS := $(shell find $(SRCDIR) -name "*.js")
SRCSCPP := $(shell find $(SRCDIR) -name "*.cpp")
TEST_FILES := $(shell find $(TESTDIR) -name "*.cpp")
#SRCS := $(shell FORFILES /P $(SRCDIR) /S /M *.js /C "CMD /C ECHO @relpath")
#SRCSCPP := $(shell FORFILES /P $(SRCDIR) /S /M *.cpp /C "CMD /C ECHO @relpath")
#TEST_FILES := $(shell FORFILES /P $(TESTDIR) /S /M *.cpp /C "CMD /C ECHO @relpath")
ESDIR := es
LIBDIR := lib
ES := $(SRCS:$(SRCDIR)/%=$(ESDIR)/%)
LIBS := $(SRCS:$(SRCDIR)/%=$(LIBDIR)/%)
DISTDIR := dist
DISTJS := $(DISTDIR)/js
UMDJS := $(DISTJS)/asm-dom.js
TESTCPP := test/cpp/app.asm.js
COMPILED := compiled
COMPILEDASMJS := $(COMPILED)/asmjs
COMPILEDWASM := $(COMPILED)/wasm
CPPDIR := cpp
TREE := \
$(COMPILED) \
$(COMPILEDASMJS) \
$(COMPILEDWASM) \
$(DISTDIR) \
$(DISTJS) \
$(ESDIR) \
$(LIBDIR) \
$(sort $(patsubst %/,%,$(dir $(ES)))) \
$(sort $(patsubst %/,%,$(dir $(LIBS))))
FILES = \
src/cpp/asm-dom.cpp \
src/cpp/asm-dom-server.cpp
BC = compiled/asm-dom.bc
CFLAGS = \
-O3 \
--bind \
-Wall \
-Werror \
-Wall \
-Wno-deprecated \
-Wno-parentheses \
-Wno-format
WASM_OPTIONS = \
-O3 \
--bind \
--memory-init-file 0 \
--llvm-lto 3 \
--llvm-opts 3 \
--js-opts 1 \
--closure 1 \
-s ENVIRONMENT=node \
-s MODULARIZE=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s AGGRESSIVE_VARIABLE_ELIMINATION=1 \
-s ABORTING_MALLOC=1 \
-s NO_EXIT_RUNTIME=1 \
-s NO_FILESYSTEM=1 \
-s DISABLE_EXCEPTION_CATCHING=2 \
-s BINARYEN=1 \
-s EXPORTED_RUNTIME_METHODS=[\'UTF8ToString\'] \
-s BINARYEN_TRAP_MODE=\'allow\'
ASMJS_OPTIONS = \
-O3 \
--bind \
--memory-init-file 0 \
--llvm-lto 3 \
--llvm-opts 3 \
--js-opts 1 \
--closure 1 \
-s ENVIRONMENT=node \
-s MODULARIZE=1 \
-s AGGRESSIVE_VARIABLE_ELIMINATION=1 \
-s ELIMINATE_DUPLICATE_FUNCTIONS=1 \
-s ABORTING_MALLOC=1 \
-s NO_EXIT_RUNTIME=1 \
-s NO_FILESYSTEM=1 \
-s DISABLE_EXCEPTION_CATCHING=2 \
-s EXPORTED_RUNTIME_METHODS=[\'UTF8ToString\'] \
-s WASM=0
.PHONY: all install clean lint test test_js test_watch build
all: build
install:
npm install
clean:
npx rimraf $(DISTDIR) $(LIBDIR) $(ESDIR) $(CPPDIR) .nyc_output $(COMPILED) $(TESTCPP)
lint:
npx eslint src test build
test: $(COMPILEDASMJS)/asm-dom.asm.js $(COMPILEDWASM)/asm-dom.js $(TESTCPP) test_js
test_js:
npx cross-env BABEL_ENV=commonjs TEST_ENV=node mocha --require babel-register test/cpp/toHTML/toHTML.spec.js
npx cross-env BABEL_ENV=commonjs TEST_ENV=node mocha --require babel-register test/js/toHTML.spec.js
npx cross-env BABEL_ENV=commonjs nyc --require babel-register mocha --recursive
build: compiled/asm-dom.a $(BC) compiled/asm-dom.o $(COMPILEDASMJS)/asm-dom.asm.js $(COMPILEDWASM)/asm-dom.js $(TESTCPP) $(LIBS) $(ES) $(UMDJS)
npx ncp $(SRCDIR)/cpp $(CPPDIR)
$(TESTCPP): $(SRCSCPP) $(TEST_FILES)
emcc \
-DASMDOM_TEST \
$(CFLAGS) \
$(ASMJS_OPTIONS) \
$(FILES) \
$(TEST_FILES) \
-o $@
.SECONDEXPANSION:
$(COMPILED)/asm-dom.%: $(SRCSCPP) | $$(@D)
emcc \
-DASMDOM_JS_SIDE \
$(CFLAGS) \
$(FILES) \
src/js/index.cpp \
-o $@
$(COMPILEDASMJS)/asm-dom.asm.js: $(BC) | $$(@D)
emcc \
$(ASMJS_OPTIONS) \
$(BC) \
-o $@
$(COMPILEDWASM)/asm-dom.js: $(BC) | $$(@D)
emcc \
$(WASM_OPTIONS) \
$(BC) \
-o $@
$(ESDIR)/%: $(SRCDIR)/% | $$(@D)
npx cross-env BABEL_ENV=es babel $< --out-file $@
$(LIBDIR)/%: $(SRCDIR)/% | $$(@D)
npx cross-env BABEL_ENV=commonjs babel $< --out-file $@
$(UMDJS): $(SRCS) | $$(@D)
npx cross-env BABEL_ENV=commonjs webpack --env.prod src/js/index.js $@
$(TREE): %:
npx mkdirp $@