-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
345 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
function retry { | ||
local tries="${TRIES-5}" | ||
local timeout="${TIMEOUT-1}" | ||
local try=0 | ||
local exit_code=0 | ||
|
||
while (( try < tries )); do | ||
if "${@}"; then | ||
return 0 | ||
else | ||
exit_code=$? | ||
fi | ||
|
||
sleep "${timeout}" | ||
echo "Retrying ..." 1>&2 | ||
try=$(( try + 1 )) | ||
timeout=$(( timeout * 2 )) | ||
done | ||
|
||
return ${exit_code} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck disable=SC2086,SC1091,SC1090 | ||
|
||
set -x | ||
set -euo pipefail | ||
|
||
# NOTE: "${@}" is an unbound variable for bash 3.2, which is the | ||
# installed version on macOS. likewise, "${var[@]}" is an unbound | ||
# error if var is an empty array. | ||
|
||
ci_dir=$(dirname "${BASH_SOURCE[0]}") | ||
ci_dir=$(realpath "${ci_dir}") | ||
project_home=$(dirname "${ci_dir}") | ||
. "${ci_dir}"/shared.sh | ||
|
||
# zig cc is very slow: only use a few targets. | ||
TARGETS=( | ||
"aarch64-unknown-linux-gnu" | ||
"aarch64-unknown-linux-musl" | ||
"i586-unknown-linux-gnu" | ||
"i586-unknown-linux-musl" | ||
) | ||
|
||
main() { | ||
export CROSS_BUILD_ZIG=1 | ||
|
||
local td= | ||
local target= | ||
|
||
retry cargo fetch | ||
cargo build | ||
export CROSS="${project_home}/target/debug/cross" | ||
|
||
td="$(mktemp -d)" | ||
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}" | ||
pushd "${td}" | ||
|
||
for target in "${TARGETS[@]}"; do | ||
"${CROSS}" build --target "${target}" | ||
# note: ensure #724 doesn't replicate during CI. | ||
cargo clean | ||
done | ||
|
||
popd | ||
rm -rf "${td}" | ||
} | ||
|
||
main "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM ubuntu:20.04 | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
COPY common.sh lib.sh / | ||
RUN /common.sh | ||
|
||
COPY cmake.sh / | ||
RUN /cmake.sh | ||
|
||
COPY xargo.sh / | ||
RUN /xargo.sh | ||
|
||
COPY zig.sh / | ||
RUN /zig.sh | ||
|
||
# needed for the zig cache, which tries to install a cache dir | ||
# in the current users directory, relative to $HOME. if the user | ||
# doesn't exist, it will try to install in the root directory, | ||
# getting permission errors | ||
RUN adduser --uid 1000 --disabled-password --gecos "" cross | ||
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \ | ||
qemu-system \ | ||
qemu-user | ||
# we don't export `BINDGEN_EXTRA_CLANG_ARGS`, `QEMU_LD_PREFIX`, or | ||
# `PKG_CONFIG_PATH` since zig doesn't have a traditional sysroot structure, | ||
# and we're not using standard, shared packages. none of the packages | ||
# have runners either, since they do not ship with the required | ||
# dynamic linker (`ld-linux-${arch}.so`). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
set -euo pipefail | ||
|
||
# shellcheck disable=SC1091 | ||
. lib.sh | ||
|
||
main() { | ||
install_packages ca-certificates curl xz-utils | ||
|
||
install_zig | ||
install_zigbuild | ||
|
||
purge_packages | ||
rm "${0}" | ||
} | ||
|
||
install_zig() { | ||
local version="0.9.1" | ||
local filename="zig-linux-x86_64-${version}.tar.xz" | ||
local dst="/opt/zig" | ||
|
||
local td | ||
td="$(mktemp -d)" | ||
|
||
pushd "${td}" | ||
|
||
curl --retry 3 -sSfL "https://ziglang.org/download/${version}/${filename}" -O | ||
mkdir -p "${dst}" | ||
tar --strip-components=1 -xJf "${filename}" --directory "${dst}" | ||
|
||
popd | ||
|
||
rm -rf "${td}" | ||
} | ||
|
||
install_zigbuild() { | ||
local version=0.10.3 | ||
|
||
local td | ||
td="$(mktemp -d)" | ||
|
||
pushd "${td}" | ||
|
||
export RUSTUP_HOME="${td}/rustup" | ||
export CARGO_HOME="${td}/cargo" | ||
|
||
curl --retry 3 -sSfL https://sh.rustup.rs -o rustup-init.sh | ||
sh rustup-init.sh -y --no-modify-path --profile minimal | ||
|
||
PATH="${CARGO_HOME}/bin:${PATH}" \ | ||
cargo install cargo-zigbuild \ | ||
--version "${version}" \ | ||
--root /usr/local | ||
|
||
popd | ||
|
||
rm -rf "${td}" | ||
} | ||
|
||
main "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.