Skip to content

Commit

Permalink
Add support for xbuild (#212)
Browse files Browse the repository at this point in the history
Signed-off-by: John Nunley <dev@notgull.net>
  • Loading branch information
notgull committed Sep 4, 2023
1 parent 01c3792 commit b45f49a
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ syft
udeps
wasmtime
watchexec
xbuild
xscale
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.<br>
Expand Down
28 changes: 17 additions & 11 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail
IFS=$'\n\t'

x() {
rx() {
local cmd="$1"
shift
(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions manifests/xbuild.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions tools/ci/tool-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=(
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions tools/codegen/base/xbuild.json
Original file line number Diff line number Diff line change
@@ -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": {}
}
}
6 changes: 6 additions & 0 deletions tools/codegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b45f49a

Please sign in to comment.