Skip to content

Commit

Permalink
[change] generation script to be a separate shell script
Browse files Browse the repository at this point in the history
Signed-off-by: Asem-Abdelhady <[email protected]>
  • Loading branch information
Asem-Abdelhady committed Jan 22, 2024
1 parent 81bb940 commit 5e7efb7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ result
/test/
/iroha-java/
/lcov.info
**/test-smartcontracts/
32 changes: 32 additions & 0 deletions scripts/generate_wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <source-dir>"
exit 1
fi

# First argument is the source directory
SOURCE_DIR="$1"

TARGET_DIR="test-smartcontracts"

mkdir -p "$TARGET_DIR"

for folder in "$SOURCE_DIR"/**; do
if [ -d "$folder" ] && [ "$(basename "$folder")" != ".cargo" ]; then

folder_name=$(basename "$folder")
target_wasm_file_path="${TARGET_DIR}/${folder_name}.wasm"
# Build the smart contracts
cargo run --bin iroha_wasm_builder_cli -- build "$folder" --optimize --outfile "$target_wasm_file_path"

fi
done

echo "Smart contracts build complete."

# How to run:
# make sure you root from the root directrory if iroha or
# any iroha directory that is not a package in the working space
# run the following command:
# ./path/to/script/generate_wasm.sh /path/to/smart_contracts

0 comments on commit 5e7efb7

Please sign in to comment.