Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for xbuild #212

Merged
merged 11 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
44 changes: 44 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
12 changes: 12 additions & 0 deletions tools/codegen/base/xbuild.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"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}",
"platform": {
notgull marked this conversation as resolved.
Show resolved Hide resolved
"x86_64_linux_gnu": {},
"x86_64_macos": {},
"x86_64_windows": {}
}
}