-
Notifications
You must be signed in to change notification settings - Fork 9
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
907b3c2
commit c76e4c3
Showing
1 changed file
with
12 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ RUSTC_VERS="1.78.0" | |
MAX_WASM_SIZE=800 # 800 KB | ||
|
||
PROJECTS=("cw-xcall" "cw-xcall-lib") | ||
|
||
WORK_DIR="$PWD" | ||
# Install wasm-opt binary | ||
if ! which wasm-opt; then | ||
curl -OL $BINARYEN_DWN | ||
|
@@ -28,6 +28,7 @@ if [ "$CUR_RUSTC_VERS" != "$RUSTC_VERS" ] || [ "$CUR_WASMOPT_VERS" != "$WASMOPT_ | |
fi | ||
|
||
mkdir -p artifacts/archway | ||
cd contracts/cosmwasm-vm | ||
cargo clippy --fix --allow-dirty | ||
cargo fmt --all | ||
cargo clean | ||
|
@@ -36,20 +37,22 @@ rustup target add wasm32-unknown-unknown | |
cargo install [email protected] --locked | ||
|
||
|
||
RUSTFLAGS='-C link-arg=-s' cargo build --workspace --exclude contracts/soroban/contracts --exclude contracts/soroban/libs --exclude test-utils --release --lib --target wasm32-unknown-unknown | ||
RUSTFLAGS='-C link-arg=-s' cargo build --exclude test-utils --release --lib --target wasm32-unknown-unknown | ||
for WASM in ./target/wasm32-unknown-unknown/release/*.wasm; do | ||
NAME=$(basename "$WASM" .wasm)${SUFFIX}.wasm | ||
echo "Creating intermediate hash for $NAME ..." | ||
sha256sum -- "$WASM" | tee -a artifacts/archway/checksums_intermediate.txt | ||
sha256sum -- "$WASM" | tee -a ${WORK_DIR}/artifacts/archway/checksums_intermediate.txt | ||
echo "Optimizing $NAME ..." | ||
wasm-opt -Os --signext-lowering "$WASM" -o "artifacts/archway/$NAME" | ||
wasm-opt -Os --signext-lowering "$WASM" -o "${WORK_DIR}/artifacts/archway/$NAME" | ||
done | ||
|
||
## Go to project root | ||
cd - | ||
# check all generated wasm files | ||
|
||
cosmwasm-check artifacts/archway/cw_mock_dapp.wasm | ||
cosmwasm-check artifacts/archway/cw_mock_dapp_multi.wasm | ||
cosmwasm-check artifacts/archway/cw_xcall.wasm | ||
cosmwasm-check ${WORK_DIR}/artifacts/archway/cw_mock_dapp.wasm | ||
cosmwasm-check ${WORK_DIR}/artifacts/archway/cw_mock_dapp_multi.wasm | ||
cosmwasm-check ${WORK_DIR}/artifacts/archway/cw_xcall.wasm | ||
|
||
|
||
# Update version | ||
|
@@ -62,7 +65,7 @@ get_version() { | |
rename_wasm_with_version() { | ||
local project_path="$1" | ||
local version=$(get_version "$project_path") | ||
local wasm_file="artifacts/archway/${project_path//-/_}.wasm" | ||
local wasm_file="${WORK_DIR}/artifacts/archway/${project_path//-/_}.wasm" | ||
|
||
if [[ -f "$wasm_file" ]]; then | ||
cp "$wasm_file" "${wasm_file%.wasm}_latest.wasm" | ||
|
@@ -81,7 +84,7 @@ done | |
|
||
# validate size | ||
echo "Check if size of wasm file exceeds $MAX_WASM_SIZE kilobytes..." | ||
for file in artifacts/archway/*.wasm | ||
for file in ${WORK_DIR}/artifacts/archway/*.wasm | ||
do | ||
size=$(du -k "$file" | awk '{print $1}') | ||
if [ $size -gt $MAX_WASM_SIZE ]; then | ||
|