# NSIS file to create a self-installing exe for Vim.
# It requires NSIS version 3.0 or later.
# Last Change: 2024 Mar 17
Unicode true
# WARNING: if you make changes to this script, look out for $0 to be valid,
# because uninstall deletes most files in $0.
# Location of gvim_ole.exe, vimw32.exe, GvimExt/*, etc.
!ifndef VIMSRC
!define VIMSRC "..\src"
!endif
# Location of runtime files
!ifndef VIMRT
!define VIMRT ".."
!endif
# Location of extra tools: diff.exe
!ifndef VIMTOOLS
!define VIMTOOLS ..\..
!endif
# Location of gettext.
# It must contain two directories: gettext32 and gettext64.
# See README.txt for detail.
!ifndef GETTEXT
!define GETTEXT ${VIMRT}
!endif
# Comment the next line if you don't have UPX.
# Get it at https://upx.github.io/
!define HAVE_UPX
# Comment the next line if you do not want to add Native Language Support
!define HAVE_NLS
# Comment the following line to create an English-only installer:
!define HAVE_MULTI_LANG
# Uncomment the next line if you want to create a 64-bit installer.
#!define WIN64
!include gvim_version.nsh # for version number
# Definition of Patch for Vim
!ifndef PATCHLEVEL
!define PATCHLEVEL 0
!endif
# ----------- No configurable settings below this line -----------
!include "Library.nsh" # For DLL install
!include "LogicLib.nsh"
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!include "Sections.nsh"
!include "x64.nsh"
# See https://nsis.sourceforge.io/LogicLib
;FileExists is already part of LogicLib, but returns true for directories
;as well as files
!macro _FileExists2 _a _b _t _f
!insertmacro _LOGICLIB_TEMP
StrCpy $_LOGICLIB_TEMP "0"
;if path is not blank, continue to next check
StrCmp `${_b}` `` +4 0
;if path exists, continue to next check (IfFileExists returns true if this
;is a directory)
IfFileExists `${_b}` `0` +3
;if path is not a directory, continue to confirm exists
IfFileExists `${_b}\*.*` +2 0
StrCpy $_LOGICLIB_TEMP "1" ;file exists
;now we have a definitive value - the file exists or it does not
StrCmp $_LOGICLIB_TEMP "1" `${_t}` `${_f}`
!macroend
!undef FileExists
!define FileExists `"" FileExists2`
!macro _DirExists _a _b _t _f
!insertmacro _LOGICLIB_TEMP
StrCpy $_LOGICLIB_TEMP "0"
;if path is not blank, continue to next check
StrCmp `${_b}` `` +3 0
;if directory exists, continue to confirm exists
IfFileExists `${_b}\*.*` 0 +2
StrCpy $_LOGICLIB_TEMP "1"
StrCmp $_LOGICLIB_TEMP "1" `${_t}` `${_f}`
!macroend
!define DirExists `"" DirExists`
!define PRODUCT "Vim ${VER_MAJOR}.${VER_MINOR}"
!define UNINST_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
!define UNINST_REG_KEY_VIM "${UNINST_REG_KEY}\${PRODUCT}"
!ifdef WIN64
Name "${PRODUCT} (x64)"
!else
Name "${PRODUCT}"
!endif
OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
CRCCheck force
SetCompressor /SOLID lzma
SetCompressorDictSize 64
ManifestDPIAware true
SetDatablockOptimize on
RequestExecutionLevel highest
!ifdef HAVE_UPX
!packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
!endif
!ifdef WIN64
!define BIT 64
!else
!define BIT 32
!endif
##########################################################
# MUI2 settings
!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING
!define MUI_ICON "icons\vim_16c.ico"
!define MUI_UNICON "icons\vim_uninst_16c.ico"
# Show all languages, despite user's codepage:
!define MUI_LANGDLL_ALLLANGUAGES
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software\Vim"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
!define MUI_WELCOMEFINISHPAGE_BITMAP "icons\welcome.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "icons\uninstall.bmp"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "icons\header.bmp"
!define MUI_HEADERIMAGE_UNBITMAP "icons\un_header.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
!define MUI_HEADERIMAGE_BITMAP_STRETCH "AspectFitHeight"
!define MUI_HEADERIMAGE_UNBITMAP_STRETCH "AspectFitHeight"
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_LICENSEPAGE_CHECKBOX
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION LaunchApplication
!define MUI_FINISHPAGE_RUN_TEXT $(str_show_readme)
# This adds '\Vim' to the user choice automagically. The actual value is
# obtained below with CheckOldVim.
!ifdef WIN64
!define DEFAULT_INSTDIR "$PROGRAMFILES64\Vim"
!else
!define DEFAULT_INSTDIR "$PROGRAMFILES\Vim"
!endif
InstallDir ${DEFAULT_INSTDIR}
# Types of installs we can perform:
InstType $(str_type_typical)
InstType $(str_type_minimal)
InstType $(str_type_full)
SilentInstall normal
# General custom functions for MUI2:
#!define MUI_CUSTOMFUNCTION_ABORT VimOnUserAbort
#!define MUI_CUSTOMFUNCTION_UNABORT un.VimOnUserAbort
# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${VIMRT}\doc\uganda.nsis.txt"
!insertmacro MUI_PAGE_COMPONENTS
Page custom SetCustom ValidateCustom
#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VimFinalCheck
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!insertmacro MUI_PAGE_FINISH
# Uninstaller pages:
!insertmacro MUI_UNPAGE_CONFIRM
#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.VimCheckRunning
!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!insertmacro MUI_UNPAGE_FINISH
##########################################################
# Languages Files
!insertmacro MUI_RESERVEFILE_LANGDLL
!include "lang\english.nsi"
# Include support for other languages:
!ifdef HAVE_MULTI_LANG
!include "lang\danish.nsi"
!include "lang\dutch.nsi"
!include "lang\german.nsi"