From c49ea40ddf9440343edb684ae227708fe81c4f09 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 20 May 2023 10:43:53 +1000 Subject: [PATCH] Automatically add NSIS plugins as part of the bundle process Avoids the need to manually copy them into place --- build/configure/src/bundle.rs | 8 +++++++- qt/bundle/win/anki.template.nsi | 14 ++++++++++---- qt/bundle/win/src/main.rs | 5 +++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/build/configure/src/bundle.rs b/build/configure/src/bundle.rs index 860276698..a2caad4dd 100644 --- a/build/configure/src/bundle.rs +++ b/build/configure/src/bundle.rs @@ -110,11 +110,17 @@ const LINUX_QT_PLUGINS: OnlineArchive = OnlineArchive { sha256: "66bb568aca7242bc55ad419bf5c96755ca15d2a743e1c3a09cba8b83230b138b", }; +const NSIS_PLUGINS: OnlineArchive = OnlineArchive { + url: "https://github.com/ankitects/anki-bundle-extras/releases/download/anki-2023-05-19/nsis.tar.zst", + sha256: "6133f730ece699de19714d0479c73bc848647d277e9cc80dda9b9ebe532b40a8", +}; + fn download_dist_folder_deps(build: &mut Build) -> Result<()> { let mut bundle_deps = vec![":wheels"]; if cfg!(windows) { download_and_extract(build, "win_amd64_audio", WIN_AUDIO, empty_manifest())?; - bundle_deps.push(":extract:win_amd64_audio"); + download_and_extract(build, "nsis_plugins", NSIS_PLUGINS, empty_manifest())?; + bundle_deps.extend([":extract:win_amd64_audio", ":extract:nsis_plugins"]); } else if cfg!(target_os = "macos") { if targetting_macos_arm() { download_and_extract(build, "mac_arm_audio", MAC_ARM_AUDIO, empty_manifest())?; diff --git a/qt/bundle/win/anki.template.nsi b/qt/bundle/win/anki.template.nsi index 6d8df5d82..730cbc444 100644 --- a/qt/bundle/win/anki.template.nsi +++ b/qt/bundle/win/anki.template.nsi @@ -1,12 +1,18 @@ ;; This installer was written many years ago, and it is probably worth investigating modern -;; installer alternatives. +;; installer alternatives at one point. + +!addplugindir . !include "fileassoc.nsh" !include WinVer.nsh !include x64.nsh -; must be installed into NSIS install location -; can be found on https://github.com/ankitects/anki-bundle-extras/releases/tag/anki-2022-02-09 -!include nsProcess.nsh + +!define nsProcess::FindProcess `!insertmacro nsProcess::FindProcess` + +!macro nsProcess::FindProcess _FILE _ERR + nsProcess::_FindProcess /NOUNLOAD `${_FILE}` + Pop ${_ERR} +!macroend ;-------------------------------- diff --git a/qt/bundle/win/src/main.rs b/qt/bundle/win/src/main.rs index 04d4d3c42..1eb1472de 100644 --- a/qt/bundle/win/src/main.rs +++ b/qt/bundle/win/src/main.rs @@ -100,6 +100,11 @@ fn build_installer( bundle_root.join("fileassoc.nsh"), include_str!("../fileassoc.nsh"), )?; + #[cfg(windows)] + fs::write( + bundle_root.join("nsProcess.dll"), + include_bytes!("../../../../out/extracted/nsis_plugins/nsProcess.dll"), + )?; let mut cmd = Command::new("c:/program files (x86)/nsis/makensis.exe"); cmd.arg("-V3"); if uninstaller {