Skip to content

Commit 1a11321

Browse files
committed
ci: build: Add set_arch for better ergonomics
Intended for local usage with the container, map short-names to installed compiler and architectures. `which` command is used for sanity testing. Signed-off-by: Jorge Marques <jorge.marques@analog.com>
1 parent f92ab61 commit 1a11321

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

ci/build.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,63 @@ auto_set_kconfig() {
929929
return 0
930930
}
931931

932+
set_arch () {
933+
local version_gcc=14
934+
local version_llvm=19
935+
local arch_gcc=("gcc_arm" "gcc_aarch64" "gcc_x86")
936+
local arch_llvm=("llvm_x86")
937+
local arch=( "${arch_llvm[@]}" "${arch_gcc[@]}")
938+
local fail=false
939+
arch_="\<${1}\>"
940+
if [[ -z "$1" ]]; then
941+
printf "missing architecture"
942+
fail=true
943+
elif [[ "${arch[@]}" =~ $arch_ ]]; then
944+
unset CXX
945+
unset LLVM
946+
unset ARCH
947+
unset CROSS_COMPILE
948+
949+
if [[ "${arch_gcc[@]}" =~ $arch_ ]]; then
950+
export CXX=gcc-$version_gcc
951+
case $1 in
952+
gcc_arm)
953+
export CROSS_COMPILE=arm-suse-linux-gnueabi-
954+
export ARCH=arm
955+
;;
956+
gcc_aarch64)
957+
export CROSS_COMPILE=aarch64-suse-linux-
958+
export ARCH=arm64
959+
;;
960+
gcc_x86)
961+
export ARCH=x86
962+
;;
963+
esac
964+
which ${CROSS_COMPILE}${CXX} 1>/dev/null
965+
elif [[ "${arch_llvm[@]}" =~ $arch_ ]]; then
966+
export LLVM=-$version_llvm
967+
case $1 in
968+
llvm_x86)
969+
export ARCH=x86
970+
;;
971+
esac
972+
which ${CROSS_COMPILE}clang${LLVM} 1>/dev/null
973+
fi
974+
else
975+
printf "unknown architecture '$1'"
976+
fail=true
977+
fi
978+
979+
if [[ "$fail" == "true" ]]; then
980+
printf ", usage:\n"
981+
echo " set_arch <arch>"
982+
echo "available architectures: "
983+
echo " ${arch[@]}"
984+
else
985+
printenv | grep -i '^LLVM=\|^CXX=\|^ARCH=\|^CROSS_COMPILE='
986+
fi
987+
}
988+
932989
set_step_warn () {
933990
echo ; echo "step_warn_$1=true" >> "$GITHUB_ENV"
934991
}

0 commit comments

Comments
 (0)