infra wasm: update the build script.

revise the compile options to optmize the binary size.
also remove all compile warnings.

size: 552616 -> 446847
This commit is contained in:
Hermet Park 2023-08-01 13:07:35 +09:00 committed by Hermet Park
parent 3fe6c7126a
commit 1267a9d718
2 changed files with 9 additions and 15 deletions

View file

@ -1,18 +1,12 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Emscripten SDK PATH is not provided"
echo "Usage: wasm_build EMSDK_PATH"
exit 1;
fi
if [ ! -d "./builddir_wasm" ]; then
if [ ! -d "./build_wasm" ]; then
sed "s|EMSDK:|$1|g" wasm_cross.txt > /tmp/.wasm_cross.txt
meson -Db_lto=true -Ddefault_library=static -Dstatic=true -Dloaders="all, lottie_beta" -Dsavers="all" -Dlog=true --cross-file /tmp/.wasm_cross.txt builddir_wasm
cp ./test/wasm/wasm_test.html builddir_wasm/src/index.html
meson -Db_lto=true -Ddefault_library=static -Dstatic=true -Dloaders="all, lottie_beta" -Dsavers="all" -Dlog=true --cross-file /tmp/.wasm_cross.txt build_wasm
cp ./test/wasm/wasm_test.html build_wasm/src/index.html
fi
ninja -C builddir_wasm/
ninja -C build_wasm/
echo "RESULT:"
echo " thorvg-wasm.wasm and thorvg-wasm.js can be found in builddir_wasm/src folder"
ls -lrt builddir_wasm/src/thorvg-wasm.*
echo " thorvg-wasm.wasm and thorvg-wasm.js can be found in build_wasm/src folder"
ls -lrt build_wasm/src/thorvg-wasm.*

View file

@ -10,9 +10,9 @@ static_lib_suffix = 'js'
shared_module_suffix = 'js'
exe_suffix = 'js'
#[built-in options]
cpp_args = ['-Wshift-negative-value', '--bind' , '-s' , 'WASM=1' , '-s' , 'ALLOW_MEMORY_GROWTH=1' , '-s' , 'FORCE_FILESYSTEM=1' , '-flto', '-O2']
cpp_link_args = ['-Wshift-negative-value', '--bind' , '-s' , 'WASM=1' , '-s' , 'ALLOW_MEMORY_GROWTH=1' , '-s' , 'FORCE_FILESYSTEM=1' , '-flto', '-O2']
[built-in options]
cpp_args = ['-Wshift-negative-value', '-flto', '-Os', '-fno-exceptions']
cpp_link_args = ['-Wshift-negative-value', '-flto', '-Os', '-fno-exceptions', '--bind', '-sWASM=1', '-sALLOW_MEMORY_GROWTH=1', '-sFORCE_FILESYSTEM=1']
[host_machine]
system = 'emscripten'