Skip to content

Commit

Permalink
chore(util) ensure SDK examples exist before installing them
Browse files Browse the repository at this point in the history
This prevents `./util/test.sh` from failing if `./util/sdk.sh`
is called to install example filters when the respective SDK hasn't
been downloaded, i.e., `tinygo` or `npm` not available.
  • Loading branch information
casimiro authored Jan 30, 2024
1 parent 4366897 commit d206dee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
18 changes: 10 additions & 8 deletions util/sdks/assemblyscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ build_assemblyscript_sdk() {
}

install_assemblyscript_sdk_examples() {
for example in $DIR_PROXY_WASM_ASSEMBLYSCRIPT_SDK/examples/*; do
name=$(basename $example)
name=$(echo $name | sed 's/-/_/g')

pushd $example
cp -av build/debug.wasm $DIR_TESTS_LIB_WASM/assemblyscript_$name.wasm
popd
done
if [[ -d "$DIR_PROXY_WASM_ASSEMBLYSCRIPT_SDK/examples" ]]; then
for example in $DIR_PROXY_WASM_ASSEMBLYSCRIPT_SDK/examples/*; do
name=$(basename $example)
name=$(echo $name | sed 's/-/_/g')

pushd $example
cp -av build/debug.wasm $DIR_TESTS_LIB_WASM/assemblyscript_$name.wasm
popd
done
fi
}

###############################################################################
Expand Down
22 changes: 12 additions & 10 deletions util/sdks/go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,18 @@ EOF
}

install_go_sdk_examples() {
pushd $DIR_PATCHED_PROXY_WASM_GO_SDK
cd examples

find . -name "*.wasm" | while read f; do
# flatten module names, for example:
# "./shared_queue/sender/main.wasm" to "go_shared_queue_sender.wasm"
name=$(echo "$f" | sed 's,./\(.*\)/main.wasm,go_\1.wasm,;s,/,_,g')
cp -av "$f" "$DIR_TESTS_LIB_WASM/$name"
done
popd
if [[ -d "$DIR_PATCHED_PROXY_WASM_GO_SDK" ]]; then
pushd $DIR_PATCHED_PROXY_WASM_GO_SDK
cd examples

find . -name "*.wasm" | while read f; do
# flatten module names, for example:
# "./shared_queue/sender/main.wasm" to "go_shared_queue_sender.wasm"
name=$(echo "$f" | sed 's,./\(.*\)/main.wasm,go_\1.wasm,;s,/,_,g')
cp -av "$f" "$DIR_TESTS_LIB_WASM/$name"
done
popd
fi
}

###############################################################################
Expand Down

0 comments on commit d206dee

Please sign in to comment.