From c76e4c371ba71d2ee3ea96a7b44e37e11dd943d2 Mon Sep 17 00:00:00 2001 From: Deepak Bomjan Date: Thu, 26 Sep 2024 08:40:37 +0545 Subject: [PATCH] ci: remove workspace build --- scripts/optimize-cosmwasm.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/optimize-cosmwasm.sh b/scripts/optimize-cosmwasm.sh index 421eb303..57880d97 100755 --- a/scripts/optimize-cosmwasm.sh +++ b/scripts/optimize-cosmwasm.sh @@ -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 cosmwasm-check@2.1.1 --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