Skip to content

Commit

Permalink
improve windows installer
Browse files Browse the repository at this point in the history
  • Loading branch information
Spydr06 committed Oct 15, 2023
1 parent 02f53d4 commit b7e1452
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ gtk4-rs/
*.zip
*.AppImage
*.lrsmod
*.exe
11 changes: 11 additions & 0 deletions make-dist.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ $shortcut = "logicrs.lnk"
$target = ".\target\release\$executable"
$zip_name = "logicrs-win64.zip"
$strip_debug_script = "strip-debug-symbols.ps1"
$installer = "logicrs-windows-x86_64-installer.exe"

function Create-Shortcut {
param (
Expand Down Expand Up @@ -50,6 +51,7 @@ Push-Location $dir
Test-Remove -Path $zip_name
Test-Remove -Path "$dist_dir\$shortcut"
Test-Remove -Path "$dist_dir\bin\$executable"
Test-Remove -Path $installer

# compile for release
cargo rustc --release -- -Clink-args="-Wl,--subsystem,windows"
Expand Down Expand Up @@ -101,4 +103,13 @@ Push-Location $dir
else {
Write-Output "Info: Created distributable package $zip_name."
}

Write-Output "Info: Generating Installer using NSIS."

$snippets_dir = "snippets"
makensis.exe "$snippets_dir\installer.nsi"

Move-Item -Path "$snippets_dir\$installer" -Destination $installer

Write-Output "Info: Generated $installer."
Pop-Location # script directory
53 changes: 53 additions & 0 deletions snippets/installer.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
!include "MUI2.nsh"

!define MUI_ABORTWARNING
!define MUI_ICON "..\windows-dist\share\logicrs.ico"

Var StartMenuFolder

Name "LogicRs"
Outfile "logicrs-windows-x86_64-installer.exe"
Unicode True
InstallDir "C:\Program Files\logicrs"

!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
!insertmacro MUI_PAGE_DIRECTORY

!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Modern UI Test"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Section "Install"
SetOutPath $INSTDIR
File /r "..\windows-dist\*.*"

WriteRegStr HKCU "Software\LogicRs" "" "$INSTDIR"
WriteUninstaller "$INSTDIR\uninstall.exe"


!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\LogicRs.lnk" "$INSTDIR\bin\logicrs.exe"
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\uninstall.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd

Section "Uninstall"
Delete "$INSTDIR\*.*"
RMDir /r "$INSTDIR"

!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
Delete "$SMPROGRAMS\$StartMenuFolder\LogicRs.lnk"
Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
RmDir "$SMPROGRAMS\$StartMenuFolder"

DeleteRegKey /ifempty HKCU "Software\LogicRs"
SectionEnd
7 changes: 0 additions & 7 deletions snippets/win-script.nsi

This file was deleted.

0 comments on commit b7e1452

Please sign in to comment.