Files
rustscreen/scripts/build-windows-installer.sh
Guillaume ASSIERandClaude Opus 5.5 78ac97903f
CI / Formatting, tests and builds (push) Successful in 2m55s
feat(windows): installateur NSIS non signé, construit depuis Linux
`scripts/build-windows-installer.sh` (#96) construit le viewer,
l'interface de bureau, les deux exécutables pour Windows (mingw-w64),
puis l'installateur avec NSIS, le tout dans les shells Nix: 16,6 Mo.

L'installateur s'installe pour l'utilisateur seul, sans droits
d'administrateur (%LOCALAPPDATA%\Programs\rustscreen), avec un
raccourci et une entrée de désinstallation. La désinstallation retire
aussi le démarrage automatique, et laisse réglages et journal.

L'application et la ligne de commande trouvent le viewer installé à
côté de l'exécutable (`viewer/`) quand RUSTSCREEN_VIEWER n'est pas
donné. L'icône Windows (icon.ico) est ajoutée, sans elle tauri-build
refuse la cible.

Guide « Démarrer sous Windows », marqué en cours de validation.
L'installateur n'a pas pu être essayé sous Wine (installateur 32 bits,
Wine WoW64 bloqué à l'initialisation): à vérifier sur un vrai Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 21:23:57 +01:00

45 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
# Builds the Windows installer from Linux (#96): viewer, desktop interface,
# the two executables cross-compiled with mingw-w64, then NSIS.
#
# ./scripts/build-windows-installer.sh # into dist/windows
# ./scripts/build-windows-installer.sh <folder>
#
# Needs Nix: every step runs in a shell of the flake, so nothing has to be
# installed on the machine. The installer is not signed (personal use, #90).
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
OUT="${1:-$ROOT/dist/windows}"
VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' "$ROOT/Cargo.toml" | head -1)"
STAGE="$OUT/stage"
cd "$ROOT"
echo "viewer and desktop interface"
nix develop .#default -c npm --prefix apps/viewer ci
nix develop .#default -c npm --prefix apps/viewer run build
nix develop .#desktop -c pnpm --dir apps/desktop install --frozen-lockfile
nix develop .#desktop -c pnpm --dir apps/desktop build
echo "Windows executables"
nix develop .#windows -c cargo build --release -p rs-session --bin rustscreen-cli
nix develop .#windows -c sh -c 'cd apps/desktop/src-tauri && cargo build --release'
TARGET="$(nix develop .#windows -c sh -c 'echo $CARGO_TARGET_DIR')/x86_64-pc-windows-gnu/release"
rm -rf "$STAGE"
mkdir -p "$STAGE"
cp "$TARGET/rustscreen.exe" "$TARGET/rustscreen-cli.exe" "$TARGET/WebView2Loader.dll" "$STAGE/"
cp apps/desktop/src-tauri/icons/icon.ico "$STAGE/rustscreen.ico"
cp -r apps/viewer/dist "$STAGE/viewer"
# The debug information doubles the size of the executables.
nix shell nixpkgs#pkgsCross.mingwW64.buildPackages.binutils -c \
x86_64-w64-mingw32-strip "$STAGE/rustscreen.exe" "$STAGE/rustscreen-cli.exe"
echo "installer"
INSTALLER="$OUT/rustscreen-$VERSION-setup.exe"
nix shell nixpkgs#nsis -c makensis -V2 \
-DVERSION="$VERSION" -DSTAGE="$STAGE" -DOUTFILE="$INSTALLER" \
packaging/windows/rustscreen.nsi
ls -l "$INSTALLER"