igneum/tools/ca3-pc1-amd/make-family-kit.sh

25 lines
1.6 KiB
Bash
Executable file

#!/usr/bin/env bash
# The family kit for tools/ca3-pc1-amd/pc1-amd-family.ps1 run b (6 October 2026): the OpenCL family probe
# (proto-opencl/family-probe.c, with --device-name) cross-compiled with mingw, its source and SHA256SUMS. A kit of its
# own because the app runs a fetch id once and the first kit's probe took a bare ordinal.
# tools/ca3-pc1-amd/make-family-kit.sh [out.zip] default $TMPDIR/igneum-ca3-pc1-amd-family-kit.zip
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$HERE/../.." && pwd)"
OUT="${1:-${TMPDIR:-/tmp}/igneum-ca3-pc1-amd-family-kit.zip}"
RED="${IGNEUM_REDIST:-$ROOT/proto-cuda/nvrtc/redist}"
[ -f "$RED/include/CL/cl.h" ] || { echo "no OpenCL headers at $RED/include/CL/cl.h (run proto-cuda/nvrtc/fetch-redist.sh or set IGNEUM_REDIST)" >&2; exit 1; }
CC=x86_64-w64-mingw32-gcc; STRIP=x86_64-w64-mingw32-strip
command -v "$CC" >/dev/null || { echo "$CC not found (brew install mingw-w64)" >&2; exit 1; }
STAGE="$(mktemp -d)"
mkdir -p "$STAGE/bin" "$STAGE/src"
echo "== family-probe-cl.exe (proto-opencl/family-probe.c)"
"$CC" -std=c99 -O2 -Wall -Wextra -static -DIGNEUM_CL_DYNAMIC -DCL_TARGET_OPENCL_VERSION=120 -I "$RED/include" -o "$STAGE/bin/family-probe-cl.exe" "$ROOT/proto-opencl/family-probe.c"
"$STRIP" "$STAGE/bin/family-probe-cl.exe"
cp "$ROOT/proto-opencl/family-probe.c" "$ROOT/proto-opencl/cl_dynamic.h" "$STAGE/src/"
( cd "$STAGE" && find . -type f ! -name SHA256SUMS | sort | xargs shasum -a 256 > SHA256SUMS )
rm -f "$OUT"
( cd "$STAGE" && zip -X -q -r "$OUT" . )
rm -rf "$STAGE"
echo "kit $OUT"
echo "sha256 $(shasum -a 256 "$OUT" | cut -c1-64) bytes $(wc -c < "$OUT" | tr -d ' ')"