Skip to content

Commit 0d0b54a

Browse files
committed
build: specify path to Wasm-to-JavaScript compiler
1 parent 0a75921 commit 0d0b54a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tools/scripts/compile_wasm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
# NODE Command for running Node.js. Default: `node`.
3131
# NODE_PATH Path for resolving node modules.
3232
# EMCCC_COMPILER Emscripten C compiler. Default: `emcc`.
33-
# WASM2WAT Command for converting wasm binary format to text format. Default. `wasm2wat`.
33+
# WASM2WAT Command for converting WebAssembly binary format to text format. Default. `wasm2wat`.
34+
# WASM2JS Command for converting WebAssembly binary format to JavaScript. Default. `wasm2js`.
3435
# SRC_FOLDER Folder containing source files. Default: `src`.
3536
# INCLUDE Includes (e.g., `-I /foo/bar -I /a/b`).
3637
# SOURCE_FILES Source file list.
@@ -67,6 +68,12 @@ if [[ -z "${wasm_to_wat}" ]]; then
6768
wasm_to_wat='wasm2wat'
6869
fi
6970

71+
# Define the path to an executable for converting a WebAssembly binary to JavaScript:
72+
wasm_to_js="${WASM2JS}"
73+
if [[ -z "${wasm_to_js}" ]]; then
74+
wasm_to_js='wasm2js'
75+
fi
76+
7077
# Define the folder containing source files:
7178
src_folder="${SRC_FOLDER}"
7279
if [[ -z "${src_folder}" ]]; then
@@ -194,7 +201,7 @@ resolve_libpaths() {
194201
#
195202
# $1 - source directory
196203
compile() {
197-
cd "$1" && EMCC_COMPILER="${emcc_compiler}" WASM2WAT="${wasm_to_wat}" INCLUDE="${include}" SOURCE_FILES="${source_files}" LIBRARIES="${libraries}" LIBPATH="${libpath}" make wasm 2>&1
204+
cd "$1" && EMCC_COMPILER="${emcc_compiler}" WASM2WAT="${wasm_to_wat}" WASM2JS="${wasm_to_js}" INCLUDE="${include}" SOURCE_FILES="${source_files}" LIBRARIES="${libraries}" LIBPATH="${libpath}" make wasm 2>&1
198205
if [[ "$?" -ne 0 ]]; then
199206
echo 'Error when attempting to compile WebAssembly.' >&2
200207
return 1

0 commit comments

Comments
 (0)