mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
simplify script a bit
This commit is contained in:
parent
b16638d813
commit
b5aa7fc213
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||||
BUILDROOT_ABS="$(realpath "$SCRIPT_DIR/../../buildroot/include" 2>/dev/null || echo "")"
|
BUILDROOT_ABS="$(realpath "$SCRIPT_DIR/../../buildroot/include" 2>/dev/null || true)"
|
||||||
PARSED_ARGS=()
|
PARSED_ARGS=()
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
@ -9,23 +9,15 @@ while [[ $# -gt 0 ]]; do
|
|||||||
-isystem)
|
-isystem)
|
||||||
shift
|
shift
|
||||||
ARG="$1"
|
ARG="$1"
|
||||||
[[ -n "$ARG" ]] && shift || break
|
shift
|
||||||
ARG_ABS="$(realpath "$ARG" 2>/dev/null || echo "")"
|
ARG_ABS="$(realpath "$ARG" 2>/dev/null || true)"
|
||||||
if [[ -n "$ARG_ABS" && "$ARG_ABS" == "$BUILDROOT_ABS" ]]; then
|
[[ "$ARG_ABS" == "$BUILDROOT_ABS" ]] && PARSED_ARGS+=("-I$ARG") || PARSED_ARGS+=("-isystem" "$ARG")
|
||||||
PARSED_ARGS+=("-I$ARG")
|
|
||||||
else
|
|
||||||
PARSED_ARGS+=("-isystem" "$ARG")
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
-isystem*)
|
-isystem*)
|
||||||
ARG="${1#-isystem}"
|
ARG="${1#-isystem}"
|
||||||
shift
|
shift
|
||||||
ARG_ABS="$(realpath "$ARG" 2>/dev/null || echo "")"
|
ARG_ABS="$(realpath "$ARG" 2>/dev/null || true)"
|
||||||
if [[ -n "$ARG_ABS" && "$ARG_ABS" == "$BUILDROOT_ABS" ]]; then
|
[[ "$ARG_ABS" == "$BUILDROOT_ABS" ]] && PARSED_ARGS+=("-I$ARG") || PARSED_ARGS+=("-isystem$ARG")
|
||||||
PARSED_ARGS+=("-I$ARG")
|
|
||||||
else
|
|
||||||
PARSED_ARGS+=("-isystem$ARG")
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
PARSED_ARGS+=("$1")
|
PARSED_ARGS+=("$1")
|
||||||
@ -34,16 +26,13 @@ while [[ $# -gt 0 ]]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
TARGET=""
|
[[ -n "$SPC_TARGET" ]] && TARGET="-target $SPC_TARGET" || TARGET=""
|
||||||
if [ -n "$SPC_TARGET" ]; then
|
|
||||||
TARGET="-target $SPC_TARGET"
|
|
||||||
fi
|
|
||||||
|
|
||||||
output=$(zig cc $TARGET $COMPILER_EXTRA "${PARSED_ARGS[@]}" 2>&1)
|
output=$(zig cc $TARGET $COMPILER_EXTRA "${PARSED_ARGS[@]}" 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
|
|
||||||
if [ $status -ne 0 ] && echo "$output" | grep -q "version '.*' in target triple"; then
|
if [[ $status -ne 0 ]] && grep -q "version '.*' in target triple" <<< "$output"; then
|
||||||
output=$(echo "$output" | grep -v "version '.*' in target triple")
|
output=$(grep -v "version '.*' in target triple" <<< "$output")
|
||||||
status=0
|
status=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user