#!/usr/bin/env bash # Cross-build the Windows NSIS installer for Gesprächsrekorder from Debian, # using cargo-xwin (MSVC cross-linking) and makensis for bundling. # # Usage: scripts/build-windows.sh # # Without an updater signing key (TAURI_SIGNING_PRIVATE_KEY) the installer is # built without updater artifacts; scripts/build-release.sh sets the key and # builds the signed release. set -euo pipefail SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)" REPO_ROOT="$(cd -- "${SCRIPT_DIR}/.." >/dev/null 2>&1 && pwd -P)" export PATH="${HOME}/.cargo/bin:${PATH}" TARGET="x86_64-pc-windows-msvc" missing=() if ! command -v makensis >/dev/null 2>&1; then missing+=("makensis (NSIS) not found on PATH") fi if ! command -v cargo-xwin >/dev/null 2>&1; then missing+=("cargo-xwin not found on PATH (expected under ~/.cargo/bin)") fi if ! rustup target list --installed 2>/dev/null | grep -qx "${TARGET}"; then missing+=("rustup target '${TARGET}' is not installed (run: rustup target add ${TARGET})") fi if [ "${#missing[@]}" -gt 0 ]; then echo "Missing prerequisites for Windows cross-build:" >&2 for item in "${missing[@]}"; do echo " - ${item}" >&2 done exit 1 fi cd "${REPO_ROOT}" config_args=() if [ -z "${TAURI_SIGNING_PRIVATE_KEY:-}" ]; then echo "No TAURI_SIGNING_PRIVATE_KEY set: building without updater artifacts." config_args=(--config '{"bundle":{"createUpdaterArtifacts":false}}') fi cargo tauri build \ --runner cargo-xwin \ --target "${TARGET}" \ --bundles nsis \ "${config_args[@]}" BUNDLE_DIR="${REPO_ROOT}/target/${TARGET}/release/bundle/nsis" echo "Build finished. NSIS installer(s):" find "${BUNDLE_DIR}" -maxdepth 1 -name '*.exe' -print