forked from use-ink/ink
-
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.
Script to print sizes of all integration test contracts (use-ink#1851)
* Script to print sizes of all integration test contracts * print only filename of wasm * Process a single contract per script invocation * Rename * Remove extension
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_NAME="${BASH_SOURCE[0]}" | ||
MANIFEST_PATH=$1 | ||
|
||
function usage { | ||
cat << EOF | ||
Usage: ${SCRIPT_NAME} MANIFEST_PATH | ||
Build and print the contract name and size for the given manifest path, if it is a valid ink! contract project. | ||
Use with `find` (see EXAMPLES) to print the contract name and size for all ink! contracts in a directory. | ||
MANIFEST_PATH | ||
Path to the Cargo.toml manifest file for a contract project | ||
EXAMPLES | ||
${SCRIPT_NAME} ./Cargo.toml | ||
find ./integration-tests/ -name "Cargo.toml" -exec ${SCRIPT_NAME} {} \; | ||
EOF | ||
} | ||
|
||
if [ -z "$MANIFEST_PATH" ]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
BUILD_RESULT=$(cargo contract build --manifest-path "$MANIFEST_PATH" --release --quiet --output-json 2>/dev/null) | ||
|
||
if [ $? -eq 0 ]; then | ||
# only print the contract name and size if the build was successful | ||
DEST_WASM=$(echo "$BUILD_RESULT" | jq -r .dest_wasm) | ||
CONTRACT_NAME=$(basename "$DEST_WASM" .wasm) | ||
CONTRACT_SIZE=$(stat -c %s "$DEST_WASM") | ||
|
||
echo "$CONTRACT_NAME" "$CONTRACT_SIZE" | ||
fi |