Skip to content

Commit

Permalink
Merge pull request #16 from wacker-dev/build
Browse files Browse the repository at this point in the history
Use bash script instead of build script to manage wit dependencies
  • Loading branch information
iawia002 authored Jul 19, 2024
2 parents b966465 + 8009bcf commit 4ae2a50
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
with:
targets: wasm32-wasip1
components: clippy, rustfmt
- name: Re-vendor WIT
run: |
./scripts/vendor-wit.sh
git diff --exit-code
- name: cargo fmt
run: cargo fmt --all -- --check
- name: cargo clippy
Expand Down
47 changes: 47 additions & 0 deletions scripts/vendor-wit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

# Script to re-vendor the WIT files.
#
# This script is also executed on CI to ensure that everything is up-to-date.
set -ex

# The make_vendor function takes a base path (e.g., "wasi") and a list
# of packages in the format "name@tag". It constructs the full destination
# path, downloads the tarballs from GitHub, extracts the relevant files, and
# removes any unwanted directories.
make_vendor() {
local packages=$1
local path="waki/wit/deps"

rm -rf $path
mkdir -p $path

for package in $packages; do
IFS='@' read -r repo tag <<< "$package"
mkdir -p $path/$repo
cached_extracted_dir="$cache_dir/$repo-$tag"

if [[ ! -d $cached_extracted_dir ]]; then
mkdir -p $cached_extracted_dir
curl -sL https://github.com/WebAssembly/wasi-$repo/archive/$tag.tar.gz | \
tar xzf - --strip-components=1 -C $cached_extracted_dir
rm -rf $cached_extracted_dir/wit/deps*
fi

cp -r $cached_extracted_dir/wit/* $path/$repo
done
}

cache_dir=$(mktemp -d)

make_vendor "
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
"

rm -rf $cache_dir
4 changes: 0 additions & 4 deletions waki/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ httparse = { version = "1.9.3", optional = true }
json = ["dep:serde_json"]
multipart = ["dep:mime", "dep:mime_guess", "dep:rand", "dep:memchr", "dep:bytes", "dep:httparse"]

[build-dependencies]
anyhow.workspace = true
wit-deps = "0.3.1"

[dev-dependencies]
test-programs-artifacts = { path = "../test-programs/artifacts" }

Expand Down
6 changes: 0 additions & 6 deletions waki/build.rs

This file was deleted.

29 changes: 0 additions & 29 deletions waki/wit/deps.lock

This file was deleted.

1 change: 0 additions & 1 deletion waki/wit/deps.toml

This file was deleted.

0 comments on commit 4ae2a50

Please sign in to comment.