Skip to content

Commit

Permalink
chore(sdk) separate build and install of .wasm examples
Browse files Browse the repository at this point in the history
The behavior of the scripts is still not as ideal as a Make-like
dependency check on the source files and target outputs going
example-by-example, but it is a step in the right direction:

* check that some .wasm files are actually present when deciding
  to skip the build
* always install .wasm files into the target location, even when
  build is skipped
  • Loading branch information
hishamhm authored and thibaultcha committed Dec 5, 2023
1 parent 8f3fa95 commit f955308
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
18 changes: 15 additions & 3 deletions util/sdks/assemblyscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ build_assemblyscript_sdk() {

if [[ -f "$DIR_PROXY_WASM_ASSEMBLYSCRIPT_SDK/.hash" \
&& $(cat "$DIR_PROXY_WASM_ASSEMBLYSCRIPT_SDK/.hash") == $(echo $hash_src)
&& -z "$clean" ]];
&& -z "$clean" ]] && \
find $DIR_PROXY_WASM_ASSEMBLYSCRIPT_SDK -name '*.wasm' | grep -q .
then
notice "AssemblyScript examples already built"
exit
return
fi

echo $hash_src > "$DIR_PROXY_WASM_ASSEMBLYSCRIPT_SDK/.hash"
Expand All @@ -87,7 +88,17 @@ build_assemblyscript_sdk() {
pushd $example
npm install
npm run asbuild
cp build/debug.wasm $DIR_TESTS_LIB_WASM/assemblyscript_$name.wasm
popd
done
}

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
}
Expand All @@ -103,4 +114,5 @@ if [ "$mode" = "download" ]; then

else
build_assemblyscript_sdk "$version" "$clean"
install_assemblyscript_sdk_examples
fi
10 changes: 8 additions & 2 deletions util/sdks/go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ build_go_sdk() {
if [[ -d "$DIR_PATCHED_PROXY_WASM_GO_SDK" \
&& -f "$DIR_PATCHED_PROXY_WASM_GO_SDK/.hash" \
&& $(cat "$DIR_PATCHED_PROXY_WASM_GO_SDK/.hash") == $(echo $hash_src)
&& -z "$clean" ]];
&& -z "$clean" ]] && \
find $DIR_PATCHED_PROXY_WASM_GO_SDK -name '*.wasm' | grep -q .
then
notice "Go examples already built"
exit
return
fi

rm -rf $DIR_PATCHED_PROXY_WASM_GO_SDK
Expand Down Expand Up @@ -105,7 +106,11 @@ EOF
notice "compiling Go examples..."

make build.examples || exit 0
popd
}

install_go_sdk_examples() {
pushd $DIR_PATCHED_PROXY_WASM_GO_SDK
cd examples

find . -name "*.wasm" | while read f; do
Expand All @@ -128,4 +133,5 @@ if [ "$mode" = "download" ]; then

else
build_go_sdk "$version" "$clean"
install_go_sdk_examples
fi

0 comments on commit f955308

Please sign in to comment.