mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
configure: set the bindgen cross target
Implement a bash version of rust-bindgen rust_to_clang_target() to convert from rust target to clang target. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-ID: <20250924120426.2158655-8-marcandre.lureau@redhat.com>
This commit is contained in:
@@ -1878,6 +1878,13 @@ if test "$skip_meson" = no; then
|
|||||||
eval "c=\$devices_${a}"
|
eval "c=\$devices_${a}"
|
||||||
echo "${a}-softmmu = '$c'" >> $cross
|
echo "${a}-softmmu = '$c'" >> $cross
|
||||||
done
|
done
|
||||||
|
if test "$rust" != disabled; then
|
||||||
|
if test "$cross_compile" = "yes"; then
|
||||||
|
. "$source_path/scripts/rust-to-clang-target.sh"
|
||||||
|
clang_target=$(rust_to_clang_target "$rust_target_triple")
|
||||||
|
echo "bindgen_clang_arguments = [$(meson_quote --target="$clang_target")]" >> $cross
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "[built-in options]" >> $cross
|
echo "[built-in options]" >> $cross
|
||||||
echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
|
echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
|
||||||
|
|||||||
Executable
+43
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2025 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# Based on rust_to_clang_target() tests from rust-bindgen.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
scripts_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||||
|
. "$scripts_dir/rust-to-clang-target.sh"
|
||||||
|
|
||||||
|
test_case() {
|
||||||
|
input="$1"
|
||||||
|
expected="$2"
|
||||||
|
result=$(rust_to_clang_target "$input")
|
||||||
|
|
||||||
|
if [ "$result" = "$expected" ]; then
|
||||||
|
echo " OK: '$input' -> '$result'"
|
||||||
|
else
|
||||||
|
echo " FAILED: '$input'"
|
||||||
|
echo " Expected: '$expected'"
|
||||||
|
echo " Got: '$result'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Running tests..."
|
||||||
|
|
||||||
|
test_case "aarch64-apple-ios" "arm64-apple-ios"
|
||||||
|
test_case "riscv64gc-unknown-linux-gnu" "riscv64-unknown-linux-gnu"
|
||||||
|
test_case "riscv64imac-unknown-none-elf" "riscv64-unknown-none-elf"
|
||||||
|
test_case "riscv32imc-unknown-none-elf" "riscv32-unknown-none-elf"
|
||||||
|
test_case "riscv32imac-unknown-none-elf" "riscv32-unknown-none-elf"
|
||||||
|
test_case "riscv32imafc-unknown-none-elf" "riscv32-unknown-none-elf"
|
||||||
|
test_case "riscv32i-unknown-none-elf" "riscv32-unknown-none-elf"
|
||||||
|
test_case "riscv32imc-esp-espidf" "riscv32-esp-elf"
|
||||||
|
test_case "xtensa-esp32-espidf" "xtensa-esp32-elf"
|
||||||
|
test_case "aarch64-apple-ios-sim" "arm64-apple-ios-simulator"
|
||||||
|
test_case "aarch64-apple-tvos-sim" "arm64-apple-tvos-simulator"
|
||||||
|
test_case "aarch64-apple-watchos-sim" "arm64-apple-watchos-simulator"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "All tests passed!"
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# Copyright (C) 2025 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# Based on rust_to_clang_target() from rust-bindgen.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
rust_to_clang_target() {
|
||||||
|
rust_target="$1"
|
||||||
|
|
||||||
|
# Split the string by hyphens
|
||||||
|
triple_parts=""
|
||||||
|
old_IFS="$IFS"
|
||||||
|
IFS='-'
|
||||||
|
for part in $rust_target; do
|
||||||
|
triple_parts="$triple_parts $part"
|
||||||
|
done
|
||||||
|
IFS="$old_IFS"
|
||||||
|
set -- $triple_parts
|
||||||
|
|
||||||
|
# RISC-V
|
||||||
|
case "$1" in
|
||||||
|
riscv32*)
|
||||||
|
set -- "riscv32" "${2}" "${3}" "${4}"
|
||||||
|
;;
|
||||||
|
riscv64*)
|
||||||
|
set -- "riscv64" "${2}" "${3}" "${4}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Apple
|
||||||
|
if [ "$2" = "apple" ]; then
|
||||||
|
if [ "$1" = "aarch64" ]; then
|
||||||
|
set -- "arm64" "${2}" "${3}" "${4}"
|
||||||
|
fi
|
||||||
|
if [ "$4" = "sim" ]; then
|
||||||
|
set -- "${1}" "${2}" "${3}" "simulator"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ESP-IDF
|
||||||
|
if [ "$3" = "espidf" ]; then
|
||||||
|
set -- "${1}" "${2}" "elf" "${4}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Reassemble the string
|
||||||
|
new_triple=""
|
||||||
|
first=1
|
||||||
|
for part in "$@"; do
|
||||||
|
if [ -n "$part" ]; then
|
||||||
|
if [ "$first" -eq 1 ]; then
|
||||||
|
new_triple="$part"
|
||||||
|
first=0
|
||||||
|
else
|
||||||
|
new_triple="$new_triple-$part"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "$new_triple"
|
||||||
|
}
|
||||||
+1
-1
Submodule tests/lcitool/libvirt-ci updated: 18c4bfe02c...9da20ff7c3
Reference in New Issue
Block a user