From b45f49a51d78b562b597014ad8a319895578fe59 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Mon, 4 Sep 2023 05:46:18 -0700 Subject: [PATCH] Add support for xbuild (#212) Signed-off-by: John Nunley --- .github/.cspell/project-dictionary.txt | 1 + README.md | 1 + main.sh | 28 ++++++++++++--------- manifests/xbuild.json | 34 ++++++++++++++++++++++++++ tools/ci/tool-list.sh | 19 ++++++++++---- tools/codegen/base/xbuild.json | 13 ++++++++++ tools/codegen/src/main.rs | 6 +++++ 7 files changed, 86 insertions(+), 16 deletions(-) create mode 100644 manifests/xbuild.json create mode 100644 tools/codegen/base/xbuild.json diff --git a/.github/.cspell/project-dictionary.txt b/.github/.cspell/project-dictionary.txt index 1bcfe43c2..efe2887a5 100644 --- a/.github/.cspell/project-dictionary.txt +++ b/.github/.cspell/project-dictionary.txt @@ -22,4 +22,5 @@ syft udeps wasmtime watchexec +xbuild xscale diff --git a/README.md b/README.md index f4b3bbcc4..9bbe0c21c 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ https://spdx.org/licenses | [**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-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 | | [**zola**](https://github.com/getzola/zola) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/getzola/zola/releases) | Linux, macOS, Windows | [MIT](https://github.com/getzola/zola/blob/HEAD/LICENSE) | If `$CARGO_HOME/bin` is not available, Rust-related binaries will be installed to `$HOME/.cargo/bin`.
diff --git a/main.sh b/main.sh index f243f4830..ff2192c43 100755 --- a/main.sh +++ b/main.sh @@ -3,7 +3,7 @@ set -euo pipefail IFS=$'\n\t' -x() { +rx() { local cmd="$1" shift ( @@ -69,7 +69,12 @@ download_and_extract() { fi fi local installed_bin - installed_bin="${bin_dir}/$(basename "${bin_in_archive}")" + + # xbuild's binary name is "x", as opposed to the usual crate name + case "${tool}" in + xbuild) installed_bin="${bin_dir}/x" ;; + *) installed_bin="${bin_dir}/$(basename "${bin_in_archive}")" ;; + esac local tar_args=() case "${url}" in @@ -246,7 +251,7 @@ install_cargo_binstall() { info "installing cargo-binstall" download_from_manifest "cargo-binstall" "latest" info "cargo-binstall installed at $(type -P "cargo-binstall${exe}")" - x cargo binstall -V + rx cargo binstall -V fi } apt_update() { @@ -578,27 +583,28 @@ for tool in "${tools[@]}"; do cargo-*) if type -P cargo &>/dev/null; then case "${tool}" in - cargo-valgrind) x cargo "${tool#cargo-}" --help ;; # cargo-valgrind 2.1.0's --version option just calls cargo's --version option + cargo-valgrind) rx cargo "${tool#cargo-}" --help ;; # cargo-valgrind 2.1.0's --version option just calls cargo's --version option *) - if ! x cargo "${tool#cargo-}" --version; then - x cargo "${tool#cargo-}" --help + if ! rx cargo "${tool#cargo-}" --version; then + rx cargo "${tool#cargo-}" --help fi ;; esac else case "${tool}" in - cargo-valgrind) x "${tool}" "${tool#cargo-}" --help ;; # cargo-valgrind 2.1.0's --version option just calls cargo's --version option + cargo-valgrind) rx "${tool}" "${tool#cargo-}" --help ;; # cargo-valgrind 2.1.0's --version option just calls cargo's --version option *) - if ! x "${tool}" "${tool#cargo-}" --version; then - x "${tool}" "${tool#cargo-}" --help + if ! rx "${tool}" "${tool#cargo-}" --version; then + rx "${tool}" "${tool#cargo-}" --help fi ;; esac fi ;; + xbuild) rx "x" --version ;; *) - if ! x "${tool}" --version; then - x "${tool}" --help + if ! rx "${tool}" --version; then + rx "${tool}" --help fi ;; esac diff --git a/manifests/xbuild.json b/manifests/xbuild.json new file mode 100644 index 000000000..8f27d3323 --- /dev/null +++ b/manifests/xbuild.json @@ -0,0 +1,34 @@ +{ + "rust_crate": "xbuild", + "template": { + "x86_64_linux_gnu": { + "url": "https://github.com/rust-mobile/xbuild/releases/download/v${version}/xbuild-linux-x64", + "bin": "xbuild-linux-x64" + }, + "x86_64_macos": { + "url": "https://github.com/rust-mobile/xbuild/releases/download/v${version}/xbuild-macos-x64", + "bin": "xbuild-macos-x64" + }, + "x86_64_windows": { + "url": "https://github.com/rust-mobile/xbuild/releases/download/v${version}/xbuild-windows-x64.exe", + "bin": "xbuild-windows-x64.exe" + } + }, + "latest": { + "version": "0.2.0" + }, + "0.2": { + "version": "0.2.0" + }, + "0.2.0": { + "x86_64_linux_gnu": { + "checksum": "9c294809ec3cb314b34e9f644b5bbf6ed262c25c1eeb78a3691836a95bc58e0d" + }, + "x86_64_macos": { + "checksum": "e357205fde5262d77b8b1dc1cb066a4f7b4edd0a83b71b3513ae466b08343305" + }, + "x86_64_windows": { + "checksum": "ce503cd64e6449d1c3e3bc2bfb621e9dd3ebfc775e99c97f98c2ab145e533946" + } + } +} diff --git a/tools/ci/tool-list.sh b/tools/ci/tool-list.sh index b4833f3fc..c96ee262c 100755 --- a/tools/ci/tool-list.sh +++ b/tools/ci/tool-list.sh @@ -5,7 +5,11 @@ IFS=$'\n\t' cd "$(dirname "$0")"/../.. # They don't provide prebuilt binaries for musl or old glibc host. +glibc_pre_2_34_incompat=( + xbuild +) glibc_pre_2_31_incompat=( + "${glibc_pre_2_34_incompat[@]}" zola ) glibc_pre_2_27_incompat=( @@ -41,13 +45,18 @@ case "$(uname -s)" in incompat_tools+=("${musl_incompat[@]}") else host_glibc_version=$(grep <<<"${ldd_version}" -E "GLIBC|GNU libc" | sed "s/.* //g") - higher_glibc_version=$(sort <<<"2.31"$'\n'"${host_glibc_version}" -Vu | tail -1) + higher_glibc_version=$(sort <<<"2.34"$'\n'"${host_glibc_version}" -Vu | tail -1) if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then - higher_glibc_version=$(sort <<<"2.27"$'\n'"${host_glibc_version}" -Vu | tail -1) - if [[ "${higher_glibc_version}" == "${host_glibc_version}" ]]; then - incompat_tools+=("${glibc_pre_2_31_incompat[@]}") + higher_glibc_version=$(sort <<<"2.31"$'\n'"${host_glibc_version}" -Vu | tail -1) + if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then + higher_glibc_version=$(sort <<<"2.27"$'\n'"${host_glibc_version}" -Vu | tail -1) + if [[ "${higher_glibc_version}" == "${host_glibc_version}" ]]; then + incompat_tools+=("${glibc_pre_2_31_incompat[@]}") + else + incompat_tools+=("${glibc_pre_2_27_incompat[@]}") + fi else - incompat_tools+=("${glibc_pre_2_27_incompat[@]}") + incompat_tools+=("${glibc_pre_2_34_incompat[@]}") fi fi fi diff --git a/tools/codegen/base/xbuild.json b/tools/codegen/base/xbuild.json new file mode 100644 index 000000000..caec34e83 --- /dev/null +++ b/tools/codegen/base/xbuild.json @@ -0,0 +1,13 @@ +{ + "repository": "https://github.com/rust-mobile/xbuild", + "tag_prefix": "v", + "rust_crate": "${package}", + "asset_name": "${package}-${os_name}-x64${exe}", + "bin": "${package}-${os_name}-x64${exe}", + "version_range": ">= 0.2.0", + "platform": { + "x86_64_linux_gnu": {}, + "x86_64_macos": {}, + "x86_64_windows": {} + } +} diff --git a/tools/codegen/src/main.rs b/tools/codegen/src/main.rs index 8ae6d4e3a..17366d992 100644 --- a/tools/codegen/src/main.rs +++ b/tools/codegen/src/main.rs @@ -178,6 +178,12 @@ fn main() -> Result<()> { continue; } } + + // Specifically skip versions of xbuild with build metadata. + if base_info.rust_crate.as_deref() == Some("xbuild") && !semver_version.build.is_empty() { + continue; + } + let mut download_info = BTreeMap::new(); for (&platform, base_download_info) in &base_info.platform { let asset_names = base_download_info