mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
simplify zig script
This commit is contained in:
parent
9c7e2171f6
commit
ba7f994a71
@ -34,52 +34,17 @@ while [[ $# -gt 0 ]]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
SPC_TARGET_WAS_SET=1
|
output=$(zig cc -target ${SPC_TARGET} -lstdc++ ${COMPILER_EXTRA} "${PARSED_ARGS[@]}" 2>&1)
|
||||||
if [ -z "${SPC_TARGET+x}" ]; then
|
status=$?
|
||||||
SPC_TARGET_WAS_SET=0
|
|
||||||
|
if [ $status -eq 0 ]; then
|
||||||
|
echo "$output"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
UNAME_M="$(uname -m)"
|
if echo "$output" | grep -q "version '.*' in target triple"; then
|
||||||
UNAME_S="$(uname -s)"
|
echo "$output" | grep -v "version '.*' in target triple"
|
||||||
|
exit 0
|
||||||
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[@]}"
|
|
||||||
else
|
else
|
||||||
TARGET="${SPC_TARGET}-${SPC_LIBC}"
|
exec zig cc -target ${SPC_TARGET} ${COMPILER_EXTRA} "${PARSED_ARGS[@]}"
|
||||||
[ -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
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user