This repository was archived by the owner on Nov 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
37 lines (27 loc) · 1.25 KB
/
Copy pathbuild.bat
File metadata and controls
37 lines (27 loc) · 1.25 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
@echo off
set ADDON_NAME=waddon
:: WebIDL Definitions of your exported functions
set IDL=%ADDON_NAME%.idl
:: Main entrypoint
set IN=src/%ADDON_NAME%.cpp
:: Header definition of exports from main entrypoint
set HEADER=src/%ADDON_NAME%.hpp
:: Output file
set OUT=%ADDON_NAME%.wasm
:: Bindings that will be autogenerated by lua-webidl
set BINDS=bindings.cpp
:: Stack Size
set STACK=6000000
:: For wasi-sdk path, see https://github.com/WebAssembly/wasi-sdk
:: This is necessary to use the standard library headers with your addons
set SYSROOT=%WASI_SDK_PATH%/share/wasi-sysroot
set CLANG=%WASI_SDK_PATH%/bin/clang
set "EMULATE=-D_WASI_EMULATED_SIGNAL -lwasi-emulated-signal"
set "LIBS=tiny-json/tiny-json.c pocketlang/src/*.c -Ipocketlang/src/include -lm"
:: Make wasi safe bindings
:: Note that the batchfile hangs here because.. it doesn't close properly? Should make an issue for this
lua-webidl %IDL% %BINDS% %HEADER% --cpp
:: Compile the newly created bindings, your project into .wasm
%CLANG% %IN% %BINDS% %LIBS% --sysroot=%SYSROOT% --target=wasm32-wasi -O3 -Wl,-z,stack-size=%STACK%,--allow-undefined,-export-dynamic -fvisibility=hidden -o %OUT% %EMULATE% -DHEAP_SIZE=55
:: Turn the .wasm output into lua!
wasm2lua %OUT% %ADDON_NAME%.lua -b %IDL% --libmode --pureLua --m3