diff options
| author | ruki <[email protected]> | 2023-11-11 23:04:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-11-11 23:04:34 +0800 |
| commit | f23af7855d5d5d2b2126dd67db0de04e05836c12 (patch) | |
| tree | e20995fccac60bf3977331f6293b2622ef562f86 | |
| parent | fa0ffa6f9266cc6123671c408d09cef210c8448c (diff) | |
improve nsis spec
| -rw-r--r-- | xmake/plugins/pack/nsis/main.lua | 2 | ||||
| -rw-r--r-- | xmake/scripts/xpack/nsis/makensis.nsi | 249 |
2 files changed, 13 insertions, 238 deletions
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua index d30559402..920f447ae 100644 --- a/xmake/plugins/pack/nsis/main.lua +++ b/xmake/plugins/pack/nsis/main.lua @@ -80,7 +80,7 @@ function _pack_nsis(makensis, package, opt) table.insert(argv, "/DMINOR=" .. version:minor()) end if version:patch() then - table.insert(argv, "/DALTER=" .. version:patch()) + table.insert(argv, "/DPATCH=" .. version:patch()) end if version_build then table.insert(argv, "/DBUILD=" .. version_build) diff --git a/xmake/scripts/xpack/nsis/makensis.nsi b/xmake/scripts/xpack/nsis/makensis.nsi index 8f3050557..a8c7b207b 100644 --- a/xmake/scripts/xpack/nsis/makensis.nsi +++ b/xmake/scripts/xpack/nsis/makensis.nsi @@ -1,33 +1,30 @@ -; xmake.nsi -; -; This script is perhaps one of the simplest NSIs you can make. All of the -; optional settings are left to their default settings. The installer simply -; prompts the user asking them where to install, and drops a copy of xmake.nsi -; there. +; this is a NSI spec file, +; it is autogenerated by the xmake build system. +; do not edit by hand. ;-------------------------------- ; includes !include "MUI2.nsh" !include "WordFunc.nsh" !include "WinMessages.nsh" -!include FileFunc.nsh -!include UAC.nsh +!include "FileFunc.nsh" +!include "UAC.nsh" -; xmake version Information +; the version information !ifndef MAJOR - !error 'xmake major version is not defined!' + !define MAJOR 1 !endif !ifndef MINOR - !error 'xmake minor version is not defined!' + !define MINOR 0 !endif -!ifndef ALTER - !error 'xmake alter version is not defined!' +!ifndef PATCH + !define PATCH 0 !endif !ifndef BUILD - !error 'xmake build version is not defined!' + !define BUILD 0 !endif -!define VERSION ${MAJOR}.${MINOR}.${ALTER} +!define VERSION ${MAJOR}.${MINOR}.${PATCH} !define VERSION_FULL ${VERSION}+${BUILD} !ifdef x64 @@ -70,15 +67,6 @@ RequestExecutionLevel user ManifestDPIAware true ;-------------------------------- -; Interface Settings - -!define MUI_ABORTWARNING - -;-------------------------------- -; Icon -!define MUI_ICON "..\core\src\demo\xmake.ico" - -;-------------------------------- ; UAC helper !macro Init thing @@ -154,216 +142,3 @@ VIAddVersionKey /LANG=0 ProductVersion ${VERSION_FULL} !define RegUninstall "Software\Microsoft\Windows\CurrentVersion\Uninstall\XMake" -;-------------------------------- - -Var NOADMIN - -Function TrimQuote - Exch $R1 ; Original string - Push $R2 - -Loop: - StrCpy $R2 "$R1" 1 - StrCmp "$R2" "'" TrimLeft - StrCmp "$R2" "$\"" TrimLeft - StrCmp "$R2" "$\r" TrimLeft - StrCmp "$R2" "$\n" TrimLeft - StrCmp "$R2" "$\t" TrimLeft - StrCmp "$R2" " " TrimLeft - GoTo Loop2 -TrimLeft: - StrCpy $R1 "$R1" "" 1 - Goto Loop - -Loop2: - StrCpy $R2 "$R1" 1 -1 - StrCmp "$R2" "'" TrimRight - StrCmp "$R2" "$\"" TrimRight - StrCmp "$R2" "$\r" TrimRight - StrCmp "$R2" "$\n" TrimRight - StrCmp "$R2" "$\t" TrimRight - StrCmp "$R2" " " TrimRight - GoTo Done -TrimRight: - StrCpy $R1 "$R1" -1 - Goto Loop2 - -Done: - Pop $R2 - Exch $R1 -FunctionEnd - -; Installer -Function .onInit - ${GetOptions} $CMDLINE "/NOADMIN" $NOADMIN - ${If} ${Errors} - !insertmacro Init "installer" - StrCpy $NOADMIN "false" - ${Else} - StrCpy $NOADMIN "true" - ${EndIf} - - ; load from reg - ${If} $InstDir == "" - ${If} $NOADMIN == "false" - ReadRegStr $R0 ${HKLM} ${RegUninstall} "InstallLocation" - ${Else} - ReadRegStr $R0 ${HKCU} ${RegUninstall} "InstallLocation" - ${EndIf} - ${If} $R0 != "" - Push $R0 - Call TrimQuote - Pop $R0 - StrCpy $InstDir $R0 - ${EndIf} - ${EndIf} - ; use default - ${If} $InstDir == "" - StrCpy $InstDir ${PROGRAMFILES}\xmake - ${EndIf} - -FunctionEnd - -Section "Xmake (required)" InstallExeutable - - SectionIn RO - - ; Set output path to the installation directory. - SetOutPath $InstDir - - ; Remove previous directories used - ; https://github.com/xmake-io/xmake/issues/1888 - IfFileExists "$InstDir\xmake.exe" file_found file_not_found_or_end - file_found: - RMDir /r "$InstDir" - goto file_not_found_or_end - file_not_found_or_end: - - ; Put file there - File /r /x ".DS_Store" /x "*.swp" "..\xmake\*.*" - File "..\*.md" - File "..\core\build\xmake.exe" - File "..\scripts\xrepo.bat" - File "..\scripts\xrepo.ps1" - File /r /x ".DS_Store" "..\winenv" - - WriteUninstaller "uninstall.exe" - - !macro AddReg RootKey - - ; Write uac info - WriteRegStr ${RootKey} ${RegUninstall} "NoAdmin" "$NOADMIN" - - ; Write the uninstall keys for Windows - WriteRegStr ${RootKey} ${RegUninstall} "DisplayName" "Xmake build utility (${ARCH})" - WriteRegStr ${RootKey} ${RegUninstall} "DisplayIcon" '"$InstDir\xmake.exe"' - WriteRegStr ${RootKey} ${RegUninstall} "Comments" "A cross-platform build utility based on Lua" - WriteRegStr ${RootKey} ${RegUninstall} "Publisher" "The TBOOX Open Source Group" - WriteRegStr ${RootKey} ${RegUninstall} "UninstallString" '"$InstDir\uninstall.exe"' - WriteRegStr ${RootKey} ${RegUninstall} "QuiteUninstallString" '"$InstDir\uninstall.exe" /S' - WriteRegStr ${RootKey} ${RegUninstall} "InstallLocation" $InstDir - WriteRegStr ${RootKey} ${RegUninstall} "HelpLink" 'https://xmake.io/' - WriteRegStr ${RootKey} ${RegUninstall} "URLInfoAbout" 'https://github.com/xmake-io/xmake' - WriteRegStr ${RootKey} ${RegUninstall} "URLUpdateInfo" 'https://github.com/xmake-io/xmake/releases' - WriteRegDWORD ${RootKey} ${RegUninstall} "VersionMajor" ${MAJOR} - WriteRegDWORD ${RootKey} ${RegUninstall} "VersionMinor" ${MINOR} - WriteRegStr ${RootKey} ${RegUninstall} "DisplayVersion" ${VERSION_FULL} - WriteRegDWORD ${RootKey} ${RegUninstall} "NoModify" 1 - WriteRegDWORD ${RootKey} ${RegUninstall} "NoRepair" 1 - - ;write size to reg - ${GetSize} "$InstDir" "/S=0K" $0 $1 $2 - IntFmt $0 "0x%08X" $0 - WriteRegDWORD ${RootKey} ${RegUninstall} "EstimatedSize" "$0" - !macroend - - ${If} $NOADMIN == "false" - !insertmacro AddReg ${HKLM} - ${Else} - !insertmacro AddReg ${HKCU} - ${EndIf} - -SectionEnd - -Section "Enable Long Path" LongPath - ${If} $NOADMIN == "false" - ; Enable long path - WriteRegDWORD ${HKLM} "SYSTEM\CurrentControlSet\Control\FileSystem" "LongPathsEnabled" 1 - ${EndIf} -SectionEnd - -Section "Add to PATH" InstallPath - - ${If} $NOADMIN == "false" - ; Remove the installation path from the $PATH environment variable first - ReadRegStr $R0 ${HKLM} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" - ${WordReplace} $R0 ";$InstDir" "" "+" $R1 - - ; Write the installation path into the $PATH environment variable - WriteRegExpandStr ${HKLM} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$R1;$InstDir" - ${Else} - ; Remove the installation path from the $PATH environment variable first - ReadRegStr $R0 ${HKCU} "Environment" "Path" - ${WordReplace} $R0 ";$InstDir" "" "+" $R1 - - ; Write the installation path into the $PATH environment variable - WriteRegExpandStr ${HKCU} "Environment" "Path" "$R1;$InstDir" - ${EndIf} - - ; make sure windows knows about the change - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - -SectionEnd - -;-------------------------------- -; Descriptions - -; Language strings -LangString DESC_InstallExeutable ${LANG_ENGLISH} "A cross-platform build utility based on Lua" -LangString DESC_InstallPath ${LANG_ENGLISH} "Add xmake to PATH" -LangString DESC_LongPath ${LANG_ENGLISH} "Increases the maximum path length limit, up to 32,767 characters (before 256). This can be useful if a project has many recursive subfolders to make sure that the project is compiled without errors. A reboot might be required because some processes may have started before the new value was set" - -; Assign language strings to sections -!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN -!insertmacro MUI_DESCRIPTION_TEXT ${InstallExeutable} $(DESC_InstallExeutable) -!insertmacro MUI_DESCRIPTION_TEXT ${InstallPath} $(DESC_InstallPath) -!insertmacro MUI_DESCRIPTION_TEXT ${LongPath} $(DESC_LongPath) -!insertmacro MUI_FUNCTION_DESCRIPTION_END - -;-------------------------------- - -; Uninstaller - -Function un.onInit - ; check if we need uac - ReadRegStr $NOADMIN ${HKLM} ${RegUninstall} "NoAdmin" - IfErrors 0 +2 - ReadRegStr $NOADMIN ${HKCU} ${RegUninstall} "NoAdmin" - - ${IfNot} $NOADMIN == "true" - !insertmacro Init "uninstaller" - ${EndIf} - -FunctionEnd - -Section "Uninstall" - - ; Remove directories used - RMDir /r "$InstDir" - - ; Clean reg - ${If} $NOADMIN == "false" - DeleteRegKey ${HKLM} ${RegUninstall} - ; Remove the installation path from the $PATH environment variable - ReadRegStr $R0 ${HKLM} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" - ${WordReplace} $R0 ";$InstDir" "" "+" $R1 - WriteRegExpandStr ${HKLM} "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$R1" - ${Else} - DeleteRegKey ${HKCU} ${RegUninstall} - ; Remove the installation path from the $PATH environment variable - ReadRegStr $R0 ${HKCU} "Environment" "Path" - ${WordReplace} $R0 ";$InstDir" "" "+" $R1 - WriteRegExpandStr ${HKCU} "Environment" "Path" "$R1" - ${EndIf} - -SectionEnd |
