maolan 0.2.3

Rust DAW application for recording, editing, routing, automation, export, and plugin hosting
; Maolan DAW Installer
; Run with: makensis.exe installer.nsi
; Requires all binaries and DLLs to be staged in C:\maolan-staging\daw

Unicode true

!include "MUI2.nsh"
!include "LogicLib.nsh"

!ifndef MAOLAN_VERSION
!define MAOLAN_VERSION "0.2.1"
!endif

!ifndef MAOLAN_PRODUCT_VERSION
!define MAOLAN_PRODUCT_VERSION "${MAOLAN_VERSION}.0"
!endif

;--------------------------------
; General
;--------------------------------
Name "Maolan"
OutFile "maolan-setup.exe"
InstallDir "$LOCALAPPDATA\Maolan"
InstallDirRegKey HKCU "Software\Maolan" "InstallDir"
RequestExecutionLevel user

;--------------------------------
; Version Info
;--------------------------------
VIProductVersion "${MAOLAN_PRODUCT_VERSION}"
VIAddVersionKey "ProductName" "Maolan"
VIAddVersionKey "ProductVersion" "${MAOLAN_VERSION}"
VIAddVersionKey "FileVersion" "${MAOLAN_VERSION}"
VIAddVersionKey "FileDescription" "Maolan Digital Audio Workstation"
VIAddVersionKey "LegalCopyright" "BSD-2-Clause"

;--------------------------------
; Interface Settings
;--------------------------------
!define MUI_ABORTWARNING
!ifndef MAOLAN_ICON
!define MAOLAN_ICON "..\images\maolan-icon.ico"
!endif
!define MUI_ICON "${MAOLAN_ICON}"
!define MUI_UNICON "${MAOLAN_ICON}"

;--------------------------------
; Pages
;--------------------------------
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH

;--------------------------------
; Languages
;--------------------------------
!insertmacro MUI_LANGUAGE "English"

;--------------------------------
; Installer Sections
;--------------------------------
Section "Install"
    SetOutPath "$INSTDIR"

    ; Copy all staged binaries and DLLs
    File "C:\maolan-staging\daw\*.*"

    ; Run VC++ Redistributable installer
    ExecWait '"$INSTDIR\vc_redist.x64.exe" /install /quiet /norestart' $0
    Delete "$INSTDIR\vc_redist.x64.exe"

    ; Store installation folder
    WriteRegStr HKCU "Software\Maolan" "InstallDir" $INSTDIR

    ; Create uninstaller
    WriteUninstaller "$INSTDIR\Uninstall.exe"

    ; Add to Add/Remove Programs
    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Maolan" \
        "DisplayName" "Maolan"
    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Maolan" \
        "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Maolan" \
        "DisplayVersion" "${MAOLAN_VERSION}"
    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Maolan" \
        "Publisher" "Maolan Team"
    WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Maolan" \
        "NoModify" 1
    WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Maolan" \
        "NoRepair" 1

    ; Create Start Menu shortcuts
    CreateDirectory "$SMPROGRAMS\Maolan"
    CreateShortcut "$SMPROGRAMS\Maolan\Maolan.lnk" "$INSTDIR\maolan.exe" "" "$INSTDIR\maolan.exe" 0
    CreateShortcut "$SMPROGRAMS\Maolan\Maolan CLI.lnk" "$INSTDIR\maolan-cli.exe" "" "$INSTDIR\maolan-cli.exe" 0
    CreateShortcut "$SMPROGRAMS\Maolan\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0

    ; Create desktop shortcut
    CreateShortcut "$DESKTOP\Maolan.lnk" "$INSTDIR\maolan.exe" "" "$INSTDIR\maolan.exe" 0
SectionEnd

;--------------------------------
; Uninstaller Section
;--------------------------------
Section "Uninstall"
    Delete "$INSTDIR\maolan.exe"
    Delete "$INSTDIR\maolan-cli.exe"
    Delete "$INSTDIR\maolan-plugin-host.exe"
    Delete "$INSTDIR\avcodec-62.dll"
    Delete "$INSTDIR\avdevice-62.dll"
    Delete "$INSTDIR\avfilter-11.dll"
    Delete "$INSTDIR\avformat-62.dll"
    Delete "$INSTDIR\avutil-60.dll"
    Delete "$INSTDIR\swresample-6.dll"
    Delete "$INSTDIR\Uninstall.exe"

    Delete "$SMPROGRAMS\Maolan\Maolan.lnk"
    Delete "$SMPROGRAMS\Maolan\Maolan CLI.lnk"
    Delete "$SMPROGRAMS\Maolan\Uninstall.lnk"
    RMDir "$SMPROGRAMS\Maolan"

    Delete "$DESKTOP\Maolan.lnk"

    DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Maolan"
    DeleteRegKey HKCU "Software\Maolan"

    RMDir "$INSTDIR"
SectionEnd