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 APP_NAME "@APP_NAME@"
!define EXE_NAME "@EXE_NAME@" !define EXE_NAME "@EXE_NAME@"
!define README_FILE "README" !define README_FILE "README"
!define LICENSE_FILE "@PROJECT_SOURCE_DIR@\resources\text\COPYING_GNU_GPL" !define LICENSE_FILE "@PWD@\resources\text\COPYING_GNU_GPL"
!define MUI_ICON "@PROJECT_SOURCE_DIR@\resources\graphics\@APP_LOW_NAME@.ico" !define MUI_ICON "@PWD@\resources\graphics\@APP_LOW_NAME@.ico"
!define MUI_UNICON "@PROJECT_SOURCE_DIR@\resources\graphics\@APP_LOW_NAME@.ico" !define MUI_UNICON "@PWD@\resources\graphics\@APP_LOW_NAME@.ico"
!define PATCH "0" !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. ; Do necessary inclusions.
!include ..\..\..\resources\nsis\NSIS.definitions.nsh !include NSIS.definitions.nsh
!include MUI2.nsh !include MUI2.nsh
;-------------------------------- ;--------------------------------
; Basic values definitions. ; Basic values definitions.
!define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
; Name and file. ; Name and file.
Name "${APP_NAME} portable" Name "${APP_NAME} portable"
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@" OutFile "${OUTPUT_FILE}"
; Set custom branding text. ; Set custom branding text.
BrandingText "${APP_NAME}" BrandingText "${APP_NAME}"
@ -36,7 +35,7 @@ BrandingText "${APP_NAME}"
SetCompressor /SOLID /FINAL lzma SetCompressor /SOLID /FINAL lzma
; Default installation folder. ; Default installation folder.
InstallDir "@CPACK_NSIS_INSTALL_ROOT@\${APP_NAME}" InstallDir "$PROGRAMFILES\${APP_NAME}"
InstallDirRegKey HKCU "Software\${APP_NAME}" "Install Directory" InstallDirRegKey HKCU "Software\${APP_NAME}" "Install Directory"
; Require administrator access. ; Require administrator access.
@ -138,7 +137,7 @@ NotInstalled:
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
; Install core application files. ; Install core application files.
@CPACK_NSIS_FULL_INSTALL@ File /r "${BINARY_TREE}\"
; Store installation folder. ; Store installation folder.
WriteRegStr HKCU "Software\${APP_NAME}" "Install Directory" $INSTDIR WriteRegStr HKCU "Software\${APP_NAME}" "Install Directory" $INSTDIR
@ -172,10 +171,10 @@ Section "Uninstall"
; Here remove all files, but skip "data" folder. ; Here remove all files, but skip "data" folder.
Push "$INSTDIR" Push "$INSTDIR"
Push "data" Push "data"
Call RmDirsButOne Call un.RmDirsButOne
; Remove uninstaller. ; Remove uninstaller.
Delete "$INSTDIR\Uninstall.exe" Delete "$INSTDIR\*"
; Remove rest of installed files. ; Remove rest of installed files.
; Custom files are left intact. ; Custom files are left intact.
@ -193,7 +192,7 @@ SectionEnd
;-------------------------------- ;--------------------------------
; Custom functions. ; Custom functions.
Function RmDirsButOne Function un.RmDirsButOne
Exch $R0 ; exclude dir Exch $R0 ; exclude dir
Exch Exch
Exch $R1 ; route dir Exch $R1 ; route dir

View file

@ -462,14 +462,36 @@ QMAKE_EXTRA_COMPILERS += lrelease
# Create new "make 7zip" target and "make zip" target. # Create new "make 7zip" target and "make zip" target.
win32 { win32 {
seven_zip.target = 7zip 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/*) 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.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/*) 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 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 { unix:!mac {
seven_zip.target = 7zip seven_zip.target = 7zip
seven_zip.commands = 7za a -t7z $$TARGET-$$APP_VERSION-win32.7z $$shell_path($$INSTALL_ROOT/*) seven_zip.commands = 7za a -t7z $$TARGET-$$APP_VERSION-win32.7z $$shell_path($$INSTALL_ROOT/*)