Skip to content

Commit 2c56cbb

Browse files
Manciukicroypat
authored andcommitted
feat(devctr): add checkbuild command to cargo-check specific arch
Add a new checkbuild command to the devtool so that contributors can run cargo-check against all supported architectures. There is currently no easy way to check compilation against a different architectures. This causes unnecessary back and forth in reviews where the contributor has no easy access to the other architecture. Signed-off-by: Riccardo Mancini <[email protected]>
1 parent 0bf5dda commit 2c56cbb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tools/devtool

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,9 @@ cmd_help() {
427427
428428
checkstyle
429429
Run style checks
430+
431+
checkbuild [--all|-m x86_64|aarch64]
432+
Run cargo check on the target architecture (supports cross compilation).
430433
EOF
431434
}
432435

@@ -959,6 +962,39 @@ cmd_checkstyle() {
959962
cmd_test --no-build --no-kvm-check -- -n 4 --doctest-modules framework || exit 1
960963
}
961964

965+
cmd_checkbuild() {
966+
TARGET_ARCH=$(uname -m)
967+
SUPPORTED_ARCHS=(x86_64 aarch64)
968+
while [ $# -gt 0 ]; do
969+
case "$1" in
970+
"-h"|"--help") { cmd_help; exit 1; } ;;
971+
"-m"|"--arch") { TARGET_ARCH=$2; shift; } ;;
972+
"--all") {
973+
for arch in ${SUPPORTED_ARCHS[*]}; do
974+
say "Running checkbuild -m $arch"
975+
cmd_checkbuild -m $arch || return $?
976+
done
977+
}
978+
say "Build check passed for ${SUPPORTED_ARCHS[*]}"
979+
return 0
980+
;;
981+
*)
982+
die "Unknown argument: $1. Please use --help for help."
983+
;;
984+
esac
985+
shift
986+
done
987+
988+
if ! grep -q $TARGET_ARCH <<< "${SUPPORTED_ARCHS[*]}"; then
989+
die "Unknown architecture: $TARGET_ARCH. Supported architectures: ${SUPPORTED_ARCHS[*]}"
990+
fi
991+
992+
# Use GNU target to check build as musl has issues with cross-compilation
993+
cmd_sh "cargo clippy --target ${TARGET_ARCH}-unknown-linux-gnu --all --all-targets -- -D warnings" \
994+
|| die "Error running build checks for $TARGET_ARCH"
995+
say "Build check passed for $TARGET_ARCH"
996+
}
997+
962998
# Check if able to run firecracker.
963999
# ../docs/getting-started.md#prerequisites
9641000
ensure_kvm_rw () {

0 commit comments

Comments
 (0)