Compare commits

..

1 Commits

Author SHA1 Message Date
Taiki Endo
82fc405565 Support cargo-fuzz 2024-03-02 18:29:03 +09:00
9 changed files with 159 additions and 282 deletions

View File

@@ -1,5 +1,4 @@
almalinux
bindgen
binstall
coreutils
distro

View File

@@ -10,12 +10,10 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
## [Unreleased]
## [2.28.0] - 2024-03-02
- Support `wasm-bindgen`. ([#383](https://github.com/taiki-e/install-action/pull/383), thanks @Ekleog)
- Support `sccache`. ([#390](https://github.com/taiki-e/install-action/pull/390))
- Support `cargo-fuzz`. ([#352](https://github.com/taiki-e/install-action/pull/352))
## [2.27.15] - 2024-03-02
- Support `biome` on x86_64/aarch64 Linux (musl).
@@ -1837,8 +1835,7 @@ Note: This release is considered a breaking change because installing on version
Initial release
[Unreleased]: https://github.com/taiki-e/install-action/compare/v2.28.0...HEAD
[2.28.0]: https://github.com/taiki-e/install-action/compare/v2.27.15...v2.28.0
[Unreleased]: https://github.com/taiki-e/install-action/compare/v2.27.15...HEAD
[2.27.15]: https://github.com/taiki-e/install-action/compare/v2.27.14...v2.27.15
[2.27.14]: https://github.com/taiki-e/install-action/compare/v2.27.13...v2.27.14
[2.27.13]: https://github.com/taiki-e/install-action/compare/v2.27.12...v2.27.13

View File

@@ -88,6 +88,7 @@ https://spdx.org/licenses
| [**cargo-deny**](https://github.com/EmbarkStudios/cargo-deny) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/EmbarkStudios/cargo-deny/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/EmbarkStudios/cargo-deny/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/EmbarkStudios/cargo-deny/blob/HEAD/LICENSE-MIT) |
| [**cargo-dinghy**](https://github.com/sonos/dinghy) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/sonos/dinghy/releases) | Linux, macOS | [Apache-2.0](https://github.com/sonos/dinghy/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/sonos/dinghy/blob/HEAD/LICENSE-MIT) |
| [**cargo-export**](https://github.com/bazhenov/cargo-export) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/bazhenov/cargo-export/releases) | Linux, macOS, Windows | [MIT](https://github.com/bazhenov/cargo-export/blob/HEAD/LICENSE) |
| [**cargo-fuzz**](https://github.com/rust-fuzz/cargo-fuzz) | `$CARGO_HOME/bin` | [GitHub Release](https://github.com/rust-fuzz/cargo-fuzz/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/rust-fuzz/cargo-fuzz/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/rust-fuzz/cargo-fuzz/blob/HEAD/LICENSE-MIT) |
| [**cargo-hack**](https://github.com/taiki-e/cargo-hack) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/taiki-e/cargo-hack/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/taiki-e/cargo-hack/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/taiki-e/cargo-hack/blob/HEAD/LICENSE-MIT) |
| [**cargo-llvm-cov**](https://github.com/taiki-e/cargo-llvm-cov) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/taiki-e/cargo-llvm-cov/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/taiki-e/cargo-llvm-cov/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/taiki-e/cargo-llvm-cov/blob/HEAD/LICENSE-MIT) |
| [**cargo-machete**](https://github.com/bnjbvr/cargo-machete) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/bnjbvr/cargo-machete/releases) | Linux, macOS, Windows | [MIT](https://github.com/bnjbvr/cargo-machete/blob/HEAD/LICENSE.md) |
@@ -114,7 +115,6 @@ https://spdx.org/licenses
| [**shfmt**](https://github.com/mvdan/sh) | `/usr/local/bin` | [GitHub Releases](https://github.com/mvdan/sh/releases) | Linux, macOS, Windows | [BSD-3-Clause](https://github.com/mvdan/sh/blob/HEAD/LICENSE) |
| [**syft**](https://github.com/anchore/syft) | `/usr/local/bin` | [Github Releases](https://github.com/anchore/syft/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/anchore/syft/blob/HEAD/LICENSE) |
| [**valgrind**](https://valgrind.org) | `/snap/bin` | [snap](https://snapcraft.io/install/valgrind/ubuntu) | Linux | [GPL-2.0-or-later](https://valgrind.org/docs/manual/license.gpl.html) |
| [**wasm-bindgen**](https://github.com/rustwasm/wasm-bindgen) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/rustwasm/wasm-bindgen/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/rustwasm/wasm-bindgen/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/rustwasm/wasm-bindgen/blob/HEAD/LICENSE-MIT) |
| [**wasm-pack**](https://github.com/rustwasm/wasm-pack) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/rustwasm/wasm-pack/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/rustwasm/wasm-pack/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/rustwasm/wasm-pack/blob/HEAD/LICENSE-MIT) |
| [**wasmtime**](https://github.com/bytecodealliance/wasmtime) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/bytecodealliance/wasmtime/releases) | Linux, macOS, Windows | [Apache-2.0 WITH LLVM-exception](https://github.com/bytecodealliance/wasmtime/blob/HEAD/LICENSE) |
| [**xbuild**](https://github.com/rust-mobile/xbuild) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/rust-mobile/xbuild/releases) | Linux, macOS, Windows | Apache-2.0 OR MIT |

157
main.sh
View File

@@ -54,26 +54,18 @@ download_and_checksum() {
}
download_and_extract() {
local url="$1"
shift
local checksum="$1"
shift
local bin_dir="$1"
shift
local bin_in_archive=("$@") # path to bin in archive
local checksum="$2"
local bin_dir="$3"
local bin_in_archive="$4" # path to bin in archive
if [[ "${bin_dir}" == "${install_action_dir}/bin" ]]; then
init_install_action_bin_dir
fi
installed_bin=()
local tmp
local installed_bin
# xbuild's binary name is "x", as opposed to the usual crate name
case "${tool}" in
# xbuild's binary name is "x", as opposed to the usual crate name
xbuild) installed_bin=("${bin_dir}/x") ;;
*)
for tmp in "${bin_in_archive[@]}"; do
installed_bin+=("${bin_dir}/$(basename "${tmp}")")
done
;;
xbuild) installed_bin="${bin_dir}/x" ;;
*) installed_bin="${bin_dir}/$(basename "${bin_in_archive}")" ;;
esac
local tar_args=()
@@ -127,23 +119,19 @@ download_and_extract() {
download_and_checksum "${url}" "${checksum}"
if [[ ${#tar_args[@]} -gt 0 ]]; then
tar_args+=("tmp")
tar "${tar_args[@]}"
for tmp in "${bin_in_archive[@]}"; do
mv "${tmp}" "${bin_dir}/"
done
local components
components=$(tr <<<"${bin_in_archive}" -cd '/' | wc -c)
if [[ "${components}" != "0" ]]; then
tar_args+=(--strip-components "${components}")
fi
tar "${tar_args[@]}" -C "${bin_dir}" "${bin_in_archive}"
else
case "${url}" in
*.zip)
unzip -q tmp "${bin_in_archive#\./}"
for tmp in "${bin_in_archive[@]}"; do
mv "${tmp}" "${bin_dir}/"
done
;;
*)
for tmp in "${installed_bin[@]}"; do
mv tmp "${tmp}"
done
mv "${bin_in_archive}" "${bin_dir}/"
;;
*) mv tmp "${installed_bin}" ;;
esac
fi
)
@@ -151,11 +139,9 @@ download_and_extract() {
case "${host_os}" in
linux | macos)
for tmp in "${installed_bin[@]}"; do
if [[ ! -x "${tmp}" ]]; then
chmod +x "${tmp}"
fi
done
if [[ ! -x "${installed_bin}" ]]; then
chmod +x "${installed_bin}"
fi
;;
esac
}
@@ -212,31 +198,15 @@ read_download_info() {
fi
checksum=$(call_jq <<<"${download_info}" -r '.checksum')
url=$(call_jq <<<"${download_info}" -r '.url')
local tmp
bin_in_archive=()
if [[ "${url}" == "null" ]]; then
local template
template=$(call_jq -r ".template.${host_platform}" "${manifest_dir}/${tool}.json")
url=$(call_jq <<<"${template}" -r '.url')
url="${url//\$\{version\}/${exact_version}}"
tmp=$(call_jq <<<"${template}" -r '.bin' | sed -E "s/\\$\\{version\\}/${exact_version}/g")
if [[ "${tmp}" == *"["* ]]; then
# shellcheck disable=SC2207
bin_in_archive=($(call_jq <<<"${template}" -r '.bin[]' | sed -E "s/\\$\\{version\\}/${exact_version}/g"))
fi
bin_in_archive=$(call_jq <<<"${template}" -r '.bin')
bin_in_archive="${bin_in_archive//\$\{version\}/${exact_version}}"
else
tmp=$(call_jq <<<"${download_info}" -r '.bin')
if [[ "${tmp}" == *"["* ]]; then
# shellcheck disable=SC2207
bin_in_archive=($(call_jq <<<"${download_info}" -r '.bin[]'))
fi
fi
if [[ ${#bin_in_archive[@]} -eq 0 ]]; then
if [[ "${tmp}" == "null" ]]; then
bin_in_archive=("${tool}${exe}")
else
bin_in_archive=("${tmp}")
fi
bin_in_archive=$(call_jq <<<"${download_info}" -r '.bin')
fi
if [[ "${rust_crate}" == "null" ]]; then
if [[ "${host_os}" == "windows" ]] || [[ ! -e /usr/local/bin ]]; then
@@ -247,6 +217,9 @@ read_download_info() {
else
bin_dir="${cargo_bin}"
fi
if [[ "${bin_in_archive}" == "null" ]]; then
bin_in_archive="${tool}${exe}"
fi
}
download_from_manifest() {
read_manifest "$@"
@@ -254,7 +227,7 @@ download_from_manifest() {
}
download_from_download_info() {
read_download_info "$@"
download_and_extract "${url}" "${checksum}" "${bin_dir}" "${bin_in_archive[@]}"
download_and_extract "${url}" "${checksum}" "${bin_dir}" "${bin_in_archive}"
}
install_cargo_binstall() {
local binstall_version
@@ -567,7 +540,6 @@ for tool in "${tools[@]}"; do
else
version="latest"
fi
installed_bin=()
case "${tool}" in
protoc)
info "installing ${tool}@${version}"
@@ -604,7 +576,6 @@ for tool in "${tools[@]}"; do
fi
)
rm -rf "${tmp_dir}"
installed_bin=("${tool}${exe}")
;;
valgrind)
info "installing ${tool}@${version}"
@@ -622,7 +593,6 @@ for tool in "${tools[@]}"; do
# Use snap to install the latest Valgrind
# https://snapcraft.io/install/valgrind/ubuntu
snap_install valgrind --classic
installed_bin=("${tool}${exe}")
;;
cargo-binstall)
case "${version}" in
@@ -681,50 +651,41 @@ for tool in "${tools[@]}"; do
;;
esac
tool_bin_stems=()
for tool_bin in "${installed_bin[@]}"; do
tool_bin=$(basename "${tool_bin}")
tool_bin_stem="${tool_bin%.exe}"
case "${tool}" in
xbuild) tool_bin="x" ;;
*) tool_bin="${tool}" ;;
esac
installed_at=$(type -P "${tool_bin}${exe}" || echo "")
if [[ -n "${installed_at}" ]]; then
tool_bin="${tool_bin}${exe}"
else
installed_at=$(type -P "${tool_bin}" || echo "")
if [[ -z "${installed_at}" ]]; then
tool_bin="${tool_bin_stem}"
installed_at=$(type -P "${tool_bin}" || echo "")
fi
if [[ -n "${installed_at}" ]]; then
info "${tool_bin_stem} installed at ${installed_at}"
else
warn "${tool_bin_stem} should be installed at ${bin_dir:+"${bin_dir}/"}${tool_bin}${exe}; but ${tool_bin}${exe} not found in path"
fi
tool_bin_stems+=("${tool_bin_stem}")
done
for tool_bin_stem in "${tool_bin_stems[@]}"; do
# cargo-udeps 0.1.30 and wasm-pack 0.12.0 do not support --version flag.
case "${tool_bin_stem}" in
# biome up to 1.2.2 exits with 1 on both --version and --help flags.
# cargo-machete up to 0.6.0 does not support --version flag.
biome | cargo-machete) rx "${tool_bin_stem}" --version || true ;;
# these packages support neither --version nor --help flag.
cargo-careful | wasm-bindgen-test-runner) ;;
# wasm2es6js does not support --version flag and --help flag doesn't contains version info.
wasm2es6js) ;;
cargo-*)
case "${tool_bin_stem}" in
# cargo-valgrind 2.1.0's --version flag just calls cargo's --version flag
cargo-valgrind) rx "${tool_bin_stem}" "${tool_bin_stem#cargo-}" --help ;;
*)
if ! rx "${tool_bin_stem}" "${tool_bin_stem#cargo-}" --version; then
rx "${tool_bin_stem}" "${tool_bin_stem#cargo-}" --help
fi
;;
esac
;;
*)
if ! rx "${tool_bin_stem}" --version; then
rx "${tool_bin_stem}" --help
fi
;;
esac
done
fi
if [[ -n "${installed_at}" ]]; then
info "${tool} installed at ${installed_at}"
else
warn "${tool} should be installed at ${bin_dir:+"${bin_dir}/"}${tool_bin}${exe}; but ${tool_bin}${exe} not found in path"
fi
# cargo-udeps 0.1.30 and wasm-pack 0.12.0 do not support --version option.
case "${tool}" in
biome) rx "${tool_bin}" --version || true ;; # biome up to 1.2.2 exits with 1 on --version and --help
cargo-careful | cargo-machete) ;; # cargo-careful 0.3.4 and cargo-machete 0.5.0 do not support neither --version nor --help option.
cargo-*)
case "${tool}" in
cargo-valgrind) rx "${tool_bin}" "${tool#cargo-}" --help ;; # cargo-valgrind 2.1.0's --version option just calls cargo's --version option
*)
if ! rx "${tool_bin}" "${tool#cargo-}" --version; then
rx "${tool_bin}" "${tool#cargo-}" --help
fi
;;
esac
;;
*)
if ! rx "${tool_bin}" --version; then
rx "${tool_bin}" --help
fi
;;
esac
echo
done

64
manifests/cargo-fuzz.json generated Normal file
View File

@@ -0,0 +1,64 @@
{
"rust_crate": "cargo-fuzz",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/rust-fuzz/cargo-fuzz/releases/download/${version}/cargo-fuzz-${version}-x86_64-unknown-linux-musl.tar.gz"
},
"x86_64_macos": {
"url": "https://github.com/rust-fuzz/cargo-fuzz/releases/download/${version}/cargo-fuzz-${version}-x86_64-apple-darwin.tar.gz"
},
"x86_64_windows": {
"url": "https://github.com/rust-fuzz/cargo-fuzz/releases/download/${version}/cargo-fuzz-${version}-x86_64-pc-windows-msvc.zip"
}
},
"latest": {
"version": "0.11.2"
},
"0.12.0": {
"x86_64_linux_musl": {
"checksum": "e5f38ce96c36e05c43b76fc00bf22537c944edc71e0f0e869ca18a6ab40e8efa"
},
"x86_64_macos": {
"checksum": "f28dece7bceefe9069632b677111f157b5c62c7b006c665d191bf562d9b56f8e"
},
"x86_64_windows": {
"checksum": "70ddcf1d31a40b8563e501d15ec676b9e81d7bad9e346a19afe8bb45286a0a52"
}
},
"0.11": {
"version": "0.11.2"
},
"0.11.4": {
"x86_64_linux_musl": {
"checksum": "c185905364d5cd32a3e6e32ef10d5f22ae999df13d569041465762ea05245cfb"
},
"x86_64_macos": {
"checksum": "0cf9c6d7a8b3de49eb8a518951aa8a7ad0733244294d075af5bc6486ac5bb2f2"
},
"x86_64_windows": {
"checksum": "0826605d7dd15433e2c779053b04588759ce648b4843efe6c29c466001af62d4"
}
},
"0.11.3": {
"x86_64_linux_musl": {
"checksum": "b1fce2bad4352e6d0a2271b091715a31099830ee351792f70a7f19fb3a171d1a"
},
"x86_64_macos": {
"checksum": "29d2609b2ab24385b729befeccd015501eb6bd6331c88e2026f19894d33364b2"
},
"x86_64_windows": {
"checksum": "6d34045c3d3ac31f5454b5745985544c5fbfb4d4e3231a4a5be17c94e3b12e86"
}
},
"0.11.2": {
"x86_64_linux_musl": {
"checksum": "0f5b5bce0b9ee8ed9dcf3f4699038c5178db9f536df7909a7e1cae8039f5626b"
},
"x86_64_macos": {
"checksum": "70f0cba45bd015eefe2e6e4b07d5a9e4b3e9eb90e637a2773c7a30ec1792602f"
},
"x86_64_windows": {
"checksum": "1867b415541f81265189daeed13d1cab16186641d9cb3c447b2a86c7ea002309"
}
}
}

View File

@@ -1,119 +0,0 @@
{
"rust_crate": "wasm-bindgen-cli",
"template": {
"x86_64_linux_musl": {
"url": "https://github.com/rustwasm/wasm-bindgen/releases/download/${version}/wasm-bindgen-${version}-x86_64-unknown-linux-musl.tar.gz",
"bin": [
"wasm-bindgen-${version}-x86_64-unknown-linux-musl/wasm-bindgen-test-runner",
"wasm-bindgen-${version}-x86_64-unknown-linux-musl/wasm-bindgen",
"wasm-bindgen-${version}-x86_64-unknown-linux-musl/wasm2es6js"
]
},
"x86_64_macos": {
"url": "https://github.com/rustwasm/wasm-bindgen/releases/download/${version}/wasm-bindgen-${version}-x86_64-apple-darwin.tar.gz",
"bin": [
"wasm-bindgen-${version}-x86_64-apple-darwin/wasm-bindgen-test-runner",
"wasm-bindgen-${version}-x86_64-apple-darwin/wasm-bindgen",
"wasm-bindgen-${version}-x86_64-apple-darwin/wasm2es6js"
]
},
"x86_64_windows": {
"url": "https://github.com/rustwasm/wasm-bindgen/releases/download/${version}/wasm-bindgen-${version}-x86_64-pc-windows-msvc.tar.gz",
"bin": [
"wasm-bindgen-${version}-x86_64-pc-windows-msvc/wasm-bindgen-test-runner.exe",
"wasm-bindgen-${version}-x86_64-pc-windows-msvc/wasm-bindgen.exe",
"wasm-bindgen-${version}-x86_64-pc-windows-msvc/wasm2es6js.exe"
]
},
"aarch64_linux_gnu": {
"url": "https://github.com/rustwasm/wasm-bindgen/releases/download/${version}/wasm-bindgen-${version}-aarch64-unknown-linux-gnu.tar.gz",
"bin": [
"wasm-bindgen-${version}-aarch64-unknown-linux-gnu/wasm-bindgen-test-runner",
"wasm-bindgen-${version}-aarch64-unknown-linux-gnu/wasm-bindgen",
"wasm-bindgen-${version}-aarch64-unknown-linux-gnu/wasm2es6js"
]
},
"aarch64_macos": {
"url": "https://github.com/rustwasm/wasm-bindgen/releases/download/${version}/wasm-bindgen-${version}-aarch64-apple-darwin.tar.gz",
"bin": [
"wasm-bindgen-${version}-aarch64-apple-darwin/wasm-bindgen-test-runner",
"wasm-bindgen-${version}-aarch64-apple-darwin/wasm-bindgen",
"wasm-bindgen-${version}-aarch64-apple-darwin/wasm2es6js"
]
}
},
"latest": {
"version": "0.2.91"
},
"0.2": {
"version": "0.2.91"
},
"0.2.91": {
"x86_64_linux_musl": {
"checksum": "48123760cd139036125dbc07aaf09c73237d2bf910810b00a2dabbbac7a92e4e"
},
"x86_64_macos": {
"checksum": "8c9378515f5162d77c8bbec8925e2444e4509fc5fd4e42c218b70bd7e7b5c34d"
},
"x86_64_windows": {
"checksum": "9077f846f8e29dbc246688294b02474c4247e176739b43b0ce5df093e3c23ccf"
},
"aarch64_linux_gnu": {
"checksum": "06a93a6c4ca7166082e8c6179e9f1dc6ca1df822894669b5257cdff08692bf00"
},
"aarch64_macos": {
"checksum": "8f644617cbd12763268854cb550604f18e15a869c9b2e63ba977278fee99ff3d"
}
},
"0.2.90": {
"x86_64_linux_musl": {
"checksum": "46131161e31617d102260b1420159fe5006f6b0fdb8a0a90fe7adc858b662132"
},
"x86_64_macos": {
"checksum": "374a460a4c8cf097e84725082da6c909830cbc6caa16538735bcc066971e3bcd"
},
"x86_64_windows": {
"checksum": "919b6f010164c5d2f28df505098d94c0ac3727c9aeeea2df12453008dc451c78"
},
"aarch64_linux_gnu": {
"checksum": "29075a17870097d800e471ec2a800f915c09c5c8d4b2b1436fd43381aa7bf480"
},
"aarch64_macos": {
"checksum": "d3724348014d028048b9539fac36858a0a1aba165814a69542d3038d65303093"
}
},
"0.2.89": {
"x86_64_linux_musl": {
"checksum": "e6361f3069a8a94ca44f0eb6e22b1de59ee71236bba2acd0278f1387e09a90d0"
},
"x86_64_macos": {
"checksum": "5ca6b6e9a2b971cdc5571a54a963f6f13ae6263bbf921998feeef3ff6b6b70b7"
},
"x86_64_windows": {
"checksum": "5dd04e972fc0910122f5d9881aa49470e6734e5a1d3294030eaace738771fddc"
},
"aarch64_linux_gnu": {
"checksum": "4ca6d7cedf6d47eec55d739bfd228270061a1c2bb4b625442e2bb716d2cc7337"
},
"aarch64_macos": {
"checksum": "cff8b011832e0f17fc94e4673a2910b04cb11bd527736b96f94abea24ff674be"
}
},
"0.2.88": {
"x86_64_linux_musl": {
"checksum": "d7dcb7f5ad1d0cb68df5d45ffd9119d1db3d42ee6d50a8b2d3c42a56c74bdd8e"
},
"x86_64_macos": {
"checksum": "0d1913322e657444c942c644abb687e46807fec31e3efbafb199a7932e677dcc"
},
"x86_64_windows": {
"checksum": "ed885be56d41c5c1d3b1495307d57a2d48b296cfe5afe92e06b6ea09c4ba4532"
},
"aarch64_linux_gnu": {
"checksum": "f13bb83170a3d44edfbebd263c695e6fb5815d77467490af1c49e2e8ec816803"
},
"aarch64_macos": {
"checksum": "712c787c411a765e5bf8f2f3f11db9d5ec823260b763e1017d6790e9b3c225ff"
}
}
}

View File

@@ -0,0 +1,14 @@
{
"repository": "https://github.com/rust-fuzz/cargo-fuzz",
"tag_prefix": "",
"rust_crate": "${package}",
"broken": ["0.11.3", "0.11.4", "0.12.0"],
"asset_name": "${package}-${version}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_musl": {},
"x86_64_macos": {},
"x86_64_windows": {
"asset_name": "${package}-${version}-${rust_target}.zip"
}
}
}

View File

@@ -1,19 +0,0 @@
{
"repository": "https://github.com/rustwasm/wasm-bindgen",
"tag_prefix": "",
"rust_crate": "wasm-bindgen-cli",
"version_range": ">= 0.2.88",
"asset_name": "wasm-bindgen-${version}-${rust_target}.tar.gz",
"bin": [
"wasm-bindgen-${version}-${rust_target}/wasm-bindgen-test-runner${exe}",
"wasm-bindgen-${version}-${rust_target}/wasm-bindgen${exe}",
"wasm-bindgen-${version}-${rust_target}/wasm2es6js${exe}"
],
"platform": {
"x86_64_linux_musl": {},
"x86_64_macos": {},
"x86_64_windows": {},
"aarch64_linux_gnu": {},
"aarch64_macos": {}
}
}

View File

@@ -41,7 +41,6 @@ fn main() -> Result<()> {
let mut base_info: BaseManifest = serde_json::from_slice(&fs::read(
workspace_root.join("tools/codegen/base").join(format!("{package}.json")),
)?)?;
base_info.validate();
let repo = base_info
.repository
.strip_prefix("https://github.com/")
@@ -117,10 +116,7 @@ fn main() -> Result<()> {
for (platform, d) in &mut manifest.download_info {
let template = &template.download_info[platform];
d.url = Some(template.url.replace("${version}", version));
d.bin = template
.bin
.as_ref()
.map(|s| s.map(|s| s.replace("${version}", version)));
d.bin = template.bin.as_ref().map(|s| s.replace("${version}", version));
}
}
}
@@ -314,8 +310,11 @@ fn main() -> Result<()> {
download_info.insert(platform, ManifestDownloadInfo {
url: Some(url),
checksum: hash,
bin: base_download_info.bin.as_ref().or(base_info.bin.as_ref()).map(|s| {
s.map(|s| {
bin: base_download_info
.bin
.as_ref()
.or(base_info.bin.as_ref())
.map(|s| {
replace_vars(
s,
package,
@@ -323,9 +322,8 @@ fn main() -> Result<()> {
Some(platform),
base_info.rust_crate.as_deref(),
)
.unwrap()
})
}),
.transpose()?,
});
buf.clear();
}
@@ -453,7 +451,7 @@ fn main() -> Result<()> {
let t = template.as_mut().unwrap();
for (platform, d) in &mut manifest.download_info {
let template_url = d.url.take().unwrap().replace(version, "${version}");
let template_bin = d.bin.take().map(|s| s.map(|s| s.replace(version, "${version}")));
let template_bin = d.bin.take().map(|s| s.replace(version, "${version}"));
if let Some(d) = t.download_info.get(platform) {
if template_url != d.url || template_bin != d.bin {
template = None;
@@ -713,9 +711,9 @@ struct ManifestDownloadInfo {
#[serde(skip_serializing_if = "Option::is_none")]
url: Option<String>,
checksum: String,
/// Path to binaries in archive. Default to `${tool}${exe}`.
/// Default to ${tool}${exe}
#[serde(skip_serializing_if = "Option::is_none")]
bin: Option<StringOrArray>,
bin: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -727,9 +725,9 @@ struct ManifestTemplate {
#[derive(Debug, Clone, Serialize, Deserialize)]
struct ManifestTemplateDownloadInfo {
url: String,
/// Path to binaries in archive. Default to `${tool}${exe}`.
/// Default to ${tool}${exe}
#[serde(skip_serializing_if = "Option::is_none")]
bin: Option<StringOrArray>,
bin: Option<String>,
}
#[derive(Debug, Deserialize)]
@@ -744,26 +742,14 @@ struct BaseManifest {
default_major_version: Option<String>,
/// Asset name patterns.
asset_name: Option<StringOrArray>,
/// Path to binaries in archive. Default to `${tool}${exe}`.
bin: Option<StringOrArray>,
/// Path to binary in archive. Default to `${tool}${exe}`.
bin: Option<String>,
signing: Option<Signing>,
#[serde(default)]
broken: Vec<semver::Version>,
platform: BTreeMap<HostPlatform, BaseManifestPlatformInfo>,
version_range: Option<String>,
}
impl BaseManifest {
fn validate(&self) {
if let Some(bin) = &self.bin {
assert!(!bin.as_slice().is_empty());
}
for m in self.platform.values() {
if let Some(bin) = &m.bin {
assert!(!bin.as_slice().is_empty());
}
}
}
}
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
@@ -786,11 +772,11 @@ enum SigningKind {
struct BaseManifestPlatformInfo {
/// Asset name patterns. Default to the value at `BaseManifest::asset_name`.
asset_name: Option<StringOrArray>,
/// Path to binaries in archive. Default to the value at `BaseManifest::bin`.
bin: Option<StringOrArray>,
/// Path to binary in archive. Default to the value at `BaseManifest::bin`.
bin: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Deserialize)]
#[serde(untagged)]
enum StringOrArray {
String(String),
@@ -800,14 +786,8 @@ enum StringOrArray {
impl StringOrArray {
fn as_slice(&self) -> &[String] {
match self {
Self::String(s) => slice::from_ref(s),
Self::Array(v) => v,
}
}
fn map(&self, mut f: impl FnMut(&String) -> String) -> Self {
match self {
Self::String(s) => Self::String(f(s)),
Self::Array(v) => Self::Array(v.iter().map(f).collect()),
Self::String(s) => slice::from_ref(s),
}
}
}