From 1267a9d718c329be11e4d4f4693a406402064aa6 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 1 Aug 2023 13:07:35 +0900 Subject: [PATCH] infra wasm: update the build script. revise the compile options to optmize the binary size. also remove all compile warnings. size: 552616 -> 446847 --- wasm_build.sh | 18 ++++++------------ wasm_cross.txt | 6 +++--- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/wasm_build.sh b/wasm_build.sh index e77d5ea4..da5146c3 100755 --- a/wasm_build.sh +++ b/wasm_build.sh @@ -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.* diff --git a/wasm_cross.txt b/wasm_cross.txt index 7930335a..6b0c220a 100644 --- a/wasm_cross.txt +++ b/wasm_cross.txt @@ -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'