-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update
noir_wasm
build process to match acvm_js
- Loading branch information
1 parent
90c5d18
commit 6ad35b7
Showing
6 changed files
with
81 additions
and
27 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/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 | ||
} | ||
|
||
export self_path=$(dirname "$(readlink -f "$0")") | ||
|
||
# Clear out the existing build artifacts as these aren't automatically removed by wasm-pack. | ||
if [ -d ${self_path}/pkg/ ]; then | ||
rm -rf ${self_path}/pkg/ | ||
fi | ||
|
||
# TODO: Handle the wasm target being built in release mode | ||
TARGET=wasm32-unknown-unknown | ||
WASM_BINARY=${self_path}/../../target/${TARGET}/release/${pname}.wasm | ||
|
||
NODE_DIR=${self_path}/pkg/nodejs/ | ||
BROWSER_DIR=${self_path}/pkg/web/ | ||
NODE_WASM=${NODE_DIR}/${pname}_bg.wasm | ||
BROWSER_WASM=${BROWSER_DIR}/${pname}_bg.wasm | ||
|
||
# Build the new wasm package | ||
run_or_fail cargo build --lib --release --package noir_wasm --target wasm32-unknown-unknown | ||
run_or_fail wasm-bindgen $WASM_BINARY --out-dir $NODE_DIR --typescript --target nodejs | ||
run_or_fail wasm-bindgen $WASM_BINARY --out-dir $BROWSER_DIR --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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
#!/usr/bin/env bash | ||
export self_path=$(dirname "$(readlink -f "$0")") | ||
|
||
mkdir -p $out | ||
cp ./crates/wasm/README.md $out/ | ||
cp ./crates/wasm/package.json $out/ | ||
cp -r ./pkg/* $out/ | ||
|
||
cp ${self_path}/README.md ${self_path}/pkg/ | ||
cp ${self_path}/package.json ${self_path}/pkg/ | ||
cp -r ${self_path}/pkg/* $out/ | ||
|
||
echo "## Tracking" >> $out/README.md | ||
echo "Built from [noir-lang/noir@$GIT_COMMIT](https://github.com/noir-lang/noir/tree/$GIT_COMMIT)" >> $out/README.md | ||
|
||
# Cleanup temporary pkg directory | ||
rm -r $self_path/pkg |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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