#!/bin/bash
# Wrapper script for zig c++ that:
# 1. Uses the correct Zig target (x86_64-linux-musl)
# 2. Strips conflicting --target=x86_64-unknown-linux-musl flags from cmake/boring-sys
# 3. Handles both compilation and assembly

args=()
for arg in "$@"; do
    case "$arg" in
        --target=x86_64-unknown-linux-musl) ;; # Strip Rust-style target
        --target=*-unknown-linux-*) ;; # Strip any Rust-style Linux target
        -target) ;; # Skip standalone -target (zig uses different format)
        x86_64-unknown-linux-musl) ;; # Skip if target is passed as separate arg
        *) args+=("$arg") ;;
    esac
done

exec zig c++ -target x86_64-linux-musl "${args[@]}"
