From c0c3afe1700b97f5317f2b6c472ace7dd47477fd Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 5 Dec 2018 18:05:23 +0100 Subject: [PATCH] NSIS: automatically compute install size --- install/WinInstaller.nsi | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/install/WinInstaller.nsi b/install/WinInstaller.nsi index 6e193d39..6c1a9e29 100644 --- a/install/WinInstaller.nsi +++ b/install/WinInstaller.nsi @@ -4,8 +4,6 @@ !define VERSION 2.5.1946 !define API sdl -!define INSTALLSIZE 10072 - !define FREETYPEDLL libfreetype-6.dll !define JPEGDLL libjpeg-9.dll !define PNGDLL libpng16-16.dll @@ -85,6 +83,13 @@ FunctionEnd ;-------------------------------- ;Installer Sections +Section "Desktop shortcut" SecShortcut + + SetOutPath "$INSTDIR" + CreateShortCut "$DESKTOP\Grafx2-${API}.lnk" "$INSTDIR\bin\grafx2-${API}.exe" "" "" "" SW_SHOWNORMAL + +SectionEnd + Section "Grafx2" SecProgram SectionIn RO SetOutPath "$INSTDIR" @@ -148,8 +153,13 @@ Section "Grafx2" SecProgram WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-${API}" \ "NoRepair" 1 # Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size + SectionGetSize ${SecProgram} $0 + ${If} ${SectionIsSelected} ${SecShortcut} + SectionGetSize ${SecShortcut} $1 + IntOp $0 $0 + $1 + ${EndIf} WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-${API}" \ - "EstimatedSize" ${INSTALLSIZE} + "EstimatedSize" $0 ;Store installation folder WriteRegStr HKLM "Software\Grafx2" "" $INSTDIR @@ -159,13 +169,6 @@ Section "Grafx2" SecProgram SectionEnd -Section "Desktop shortcut" SecShortcut - - SetOutPath "$INSTDIR" - CreateShortCut "$DESKTOP\Grafx2-${API}.lnk" "$INSTDIR\bin\grafx2-${API}.exe" "" "" "" SW_SHOWNORMAL - -SectionEnd - ;-------------------------------- ;Descriptions