Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active January 17, 2023 10:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sogaiu/0fa007190e279b7b2563b0e5d5945df2 to your computer and use it in GitHub Desktop.
Save sogaiu/0fa007190e279b7b2563b0e5d5945df2 to your computer and use it in GitHub Desktop.
rough translation of tree-sitter's build-wasm script
@echo on
mkdir target\scratch
REM need control to return, so use cmd /c
cmd /c ^
emcc ^
-s WASM=1 ^
-s TOTAL_MEMORY=33554432 ^
-s ALLOW_MEMORY_GROWTH=1 ^
-s MAIN_MODULE=2 ^
-s NO_FILESYSTEM=1 ^
-s NODEJS_CATCH_EXIT=0 ^
-s NODEJS_CATCH_REJECTION=0 ^
-s EXPORTED_FUNCTIONS=@lib\binding_web\exports.json ^
-s EXPORTED_RUNTIME_METHODS='stringToUTF16','AsciiToString' ^
-s ASSERTIONS=1 -s SAFE_HEAP=1 -O0 ^
-fno-exceptions ^
-std=c99 ^
-Dfprintf(...)= ^
-D NDEBUG= ^
-I lib\src ^
-I lib\include ^
--js-library lib\binding_web\imports.js ^
--pre-js lib\binding_web\prefix.js ^
--post-js lib\binding_web\binding.js ^
--post-js lib\binding_web\suffix.js ^
lib\src\lib.c ^
lib\binding_web\binding.c ^
-o target\scratch\tree-sitter.js
copy target\scratch\tree-sitter.js lib\binding_web\tree-sitter.js
copy target\scratch\tree-sitter.wasm lib\binding_web\tree-sitter.wasm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment