From ba7f994a717354eeeb53feaff93291ee802f9eac Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 1 Jul 2025 14:12:51 +0700 Subject: [PATCH] simplify zig script --- src/SPC/store/scripts/zig-cc.sh | 55 ++++++--------------------------- 1 file changed, 10 insertions(+), 45 deletions(-) diff --git a/src/SPC/store/scripts/zig-cc.sh b/src/SPC/store/scripts/zig-cc.sh index 96745166..72900e72 100644 --- a/src/SPC/store/scripts/zig-cc.sh +++ b/src/SPC/store/scripts/zig-cc.sh @@ -34,52 +34,17 @@ while [[ $# -gt 0 ]]; do esac done -SPC_TARGET_WAS_SET=1 -if [ -z "${SPC_TARGET+x}" ]; then - SPC_TARGET_WAS_SET=0 +output=$(zig cc -target ${SPC_TARGET} -lstdc++ ${COMPILER_EXTRA} "${PARSED_ARGS[@]}" 2>&1) +status=$? + +if [ $status -eq 0 ]; then + echo "$output" + exit 0 fi -UNAME_M="$(uname -m)" -UNAME_S="$(uname -s)" - -case "$UNAME_M" in - x86_64) ARCH="x86_64" ;; - aarch64|arm64) ARCH="aarch64" ;; - *) echo "Unsupported architecture: $UNAME_M" >&2; exit 1 ;; -esac - -case "$UNAME_S" in - Linux) OS="linux" ;; - Darwin) OS="macos" ;; - *) echo "Unsupported OS: $UNAME_S" >&2; exit 1 ;; -esac - -SPC_TARGET="${SPC_TARGET:-$ARCH-$OS}" - -if [ "$SPC_LIBC" = "glibc" ]; then - SPC_LIBC="gnu" -fi - -if [ "$SPC_TARGET_WAS_SET" -eq 0 ] && [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then - exec zig cc ${COMPILER_EXTRA} "${PARSED_ARGS[@]}" -elif [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then - exec zig cc -target "${SPC_TARGET}" ${COMPILER_EXTRA} "${PARSED_ARGS[@]}" +if echo "$output" | grep -q "version '.*' in target triple"; then + echo "$output" | grep -v "version '.*' in target triple" + exit 0 else - TARGET="${SPC_TARGET}-${SPC_LIBC}" - [ -n "$SPC_LIBC_VERSION" ] && TARGET="${TARGET}.${SPC_LIBC_VERSION}" - - output=$(zig cc -target ${TARGET} -lstdc++ ${COMPILER_EXTRA} "${PARSED_ARGS[@]}" 2>&1) - status=$? - - if [ $status -eq 0 ]; then - echo "$output" - exit 0 - fi - - if echo "$output" | grep -q "version '.*' in target triple"; then - echo "$output" | grep -v "version '.*' in target triple" - exit 0 - else - exec zig cc -target ${TARGET} ${COMPILER_EXTRA} "${PARSED_ARGS[@]}" - fi + exec zig cc -target ${SPC_TARGET} ${COMPILER_EXTRA} "${PARSED_ARGS[@]}" fi