clang under strict C11 left strcasestr undeclared (returns int → pointer truncation → SIGSEGV). Parse Content-Length portably; keep -Werror on make check. Drop Nix for windows-cross (root /nix fails) and use pinned llvm-mingw UCRT instead; Alpine musl gets linux-headers for audit.h.
60 lines
1.9 KiB
Bash
Executable File
60 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# CI helper: MinGW-w64 UCRT toolchain via llvm-mingw (no Nix / no /nix).
|
|
# Downloads a pinned release, puts it on PATH, then runs bootstrap_windows.sh.
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
VER="${CST_LLVM_MINGW_VER:-20241030}"
|
|
NAME="llvm-mingw-${VER}-ucrt-ubuntu-20.04-x86_64"
|
|
TGZ="/tmp/${NAME}.tar.xz"
|
|
# Prefer /opt when writable (root CI); else unpack under $HOME.
|
|
if [[ -w /opt || "$(id -u)" -eq 0 ]]; then
|
|
DIR="/opt/${NAME}"
|
|
PARENT=/opt
|
|
else
|
|
DIR="${HOME}/${NAME}"
|
|
PARENT="$HOME"
|
|
fi
|
|
|
|
if [[ ! -x "$DIR/bin/x86_64-w64-mingw32-gcc" ]]; then
|
|
echo "==> download $NAME"
|
|
urls=(
|
|
"https://gitclone.com/github.com/mstorsjo/llvm-mingw/releases/download/${VER}/${NAME}.tar.xz"
|
|
"https://mirror.ghproxy.com/https://github.com/mstorsjo/llvm-mingw/releases/download/${VER}/${NAME}.tar.xz"
|
|
"https://github.com/mstorsjo/llvm-mingw/releases/download/${VER}/${NAME}.tar.xz"
|
|
)
|
|
ok=0
|
|
for u in "${urls[@]}"; do
|
|
echo " try $u"
|
|
if curl -fL --retry 2 --connect-timeout 20 --retry-delay 2 -o "$TGZ" "$u"; then
|
|
ok=1
|
|
break
|
|
fi
|
|
done
|
|
[[ $ok -eq 1 ]] || { echo "failed to download llvm-mingw" >&2; exit 1; }
|
|
rm -rf "$DIR"
|
|
mkdir -p "$PARENT"
|
|
tar -C "$PARENT" -xf "$TGZ"
|
|
fi
|
|
|
|
export PATH="$DIR/bin:$PATH"
|
|
export MINGW_HOST=x86_64-w64-mingw32
|
|
export BUILD_CC="${BUILD_CC:-cc}"
|
|
|
|
need() { command -v "$1" >/dev/null || { echo "missing $1" >&2; exit 1; }; }
|
|
need x86_64-w64-mingw32-gcc
|
|
need x86_64-w64-mingw32-windres
|
|
need cmake; need ninja; need perl; need zip; need git; need make
|
|
|
|
if ! printf '#include <stdio.h>\n' | x86_64-w64-mingw32-gcc -dM -E - | grep -qw _UCRT; then
|
|
echo "toolchain is not UCRT" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Third-party sources live on GitHub; prefer a CN-friendly rewrite.
|
|
git config --global url."https://gitclone.com/github.com/".insteadOf "https://github.com/" || true
|
|
|
|
echo "==> bootstrap_windows.sh"
|
|
exec bash scripts/bootstrap_windows.sh "$ROOT"
|