Working NSIS generation.

This commit is contained in:
Martin Rotter 2016-06-24 13:01:09 +02:00
parent 506bfab427
commit cd6e5c4a8a
3 changed files with 58 additions and 35 deletions

View file

@ -21,7 +21,9 @@
!define APP_NAME "@APP_NAME@"
!define EXE_NAME "@EXE_NAME@"
!define README_FILE "README"
!define LICENSE_FILE "@PROJECT_SOURCE_DIR@\resources\text\COPYING_GNU_GPL"
!define MUI_ICON "@PROJECT_SOURCE_DIR@\resources\graphics\@APP_LOW_NAME@.ico"
!define MUI_UNICON "@PROJECT_SOURCE_DIR@\resources\graphics\@APP_LOW_NAME@.ico"
!define PATCH "0"
!define LICENSE_FILE "@PWD@\resources\text\COPYING_GNU_GPL"
!define MUI_ICON "@PWD@\resources\graphics\@APP_LOW_NAME@.ico"
!define MUI_UNICON "@PWD@\resources\graphics\@APP_LOW_NAME@.ico"
!define PATCH "0"
!define OUTPUT_FILE "@OUT_PWD@\@APP_LOW_NAME@-@APP_VERSION@-win32.exe"
!define BINARY_TREE "@OUT_PWD@\app"

View file

@ -18,16 +18,15 @@
;--------------------------------
; Do necessary inclusions.
!include ..\..\..\resources\nsis\NSIS.definitions.nsh
!include NSIS.definitions.nsh
!include MUI2.nsh
;--------------------------------
; Basic values definitions.
!define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
; Name and file.
Name "${APP_NAME} portable"
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
OutFile "${OUTPUT_FILE}"
; Set custom branding text.
BrandingText "${APP_NAME}"
@ -36,7 +35,7 @@ BrandingText "${APP_NAME}"
SetCompressor /SOLID /FINAL lzma
; Default installation folder.
InstallDir "@CPACK_NSIS_INSTALL_ROOT@\${APP_NAME}"
InstallDir "$PROGRAMFILES\${APP_NAME}"
InstallDirRegKey HKCU "Software\${APP_NAME}" "Install Directory"
; Require administrator access.
@ -138,7 +137,7 @@ NotInstalled:
SetOutPath "$INSTDIR"
; Install core application files.
@CPACK_NSIS_FULL_INSTALL@
File /r "${BINARY_TREE}\"
; Store installation folder.
WriteRegStr HKCU "Software\${APP_NAME}" "Install Directory" $INSTDIR
@ -172,10 +171,10 @@ Section "Uninstall"
; Here remove all files, but skip "data" folder.
Push "$INSTDIR"
Push "data"
Call RmDirsButOne
Call un.RmDirsButOne
; Remove uninstaller.
Delete "$INSTDIR\Uninstall.exe"
Delete "$INSTDIR\*"
; Remove rest of installed files.
; Custom files are left intact.
@ -193,39 +192,39 @@ SectionEnd
;--------------------------------
; Custom functions.
Function RmDirsButOne
Exch $R0 ; exclude dir
Exch
Exch $R1 ; route dir
Push $R2
Push $R3
Function un.RmDirsButOne
Exch $R0 ; exclude dir
Exch
Exch $R1 ; route dir
Push $R2
Push $R3
ClearErrors
FindFirst $R3 $R2 "$R1\*.*"
IfErrors Exit
Top:
StrCmp $R2 "." Next
StrCmp $R2 ".." Next
StrCmp $R2 $R0 Next
IfFileExists "$R1\$R2\*.*" 0 Next
StrCmp $R2 "." Next
StrCmp $R2 ".." Next
StrCmp $R2 $R0 Next
IfFileExists "$R1\$R2\*.*" 0 Next
RmDir /r "$R1\$R2"
#Goto Exit ;uncomment this to stop it being recursive (delete only one dir)
Next:
#Goto Exit ;uncomment this to stop it being recursive (delete only one dir)
Next:
ClearErrors
FindNext $R3 $R2
IfErrors Exit
Goto Top
Goto Top
Exit:
FindClose $R3
Pop $R3
Pop $R2
Pop $R1
Pop $R0
FindClose $R3
Pop $R3
Pop $R2
Pop $R1
Pop $R0
FunctionEnd
; Executed when installer starts.

View file

@ -462,14 +462,36 @@ QMAKE_EXTRA_COMPILERS += lrelease
# Create new "make 7zip" target and "make zip" target.
win32 {
seven_zip.target = 7zip
seven_zip.depends = install
seven_zip.commands = $$shell_path($$shell_quote($$PWD/resources/scripts/7za/7za.exe)) a -t7z $$TARGET-$$APP_VERSION-win32.7z $$shell_path($$PREFIX/*)
zip.target = zip
zip.depends = install
zip.commands = $$shell_path($$shell_quote($$PWD/resources/scripts/7za/7za.exe)) a -tzip $$TARGET-$$APP_VERSION-win32.zip $$shell_path($$PREFIX/*)
QMAKE_EXTRA_TARGETS += seven_zip zip
}
# Create NSIS installer target on Windows.
win32 {
nsis.target = nsis
nsis.depends = install
nsis.commands = \
$$shell_path($$shell_quote($$PWD/resources/scripts/findreplace/findreplace/bin/Release/findreplace.exe)) @APP_VERSION@ $$shell_quote($$APP_VERSION) @APP_NAME@ $$shell_quote($$APP_NAME) @APP_LOW_NAME@ $$shell_quote($$APP_LOW_NAME) @EXE_NAME@ $$shell_quote($${APP_LOW_NAME}.exe) @PWD@ $$shell_path($$shell_quote($$PWD)) @OUT_PWD@ $$shell_path($$shell_quote($$OUT_PWD)) $$shell_path($$shell_quote($$PWD/resources/nsis/NSIS.definitions.nsh.in)) > $$shell_path($$shell_quote($$OUT_PWD/NSIS.definitions.nsh)) && \
xcopy /Y $$shell_path($$shell_quote($$PWD/resources/nsis/NSIS.template.in)) $$shell_path($$shell_quote($$OUT_PWD/)) && \
$$shell_path($$shell_quote($$PWD/resources/scripts/nsis/makensis.exe)) $$shell_path($$shell_quote($$OUT_PWD/NSIS.template.in))
QMAKE_EXTRA_TARGETS += nsis
}
win32 {
windows_all.target = windows_all
windows_all.depends = seven_zip nsis
windows_all.commands = echo "windows_all done..."
QMAKE_EXTRA_TARGETS += windows_all
}
unix:!mac {
seven_zip.target = 7zip
seven_zip.commands = 7za a -t7z $$TARGET-$$APP_VERSION-win32.7z $$shell_path($$INSTALL_ROOT/*)