igneum/proto-cuda/windows-node/make-package.sh
igneum-labs dde280f466 Windows node package: igneumd cross-compiled for the PC, START-NODE and BUILD-NODE launchers
proto-cuda/windows-node/: START-NODE.bat and start-node.ps1 (igneumd
--devnet with --addpeer to the Mac, status line every 30 s through
igneum-miner watch, keep-awake, random-delay restart, Ctrl+C),
BUILD-NODE.bat and build-node.ps1 (builds on the PC from the src.zip
snapshot; winget for Rustup, LLVM and protoc; MSVC default toolset),
ALLOW-FIREWALL.bat and allow-firewall.ps1, README.txt, cross-build.sh
(the mingw-w64 recipe that built igneumd.exe in 8 min 25 s; the exe
ships with the three mingw runtime DLLs) and make-package.sh.
WINDOWS-MINER.md gains "Run your own node"; bench-log records the
cross-compile and the two-peer sync test on the Mac (ports 27000 and
27010, live node untouched). The mining launcher's NODE_HOST=auto
edit stays uncommitted for the agent that owns start-mining.ps1.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-03 20:54:27 +00:00

57 lines
3.9 KiB
Bash
Executable file

#!/usr/bin/env bash
# Builds igneum-node-windows.zip (run your own Igneum node on a Windows PC) on the Mac.
# Contents: START-NODE.bat, start-node.ps1, BUILD-NODE.bat, build-node.ps1, ALLOW-FIREWALL.bat, allow-firewall.ps1,
# README.txt, upload-log.bat (from windows-miner/), WINDOWS-MINER.md, igneum-miner.exe (cross-compiled, the status
# reader), igneumd.exe when a cross-compiled one exists, and src.zip: a `git archive` of the node worktree's HEAD under
# vendor/igneum-node/ plus igneum-pow/ from this repository's HEAD (the fork depends on it by relative path), so the PC
# can build the node with BUILD-NODE.bat without any GitHub access.
# Usage: windows-node/make-package.sh [node worktree, default vendor/igneum-node-win] [output zip, default ~/Desktop/igneum-node-windows.zip]
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$HERE/../.." && pwd)"
NODE="${1:-$ROOT/vendor/igneum-node-win}"
OUT="${2:-$HOME/Desktop/igneum-node-windows.zip}"
[ -f "$NODE/Cargo.toml" ] || { echo "no node worktree at $NODE" >&2; exit 1; }
EXE="$NODE/target/x86_64-pc-windows-gnu/release/igneumd.exe"
MINER="$NODE/target/x86_64-pc-windows-gnu/release/igneum-miner.exe"
STAGE="$(mktemp -d)/igneum-node-windows"
mkdir -p "$STAGE/srcstage"
cp "$HERE/START-NODE.bat" "$HERE/start-node.ps1" "$HERE/BUILD-NODE.bat" "$HERE/build-node.ps1" \
"$HERE/ALLOW-FIREWALL.bat" "$HERE/allow-firewall.ps1" "$HERE/README.txt" "$STAGE/"
cp "$ROOT/proto-cuda/windows-miner/upload-log.bat" "$STAGE/"
cp "$ROOT/proto-cuda/WINDOWS-MINER.md" "$STAGE/"
MINGW=/opt/homebrew/opt/mingw-w64/toolchain-x86_64/x86_64-w64-mingw32
if [ -f "$EXE" ]; then
cp "$EXE" "$STAGE/igneumd.exe"; echo "igneumd.exe: $(ls -la "$EXE" | awk '{print $5}') bytes (cross-compiled)"
# The exe imports libstdc++-6.dll (rustc passes the cc crate's -lstdc++ as -Bdynamic, so -static does not cover it);
# that DLL needs libgcc_s_seh-1.dll and libwinpthread-1.dll. Ship the three next to the exe (GCC runtime exception).
IMPORTS="$(x86_64-w64-mingw32-objdump -p "$EXE" 2>/dev/null | grep 'DLL Name: lib' || true)" # no grep -q: pipefail would turn objdump's SIGPIPE into a miss
if [ -n "$IMPORTS" ]; then
for dll in lib/libstdc++-6.dll lib/libgcc_s_seh-1.dll bin/libwinpthread-1.dll; do
[ -f "$MINGW/$dll" ] || { echo "missing $MINGW/$dll" >&2; exit 1; }
cp "$MINGW/$dll" "$STAGE/"
x86_64-w64-mingw32-strip "$STAGE/$(basename "$dll")" 2>/dev/null || true # the toolchain's libstdc++-6.dll carries 27 MB of debug symbols
done
echo "mingw runtime DLLs added next to the exe: libstdc++-6.dll libgcc_s_seh-1.dll libwinpthread-1.dll"
fi
else echo "no cross-compiled igneumd.exe at $EXE; the package builds on the PC"; fi
if [ -f "$MINER" ]; then cp "$MINER" "$STAGE/igneum-miner.exe"; else echo "warning: no cross-compiled igneum-miner.exe at $MINER (BUILD-NODE.bat builds it too)"; fi
# the source snapshot
NODE_HEAD="$(git -C "$NODE" rev-parse HEAD)"
ROOT_HEAD="$(git -C "$ROOT" rev-parse HEAD)"
git -C "$NODE" archive --format=tar --prefix=vendor/igneum-node/ HEAD | tar -x -C "$STAGE/srcstage"
git -C "$ROOT" archive --format=tar HEAD igneum-pow | tar -x -C "$STAGE/srcstage"
{
echo "igneum node source snapshot, made $(date -u +%Y-%m-%dT%H:%M:%SZ)"
echo "vendor/igneum-node: branch $(git -C "$NODE" rev-parse --abbrev-ref HEAD) commit $NODE_HEAD ($(git -C "$NODE" log -1 --format=%s))"
echo "igneum-pow: igneum commit $ROOT_HEAD"
echo "build: cd vendor/igneum-node && cargo build --release -p kaspad --features igneum-pow (binary: target/release/igneumd)"
} > "$STAGE/srcstage/SNAPSHOT.txt"
(cd "$STAGE/srcstage" && zip -qr "../src.zip" .)
rm -rf "$STAGE/srcstage"
# CRLF for the files Windows tools read as text
for f in "$STAGE"/*.bat "$STAGE/README.txt"; do perl -pi -e 's/\r?\n/\r\n/' "$f"; done
rm -f "$OUT"
(cd "$(dirname "$STAGE")" && zip -qr "$OUT" "$(basename "$STAGE")")
ls -la "$OUT"
unzip -l "$OUT" | tail -n +4 | awk '{print $1, $4}' | sed '/^ *$/d'