From 8009bcf3f6146cdcecccc96f5c729edcbcfc2c34 Mon Sep 17 00:00:00 2001 From: Xinzhao Xu Date: Fri, 19 Jul 2024 09:33:00 +0800 Subject: [PATCH] Use bash script instead of build script to manage wit dependencies --- .github/workflows/ci.yml | 4 ++++ scripts/vendor-wit.sh | 47 ++++++++++++++++++++++++++++++++++++++++ waki/Cargo.toml | 4 ---- waki/build.rs | 6 ----- waki/wit/deps.lock | 29 ------------------------- waki/wit/deps.toml | 1 - 6 files changed, 51 insertions(+), 40 deletions(-) create mode 100755 scripts/vendor-wit.sh delete mode 100644 waki/build.rs delete mode 100644 waki/wit/deps.lock delete mode 100644 waki/wit/deps.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 022fa0a..15fd067 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/scripts/vendor-wit.sh b/scripts/vendor-wit.sh new file mode 100755 index 0000000..c86a642 --- /dev/null +++ b/scripts/vendor-wit.sh @@ -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 " + cli@v0.2.0 + clocks@v0.2.0 + filesystem@v0.2.0 + io@v0.2.0 + random@v0.2.0 + sockets@v0.2.0 + http@v0.2.0 +" + +rm -rf $cache_dir diff --git a/waki/Cargo.toml b/waki/Cargo.toml index 5c8a5b6..ab93f50 100644 --- a/waki/Cargo.toml +++ b/waki/Cargo.toml @@ -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" } diff --git a/waki/build.rs b/waki/build.rs deleted file mode 100644 index 4996654..0000000 --- a/waki/build.rs +++ /dev/null @@ -1,6 +0,0 @@ -use anyhow::Result; - -fn main() -> Result<()> { - wit_deps::lock_sync!()?; - Ok(()) -} diff --git a/waki/wit/deps.lock b/waki/wit/deps.lock deleted file mode 100644 index 5bd958b..0000000 --- a/waki/wit/deps.lock +++ /dev/null @@ -1,29 +0,0 @@ -[cli] -sha256 = "285865a31d777181b075f39e92bcfe59c89cd6bacce660be1b9a627646956258" -sha512 = "da2622210a9e3eea82b99f1a5b8a44ce5443d009cb943f7bca0bf9cf4360829b289913d7ee727c011f0f72994ea7dc8e661ebcc0a6b34b587297d80cd9b3f7e8" - -[clocks] -sha256 = "468b4d12892fe926b8eb5d398dbf579d566c93231fa44f415440572c695b7613" -sha512 = "e6b53a07221f1413953c9797c68f08b815fdaebf66419bbc1ea3e8b7dece73731062693634731f311a03957b268cf9cc509c518bd15e513c318aa04a8459b93a" - -[filesystem] -sha256 = "498c465cfd04587db40f970fff2185daa597d074c20b68a8bcbae558f261499b" -sha512 = "ead452f9b7bfb88593a502ec00d76d4228003d51c40fd0408aebc32d35c94673551b00230d730873361567cc209ec218c41fb4e95bad194268592c49e7964347" - -[http] -url = "https://github.com/WebAssembly/wasi-http/archive/v0.2.0.tar.gz" -sha256 = "8f44402bde16c48e28c47dc53eab0b26af5b3b3482a1852cf77673e0880ba1c1" -sha512 = "760695f9a25c25bf75a25b731cb21c3bda9e288e450edda823324ecbc73d5d798bbb5de2edad999566980836f037463ee9e57d61789d04b3f3e381475b1a9a0f" -deps = ["cli", "clocks", "filesystem", "io", "random", "sockets"] - -[io] -sha256 = "7210e5653539a15478f894d4da24cc69d61924cbcba21d2804d69314a88e5a4c" -sha512 = "49184a1b0945a889abd52d25271172ed3dc2db6968fcdddb1bab7ee0081f4a3eeee0977ad2291126a37631c0d86eeea75d822fa8af224c422134500bf9f0f2bb" - -[random] -sha256 = "7371d03c037d924caba2587fb2e7c5773a0d3c5fcecbf7971e0e0ba57973c53d" -sha512 = "964c4e8925a53078e4d94ba907b54f89a0b7e154f46823a505391471466c17f53c8692682e5c85771712acd88b348686173fc07c53a3cfe3d301b8cd8ddd0de4" - -[sockets] -sha256 = "622bd28bbeb43736375dc02bd003fd3a016ff8ee91e14bab488325c6b38bf966" -sha512 = "5a63c1f36de0c4548e1d2297bdbededb28721cbad94ef7825c469eae29d7451c97e00b4c1d6730ee1ec0c4a5aac922961a2795762d4a0c3bb54e30a391a84bae" diff --git a/waki/wit/deps.toml b/waki/wit/deps.toml deleted file mode 100644 index 1b375ee..0000000 --- a/waki/wit/deps.toml +++ /dev/null @@ -1 +0,0 @@ -http = "https://github.com/WebAssembly/wasi-http/archive/v0.2.0.tar.gz"