diff options
author | 深淵の鴿子 <71170059+ZerxZ@users.noreply.github.com> | 2024-10-27 20:51:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-28 11:51:48 +0800 |
commit | 3387abbfe072cbfe1ed1e7a3d71668603831591b (patch) | |
tree | 22a7601ed657750ae57ad45d5d3ee8f6d88b18f3 /makefile | |
parent | 1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0 (diff) | |
download | yuescript-3387abbfe072cbfe1ed1e7a3d71668603831591b.tar.gz yuescript-3387abbfe072cbfe1ed1e7a3d71668603831591b.tar.bz2 yuescript-3387abbfe072cbfe1ed1e7a3d71668603831591b.zip |
Add Support WASM ESM and CommonJs module, Typescript. (#176)
Diffstat (limited to 'makefile')
-rw-r--r-- | makefile | 122 |
1 files changed, 121 insertions, 1 deletions
@@ -207,11 +207,131 @@ endif | |||
207 | @echo -n "Total build time: " | 207 | @echo -n "Total build time: " |
208 | @$(END_TIME) | 208 | @$(END_TIME) |
209 | 209 | ||
210 | .PHONY: wasm-node | ||
211 | wasm-node: clean | ||
212 | @$(MAKE) generic CC='emcc' AR='emar rcu' RANLIB='emranlib' -C $(SRC_PATH)/3rdParty/lua | ||
213 | @mkdir -p wasm/dist | ||
214 | @mkdir -p wasm/dist/esm | ||
215 | @mkdir -p wasm/dist/cjs | ||
216 | # ESM Module | ||
217 | @emcc $(SRC_PATH)/yue_wasm.cpp \ | ||
218 | $(SRC_PATH)/yuescript/ast.cpp \ | ||
219 | $(SRC_PATH)/yuescript/yue_ast.cpp \ | ||
220 | $(SRC_PATH)/yuescript/parser.cpp \ | ||
221 | $(SRC_PATH)/yuescript/yue_compiler.cpp \ | ||
222 | $(SRC_PATH)/yuescript/yue_parser.cpp \ | ||
223 | $(SRC_PATH)/yuescript/yuescript.cpp \ | ||
224 | $(SRC_PATH)/3rdParty/lua/liblua.a \ | ||
225 | -O2 \ | ||
226 | -o wasm/dist/esm/yuescript.mjs \ | ||
227 | -I $(SRC_PATH) \ | ||
228 | -I $(SRC_PATH)/3rdParty/lua \ | ||
229 | -std=c++17 \ | ||
230 | --bind \ | ||
231 | -fexceptions \ | ||
232 | -Wno-deprecated-declarations \ | ||
233 | -gsource-map \ | ||
234 | --emit-tsd="yuescript.d.ts" \ | ||
235 | -s EXPORT_NAME="'_createYuescriptModule'" \ | ||
236 | -s EXPORT_EXCEPTION_HANDLING_HELPERS \ | ||
237 | -s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules'] \ | ||
238 | -sEXPORTED_RUNTIME_METHODS='wasmTable,ERRNO_CODES' \ | ||
239 | -s FORCE_FILESYSTEM=1 \ | ||
240 | -s TOTAL_MEMORY=20971520 \ | ||
241 | -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' \ | ||
242 | -s EXPORT_ALL=1 \ | ||
243 | -s FS_DEBUG=1 \ | ||
244 | -s STACK_SIZE=5MB \ | ||
245 | -s AUTO_JS_LIBRARIES=0 \ | ||
246 | -s AUTO_NATIVE_LIBRARIES=0 \ | ||
247 | -s NODEJS_CATCH_EXIT=0 \ | ||
248 | -s NODEJS_CATCH_REJECTION=0 \ | ||
249 | -sGL_WORKAROUND_SAFARI_GETCONTEXT_BUG=0 \ | ||
250 | -s USE_ZLIB \ | ||
251 | -s USE_BZIP2 \ | ||
252 | -s WASM_BIGINT \ | ||
253 | -s MODULARIZE=1 \ | ||
254 | -s LZ4=1 | ||
255 | # CommonJS Module | ||
256 | @emcc $(SRC_PATH)/yue_wasm.cpp \ | ||
257 | $(SRC_PATH)/yuescript/ast.cpp \ | ||
258 | $(SRC_PATH)/yuescript/yue_ast.cpp \ | ||
259 | $(SRC_PATH)/yuescript/parser.cpp \ | ||
260 | $(SRC_PATH)/yuescript/yue_compiler.cpp \ | ||
261 | $(SRC_PATH)/yuescript/yue_parser.cpp \ | ||
262 | $(SRC_PATH)/yuescript/yuescript.cpp \ | ||
263 | $(SRC_PATH)/3rdParty/lua/liblua.a \ | ||
264 | -O2 \ | ||
265 | -o wasm/dist/cjs/yuescript.cjs \ | ||
266 | --emit-tsd="yuescript.d.ts" \ | ||
267 | -I $(SRC_PATH) \ | ||
268 | -I $(SRC_PATH)/3rdParty/lua \ | ||
269 | -std=c++17 \ | ||
270 | --bind \ | ||
271 | -fexceptions \ | ||
272 | -Wno-deprecated-declarations \ | ||
273 | -gsource-map \ | ||
274 | -s EXPORT_NAME="'_createYuescriptModule'" \ | ||
275 | -s EXPORT_EXCEPTION_HANDLING_HELPERS \ | ||
276 | -s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules'] \ | ||
277 | -sEXPORTED_RUNTIME_METHODS='wasmTable,ERRNO_CODES' \ | ||
278 | -s FORCE_FILESYSTEM=1 \ | ||
279 | -s TOTAL_MEMORY=20971520 \ | ||
280 | -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' \ | ||
281 | -s EXPORT_ALL=1 \ | ||
282 | -s FS_DEBUG=1 \ | ||
283 | -s STACK_SIZE=5MB \ | ||
284 | -s AUTO_JS_LIBRARIES=0 \ | ||
285 | -s AUTO_NATIVE_LIBRARIES=0 \ | ||
286 | -s NODEJS_CATCH_EXIT=0 \ | ||
287 | -s NODEJS_CATCH_REJECTION=0 \ | ||
288 | -sGL_WORKAROUND_SAFARI_GETCONTEXT_BUG=0 \ | ||
289 | -s USE_ZLIB \ | ||
290 | -s USE_BZIP2 \ | ||
291 | -s WASM_BIGINT\ | ||
292 | -s MODULARIZE=1\ | ||
293 | -s LZ4=1 | ||
294 | @${MAKE} clean | ||
295 | |||
210 | .PHONY: wasm | 296 | .PHONY: wasm |
211 | wasm: clean | 297 | wasm: clean |
212 | @$(MAKE) generic CC='emcc' AR='emar rcu' RANLIB='emranlib' -C $(SRC_PATH)/3rdParty/lua | 298 | @$(MAKE) generic CC='emcc' AR='emar rcu' RANLIB='emranlib' -C $(SRC_PATH)/3rdParty/lua |
213 | @mkdir -p doc/docs/.vuepress/public/js | 299 | @mkdir -p doc/docs/.vuepress/public/js |
214 | @emcc $(SRC_PATH)/yue_wasm.cpp $(SRC_PATH)/yuescript/ast.cpp $(SRC_PATH)/yuescript/yue_ast.cpp $(SRC_PATH)/yuescript/parser.cpp $(SRC_PATH)/yuescript/yue_compiler.cpp $(SRC_PATH)/yuescript/yue_parser.cpp $(SRC_PATH)/yuescript/yuescript.cpp $(SRC_PATH)/3rdParty/lua/liblua.a -O2 -o doc/docs/.vuepress/public/js/yuescript.js -I $(SRC_PATH) -I $(SRC_PATH)/3rdParty/lua -std=c++17 --bind -fexceptions -Wno-deprecated-declarations | 300 | @emcc $(SRC_PATH)/yue_wasm.cpp \ |
301 | $(SRC_PATH)/yuescript/ast.cpp \ | ||
302 | $(SRC_PATH)/yuescript/yue_ast.cpp \ | ||
303 | $(SRC_PATH)/yuescript/parser.cpp \ | ||
304 | $(SRC_PATH)/yuescript/yue_compiler.cpp \ | ||
305 | $(SRC_PATH)/yuescript/yue_parser.cpp \ | ||
306 | $(SRC_PATH)/yuescript/yuescript.cpp \ | ||
307 | $(SRC_PATH)/3rdParty/lua/liblua.a \ | ||
308 | -O2 \ | ||
309 | -o doc/docs/.vuepress/public/js/yuescript.js \ | ||
310 | -I $(SRC_PATH) \ | ||
311 | -I $(SRC_PATH)/3rdParty/lua \ | ||
312 | -std=c++17 \ | ||
313 | --bind \ | ||
314 | -fexceptions \ | ||
315 | -Wno-deprecated-declarations \ | ||
316 | -s EXPORT_EXCEPTION_HANDLING_HELPERS \ | ||
317 | -s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules'] \ | ||
318 | -sEXPORTED_RUNTIME_METHODS='wasmTable,ERRNO_CODES' \ | ||
319 | -s FORCE_FILESYSTEM=1 \ | ||
320 | -s TOTAL_MEMORY=20971520 \ | ||
321 | -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' \ | ||
322 | -s EXPORT_ALL=1 \ | ||
323 | -s FS_DEBUG=1 \ | ||
324 | -s STACK_SIZE=5MB \ | ||
325 | -s AUTO_JS_LIBRARIES=0 \ | ||
326 | -s AUTO_NATIVE_LIBRARIES=0 \ | ||
327 | -s NODEJS_CATCH_EXIT=0 \ | ||
328 | -s NODEJS_CATCH_REJECTION=0 \ | ||
329 | -sGL_WORKAROUND_SAFARI_GETCONTEXT_BUG=0 \ | ||
330 | -s USE_ZLIB \ | ||
331 | -s USE_BZIP2 \ | ||
332 | -s WASM_BIGINT\ | ||
333 | -s MODULARIZE=1 \ | ||
334 | -s LZ4=1 | ||
215 | @${MAKE} clean | 335 | @${MAKE} clean |
216 | 336 | ||
217 | # Debug build for gdb debugging | 337 | # Debug build for gdb debugging |