Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/ci/vendor-wit.sh
1685 views
1
#!/usr/bin/env bash
2
3
# Script to re-vendor the WIT files that Wasmtime uses as defined by a
4
# particular tag in upstream repositories.
5
#
6
# This script is executed on CI to ensure that everything is up-to-date.
7
set -ex
8
9
# The make_vendor function takes a base path (e.g., "wasi") and a list
10
# of packages in the format "name@tag". It constructs the full destination
11
# path, downloads the tarballs from GitHub, extracts the relevant files, and
12
# removes any unwanted directories.
13
make_vendor() {
14
local name=$1
15
local packages=$2
16
local path="crates/$name/wit/deps"
17
18
rm -rf $path
19
mkdir -p $path
20
21
for package in $packages; do
22
IFS='@' read -r repo tag subdir <<< "$package"
23
mkdir -p "$path/$repo"
24
cached_extracted_dir="$cache_dir/$repo-$tag"
25
26
if [[ ! -d $cached_extracted_dir ]]; then
27
mkdir -p $cached_extracted_dir
28
curl --retry 5 --retry-all-errors -sLO https://github.com/WebAssembly/wasi-$repo/archive/$tag.tar.gz
29
tar xzf $tag.tar.gz --strip-components=1 -C $cached_extracted_dir
30
rm $tag.tar.gz
31
rm -rf $cached_extracted_dir/${subdir:-"wit"}/deps*
32
fi
33
34
cp -r $cached_extracted_dir/${subdir:-"wit"}/* $path/$repo
35
done
36
}
37
38
cache_dir=$(mktemp -d)
39
40
make_vendor "wasi-io" "
41
[email protected]
42
"
43
44
make_vendor "wasi/src/p2" "
45
[email protected]
46
[email protected]
47
[email protected]
48
[email protected]
49
[email protected]
50
[email protected]
51
"
52
53
make_vendor "wasi-http" "
54
[email protected]
55
[email protected]
56
[email protected]
57
[email protected]
58
[email protected]
59
[email protected]
60
[email protected]
61
"
62
63
make_vendor "wasi-tls" "
64
[email protected]
65
[email protected]+505fc98
66
"
67
68
make_vendor "wasi-config" "config@f4d699b"
69
70
make_vendor "wasi-keyvalue" "keyvalue@219ea36"
71
72
make_vendor "wasi/src/p3" "
73
[email protected]@wit-0.3.0-draft
74
[email protected]@wit-0.3.0-draft
75
[email protected]@wit-0.3.0-draft
76
[email protected]@wit-0.3.0-draft
77
[email protected]@wit-0.3.0-draft
78
"
79
80
make_vendor "wasi-http/src/p3" "
81
[email protected]@wit-0.3.0-draft
82
[email protected]@wit-0.3.0-draft
83
[email protected]@wit-0.3.0-draft
84
[email protected]@wit-0.3.0-draft
85
[email protected]@wit-0.3.0-draft
86
[email protected]@wit-0.3.0-draft
87
"
88
89
rm -rf $cache_dir
90
91
# Separately (for now), vendor the `wasi-nn` WIT files since their retrieval is
92
# slightly different than above.
93
repo=https://raw.githubusercontent.com/WebAssembly/wasi-nn
94
revision=0.2.0-rc-2024-10-28
95
curl --retry 5 --retry-all-errors -L $repo/$revision/wasi-nn.witx -o crates/wasi-nn/witx/wasi-nn.witx
96
curl --retry 5 --retry-all-errors -L $repo/$revision/wit/wasi-nn.wit -o crates/wasi-nn/wit/wasi-nn.wit
97
98