-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from Lay3rLabs/wasi_setup
Easier WASI setup
- Loading branch information
Showing
6 changed files
with
75 additions
and
2 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
# Compiled files and executables | ||
/target/ | ||
artifacts/ | ||
components/ | ||
internal/ | ||
|
||
# Code coverage | ||
|
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
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,29 @@ | ||
#!/bin/bash | ||
set -o errexit -o nounset -o pipefail | ||
command -v shellcheck >/dev/null && shellcheck "$0" | ||
|
||
# Compiles all WASI components, places the output in components dir | ||
|
||
|
||
OUTDIR="components" | ||
|
||
rm -rf "$OUTDIR" | ||
mkdir -p "$OUTDIR" | ||
|
||
rm -rf target/wasm32-wasip1/release/*.wasm "$OUTDIR" | ||
|
||
BASEDIR=$(pwd) | ||
for C in wasi/*/Cargo.toml; do | ||
DIR=$(dirname "$C") | ||
echo "Building WASI component in $DIR" | ||
( | ||
cd "$DIR"; | ||
cargo component build --release | ||
) | ||
done | ||
|
||
cp target/wasm32-wasip1/release/*.wasm "$OUTDIR" | ||
|
||
ls -l "$OUTDIR" | ||
cd "$OUTDIR" | ||
sha256sum -- *.wasm | tee checksums.txt |
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
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,41 @@ | ||
#!/bin/bash | ||
set -o errexit -o nounset -o pipefail | ||
command -v shellcheck >/dev/null && shellcheck "$0" | ||
|
||
# The minimum Rust version we support | ||
MSRV="1.80.0" | ||
|
||
# install rustup if not present | ||
if ! which rustup > /dev/null; then | ||
echo "Installing Rustup tooling" | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | ||
fi | ||
|
||
# ensure we have a recent-enough version of Rust | ||
V=$(cargo --version | cut -f2 -d' ') | ||
if [[ $V < $MSRV ]]; then | ||
echo "Upgrading Rust to $MSRV" | ||
rustup update stable | ||
fi | ||
|
||
# install the wasm32-wasi target | ||
echo "Adding WASI tooling..." | ||
rustup target add wasm32-wasip1 | ||
cargo install cargo-component | ||
|
||
# setup wkg | ||
if [[ $OSTYPE == 'darwin'* ]]; then | ||
WKG_DIR="$HOME/Library/Application Support/wasm-pkg" | ||
elif [[ $OSTYPE == 'linux'* ]]; then | ||
WKG_DIR="$HOME/.config/wasm-pkg" | ||
else | ||
echo "Unsupported OS: $OSTYPE" | ||
exit 1 | ||
fi | ||
WKG_FILE="$WKG_DIR/config.toml" | ||
|
||
if [ ! -f "$WKG_FILE" ]; then | ||
echo "Creating wkg config file at $WKG_FILE" | ||
mkdir -p "$WKG_DIR" | ||
echo 'default_registry = "wa.dev"' > "$WKG_FILE" | ||
fi |
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