Repository navigation
cargo-zigbuild possible? #3185
|
Hello, Is it possible to combine cargo-nextest and cargo-zigbuild ? I am compiling my project on a linux host (x86_64-unknown-linux-gnu). To compile for my other targets (aarch64-unknown-linux-gnu and x86_64-pc-windows-gnu), I am using cargo-zigbuild. Everything is working smoothly. To run my tests on the different targets, I have configured the runner in the .cargo/config.toml file:
|
Replies: 4 comments 1 reply
|
Thanks for the issue. Nextest will pick up the target runner correctly, but it's possible that zigbuild needs to gain a nextest command. |
|
So in your opinion, it would make more sense to add a nextest command to zigbuild: |
|
FYI I created a thread in the zigbuild github to discuss this possibility rust-cross/cargo-zigbuild#427 |
|
I needed this for
The resulting command is effectively: CARGO=/path/to/cargo-driver \
REAL_CARGO="$(command -v cargo)" \
CARGO_ZIGBUILD="$(command -v cargo-zigbuild)" \
RUST_RUNTIME_ZIG_TARGET=x86_64-unknown-linux-gnu.2.17 \
cargo-nextest nextest archive --target x86_64-unknown-linux-gnu ...This lets the nextest-facing command retain the canonical target while the actual compilation goes through Zig with its ABI-compatible target. The wrapper validates that exactly one canonical #!/bin/bash
set -euo pipefail
: "${REAL_CARGO:?REAL_CARGO is required}"
: "${CARGO_ZIGBUILD:?CARGO_ZIGBUILD is required}"
: "${RUST_RUNTIME_ZIG_TARGET:?RUST_RUNTIME_ZIG_TARGET is required}"
args=("$@")
if [[ "${args[0]:-}" != test ]]; then
exec env -u CARGO "$REAL_CARGO" "${args[@]}"
fi
for index in "${!args[@]}"; do
case "${args[index]}" in
--target)
next_index=$((index + 1))
[[ "${args[next_index]}" == x86_64-unknown-linux-gnu ]] ||
{ echo "expected canonical Linux target" >&2; exit 1; }
args[next_index]="$RUST_RUNTIME_ZIG_TARGET"
;;
--target=x86_64-unknown-linux-gnu)
args[index]="--target=$RUST_RUNTIME_ZIG_TARGET"
;;
esac
done |
Correct, yes. That is how tools like llvm-cov integrate into nextest as well.