compile-wasm.sh 1013 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/sh
  2. set -e
  3. dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
  4. pushd $dir > /dev/null
  5. mkdir -p lib/assets/
  6. # Need to use -O2, as -O3 applies the Closure compiler to native function names.
  7. # The entries for exported functions in Module.asm will be scrambled so
  8. # EmscriptenModule._fromJs() is unable to parse them and link them with original
  9. # names set on the module, e.g. Module._spine_get_major_version.
  10. echo "const module = {};" > pre.js
  11. em++ \
  12. -Isrc/spine-cpp/include \
  13. -O2 --closure 1 -fno-rtti -fno-exceptions \
  14. -s STRICT=1 \
  15. -s EXPORTED_RUNTIME_METHODS=wasmExports \
  16. -s ERROR_ON_UNDEFINED_SYMBOLS=1 \
  17. -s MODULARIZE=1 \
  18. -s ALLOW_MEMORY_GROWTH=1 \
  19. -s ALLOW_TABLE_GROWTH \
  20. -s MALLOC=emmalloc \
  21. -s EXPORT_ALL=1 \
  22. -s EXPORTED_FUNCTIONS='["_malloc", "_free"]' \
  23. --no-entry \
  24. --extern-pre-js pre.js \
  25. -s EXPORT_NAME=libspine_flutter \
  26. src/spine-cpp-lite/spine-cpp-lite.cpp `find src/spine-cpp/src -type f` \
  27. -o lib/assets/libspine_flutter.js
  28. ls -lah lib/assets
  29. rm pre.js
  30. popd