-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f1fed8
commit c79d0e9
Showing
5 changed files
with
60 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
function run_or_fail { | ||
"$@" | ||
local status=$? | ||
if [ $status -ne 0 ]; then | ||
echo "Command '$*' failed with exit code $status" >&2 | ||
exit $status | ||
fi | ||
} | ||
function run_if_available { | ||
if command -v "$1" >/dev/null 2>&1; then | ||
"$@" | ||
else | ||
echo "$1 is not installed. Please install it to use this feature." >&2 | ||
fi | ||
} | ||
|
||
# Clear out the existing build artifacts as these aren't automatically removed by wasm-pack. | ||
if [ -d ./pkg/ ]; then | ||
rm -rf ./pkg/ | ||
fi | ||
|
||
WASM_BINARY=./target/wasm32-unknown-unknown/release/acvm_simulator.wasm | ||
NODE_WASM=./pkg/nodejs/acvm_simulator_bg.wasm | ||
BROWSER_WASM=./pkg/nodejs/acvm_simulator_bg.wasm | ||
WASM_BINARY=./target/wasm32-unknown-unknown/release/${pname}.wasm | ||
NODE_WASM=./pkg/nodejs/${pname}_bg.wasm | ||
BROWSER_WASM=./pkg/nodejs/${pname}_bg.wasm | ||
|
||
# Build the new wasm package | ||
cargo build --lib --release --target wasm32-unknown-unknown | ||
wasm-bindgen $WASM_BINARY --out-dir ./pkg/nodejs --typescript --target nodejs | ||
wasm-bindgen $WASM_BINARY --out-dir ./pkg/web --typescript --target web | ||
wasm-opt $NODE_WASM -o $NODE_WASM -O | ||
wasm-opt $BROWSER_WASM -o $BROWSER_WASM -O | ||
run_or_fail cargo build --lib --release --target wasm32-unknown-unknown | ||
run_or_fail wasm-bindgen $WASM_BINARY --out-dir ./pkg/nodejs --typescript --target nodejs | ||
run_or_fail wasm-bindgen $WASM_BINARY --out-dir ./pkg/web --typescript --target web | ||
run_if_available wasm-opt $NODE_WASM -o $NODE_WASM -O | ||
run_if_available wasm-opt $BROWSER_WASM -o $BROWSER_WASM -O |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters