Files
kdm-re/tests/smoke/build.sh
T

27 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Cross-compiles tests/smoke/hello.c into a 32-bit Windows DLL using the pinned
# i686-w64-mingw32 toolchain. Run from the worktree root or this directory.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
# shellcheck source=/dev/null
source "$ROOT_DIR/activate.sh"
command -v i686-w64-mingw32-gcc >/dev/null || {
echo "build.sh: i686-w64-mingw32-gcc not found on PATH after sourcing activate.sh." >&2
echo " See $ROOT_DIR/activate.sh (and toolchain.lock for the pinned install commands)" >&2
echo " to install/activate the no-sudo mingw-w64 cross toolchain." >&2
exit 1
}
# The pinned i686-w64-mingw32-gcc (16.2.0) links its default startup objects
# against mcfgthread; that runtime lib ships as its own nix package
# (pkgsCross.mingw32.windows.mcfgthreads) rather than bundled in gcc's own
# search path, so point the linker at it explicitly.
MCFGTHREAD_LIB="/nix/store/g72bh3mrbh6gkh59axd2199js9kccxfs-mcfgthread-i686-w64-mingw32-2.5.1/lib"
cd "$SCRIPT_DIR"
i686-w64-mingw32-gcc -shared -o hello.dll hello.c -L"$MCFGTHREAD_LIB" -Wl,--out-implib,libhello.a
echo "Built: $SCRIPT_DIR/hello.dll"