Skip to content

Commit

Permalink
ci: remove workspace build
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepakBomjan committed Sep 26, 2024
1 parent 907b3c2 commit c76e4c3
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions scripts/optimize-cosmwasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit c76e4c3

Please sign in to comment.