build: finish cross-platform release tooling
This commit is contained in:
+12
-50
@@ -1,64 +1,26 @@
|
||||
#!/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.
|
||||
# CI helper: Windows x86_64 release with Debian's mingw-w64 UCRT gcc.
|
||||
# apt-get install gcc-mingw-w64-ucrt64 binutils-mingw-w64-ucrt64 nsis (trixie+)
|
||||
# Checks the toolchain, then runs bootstrap_windows.sh, which builds the
|
||||
# third-party libs, cst-agent.exe, the zip and the NSIS installer.
|
||||
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"
|
||||
# Prefer CN-reachable GitHub proxies; raw github.com is often unreachable.
|
||||
urls=(
|
||||
"https://ghfast.top/https://github.com/mstorsjo/llvm-mingw/releases/download/${VER}/${NAME}.tar.xz"
|
||||
"https://ghproxy.net/https://github.com/mstorsjo/llvm-mingw/releases/download/${VER}/${NAME}.tar.xz"
|
||||
"https://gitclone.com/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 15 --max-time 600 \
|
||||
--retry-delay 2 -o "$TGZ" "$u"; then
|
||||
# Reject tiny error pages that some proxies return with HTTP 200.
|
||||
sz=$(wc -c <"$TGZ")
|
||||
if [[ "$sz" -gt 10000000 ]]; then
|
||||
ok=1
|
||||
break
|
||||
fi
|
||||
echo " too small ($sz bytes), next mirror"
|
||||
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 MINGW_HOST="${MINGW_HOST:-x86_64-w64-mingw32ucrt}"
|
||||
export BUILD_CC="${BUILD_CC:-cc}"
|
||||
export CST_REQUIRE_NSIS=1
|
||||
|
||||
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
|
||||
need "$MINGW_HOST-gcc"
|
||||
need "$MINGW_HOST-windres"
|
||||
need cmake; need ninja; need perl; need zip; need git; need make; need makensis
|
||||
|
||||
if ! printf '#include <stdio.h>\n' | x86_64-w64-mingw32-gcc -dM -E - | grep -qw _UCRT; then
|
||||
echo "toolchain is not UCRT" >&2
|
||||
if ! printf '#include <stdio.h>\n' | "$MINGW_HOST-gcc" -dM -E - | grep -qw _UCRT; then
|
||||
echo "$MINGW_HOST-gcc is not UCRT" >&2
|
||||
exit 1
|
||||
fi
|
||||
"$MINGW_HOST-gcc" --version | head -1
|
||||
|
||||
# Do not set a global insteadOf: a single broken proxy (e.g. gitclone 502)
|
||||
# would take down every third_party clone. build_third_party_mingw.sh tries
|
||||
|
||||
Reference in New Issue
Block a user