41 lines
1.1 KiB
Bash
Raw Normal View History

2025-06-26 16:03:57 +07:00
#!/usr/bin/env bash
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
2025-07-02 09:26:11 +07:00
BUILDROOT_ABS="$(realpath "$SCRIPT_DIR/../../buildroot/include" 2>/dev/null || true)"
2025-06-26 16:03:57 +07:00
PARSED_ARGS=()
while [[ $# -gt 0 ]]; do
case "$1" in
-isystem)
shift
ARG="$1"
2025-07-02 09:26:11 +07:00
shift
ARG_ABS="$(realpath "$ARG" 2>/dev/null || true)"
[[ "$ARG_ABS" == "$BUILDROOT_ABS" ]] && PARSED_ARGS+=("-I$ARG") || PARSED_ARGS+=("-isystem" "$ARG")
2025-06-26 16:03:57 +07:00
;;
-isystem*)
ARG="${1#-isystem}"
shift
2025-07-02 09:26:11 +07:00
ARG_ABS="$(realpath "$ARG" 2>/dev/null || true)"
[[ "$ARG_ABS" == "$BUILDROOT_ABS" ]] && PARSED_ARGS+=("-I$ARG") || PARSED_ARGS+=("-isystem$ARG")
2025-06-26 16:03:57 +07:00
;;
*)
PARSED_ARGS+=("$1")
shift
;;
esac
done
2025-07-02 09:26:11 +07:00
[[ -n "$SPC_TARGET" ]] && TARGET="-target $SPC_TARGET" || TARGET=""
2025-07-01 16:21:57 +07:00
output=$(zig cc $TARGET $COMPILER_EXTRA "${PARSED_ARGS[@]}" 2>&1)
2025-07-01 14:12:51 +07:00
status=$?
2025-06-26 16:03:57 +07:00
2025-07-02 09:26:11 +07:00
if [[ $status -ne 0 ]] && grep -q "version '.*' in target triple" <<< "$output"; then
output=$(grep -v "version '.*' in target triple" <<< "$output")
2025-07-02 09:23:31 +07:00
status=0
2025-06-26 16:03:57 +07:00
fi
2025-07-02 09:23:31 +07:00
echo "$output"
exit $status