Skip to content

Commit ba7f994

Browse files
committed
simplify zig script
1 parent 9c7e217 commit ba7f994

File tree

1 file changed

+9
-44
lines changed

1 file changed

+9
-44
lines changed

src/SPC/store/scripts/zig-cc.sh

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -34,52 +34,17 @@ while [[ $# -gt 0 ]]; do
3434
esac
3535
done
3636

37-
SPC_TARGET_WAS_SET=1
38-
if [ -z "${SPC_TARGET+x}" ]; then
39-
SPC_TARGET_WAS_SET=0
40-
fi
41-
42-
UNAME_M="$(uname -m)"
43-
UNAME_S="$(uname -s)"
44-
45-
case "$UNAME_M" in
46-
x86_64) ARCH="x86_64" ;;
47-
aarch64|arm64) ARCH="aarch64" ;;
48-
*) echo "Unsupported architecture: $UNAME_M" >&2; exit 1 ;;
49-
esac
50-
51-
case "$UNAME_S" in
52-
Linux) OS="linux" ;;
53-
Darwin) OS="macos" ;;
54-
*) echo "Unsupported OS: $UNAME_S" >&2; exit 1 ;;
55-
esac
37+
output=$(zig cc -target ${SPC_TARGET} -lstdc++ ${COMPILER_EXTRA} "${PARSED_ARGS[@]}" 2>&1)
38+
status=$?
5639

57-
SPC_TARGET="${SPC_TARGET:-$ARCH-$OS}"
58-
59-
if [ "$SPC_LIBC" = "glibc" ]; then
60-
SPC_LIBC="gnu"
40+
if [ $status -eq 0 ]; then
41+
echo "$output"
42+
exit 0
6143
fi
6244

63-
if [ "$SPC_TARGET_WAS_SET" -eq 0 ] && [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then
64-
exec zig cc ${COMPILER_EXTRA} "${PARSED_ARGS[@]}"
65-
elif [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then
66-
exec zig cc -target "${SPC_TARGET}" ${COMPILER_EXTRA} "${PARSED_ARGS[@]}"
45+
if echo "$output" | grep -q "version '.*' in target triple"; then
46+
echo "$output" | grep -v "version '.*' in target triple"
47+
exit 0
6748
else
68-
TARGET="${SPC_TARGET}-${SPC_LIBC}"
69-
[ -n "$SPC_LIBC_VERSION" ] && TARGET="${TARGET}.${SPC_LIBC_VERSION}"
70-
71-
output=$(zig cc -target ${TARGET} -lstdc++ ${COMPILER_EXTRA} "${PARSED_ARGS[@]}" 2>&1)
72-
status=$?
73-
74-
if [ $status -eq 0 ]; then
75-
echo "$output"
76-
exit 0
77-
fi
78-
79-
if echo "$output" | grep -q "version '.*' in target triple"; then
80-
echo "$output" | grep -v "version '.*' in target triple"
81-
exit 0
82-
else
83-
exec zig cc -target ${TARGET} ${COMPILER_EXTRA} "${PARSED_ARGS[@]}"
84-
fi
49+
exec zig cc -target ${SPC_TARGET} ${COMPILER_EXTRA} "${PARSED_ARGS[@]}"
8550
fi

0 commit comments

Comments
 (0)