#!/usr/bin/env bash # Gives igneumd.exe and igneum-miner.exe the coin icon and a version block (CompanyName Igneum, ProductName # Igneum Miner, 0.1.0). Two steps, both on the Mac: # 1. windres compiles resources/igneumd.rc and resources/igneum-miner.rc into COFF objects (cheap, always done). # 2. --relink runs `cargo rustc` for each binary with `-C link-arg=`: only the final crate is recompiled and # relinked, every dependency comes from the cache, so it costs a few minutes after a normal cross-build. The # objects are linked in as extra inputs, nothing in vendor/ changes. Without --relink the exact commands are # printed, and build-installer.ps1 stamps the resources with rcedit on the PC instead. # The resulting exes land where proto-cuda/windows-app/make-package.sh already picks them up # (vendor/igneum-node-win/target/x86_64-pc-windows-gnu/release/). # # packaging/windows/embed-resources.sh compile the objects, print the relink commands # packaging/windows/embed-resources.sh --relink also relink both exes (needs a completed cross-build in the cache) set -euo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" ROOT="$(cd "$HERE/../.." && pwd)" ICONS="$ROOT/brand/icons" OUT="$HERE/build/res" NODE="${NODE_WORKTREE:-$ROOT/vendor/igneum-node-win}" MINGW="/opt/homebrew/opt/mingw-w64/toolchain-x86_64/x86_64-w64-mingw32" command -v x86_64-w64-mingw32-windres >/dev/null || { echo "x86_64-w64-mingw32-windres not found (brew install mingw-w64)" >&2; exit 1; } [ -f "$ICONS/igneum.ico" ] || { echo "no $ICONS/igneum.ico; run python3 brand/icons/make-icons.py first" >&2; exit 1; } mkdir -p "$OUT" for name in igneumd igneum-miner; do x86_64-w64-mingw32-windres -I "$ICONS" -i "$HERE/resources/$name.rc" -O coff -o "$OUT/$name.res.o" echo "compiled $OUT/$name.res.o ($(stat -f %z "$OUT/$name.res.o") bytes)" done # The same environment as proto-cuda/windows-node/cross-build.sh, so the cached dependencies are reused. export PATH="$HOME/.cargo/bin:/opt/homebrew/bin:$PATH" export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-target}" export CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc export CXX_x86_64_pc_windows_gnu=x86_64-w64-mingw32-g++ export AR_x86_64_pc_windows_gnu=x86_64-w64-mingw32-ar export LIBCLANG_PATH=/opt/homebrew/opt/llvm/lib export BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_windows_gnu="--target=x86_64-w64-mingw32 --sysroot=$MINGW -I$MINGW/include" export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS="-C link-arg=-static -C link-arg=-static-libgcc" relink_cmd() { # $1 package, $2 bin, $3 object printf 'nice -n 19 cargo rustc --release -j 2 -p %s --bin %s --features igneum-pow --target x86_64-pc-windows-gnu -- -C link-arg=%q\n' "$1" "$2" "$3" } if [ "${1:-}" = "--relink" ]; then cd "$NODE" for spec in "kaspad igneumd" "igneum-miner igneum-miner"; do set -- $spec echo "relinking $2.exe" eval "$(relink_cmd "$1" "$2" "$OUT/$2.res.o")" exe="$CARGO_TARGET_DIR/x86_64-pc-windows-gnu/release/$2.exe" x86_64-w64-mingw32-objdump -h "$exe" | grep -q '\.rsrc' && echo "$exe: .rsrc section present ($(stat -f %z "$exe") bytes)" || { echo "$exe has no .rsrc section" >&2; exit 1; } done else cat <