summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-17 22:53:23 +0800
committerruki <[email protected]>2023-11-17 22:53:23 +0800
commit65d2bc2cad967c0de7304e00500d99ff13307d21 (patch)
tree8b28cd6f380c0df8d53068e2c335db8daecf37dd
parentcf3afe37b546efb93079fd6314c0769884ca0fb1 (diff)
fix makensis
-rw-r--r--xmake/includes/xpack/xmake.lua4
-rw-r--r--xmake/plugins/pack/nsis/main.lua15
-rw-r--r--xmake/scripts/xpack/nsis/makensis.nsi8
3 files changed, 23 insertions, 4 deletions
diff --git a/xmake/includes/xpack/xmake.lua b/xmake/includes/xpack/xmake.lua
index 9021404f7..901cb160b 100644
--- a/xmake/includes/xpack/xmake.lua
+++ b/xmake/includes/xpack/xmake.lua
@@ -51,7 +51,9 @@ local apis = {
-- set installed include directory, e.g. include
"xpack.set_includedir",
-- set nsis display name
- "xpack.set_nsis_displayname"
+ "xpack.set_nsis_displayname",
+ -- set nsis display icon
+ "xpack.set_nsis_displayicon"
},
paths = {
-- set the spec file path, support the custom variable pattern, e.g. set_specfile("", {pattern = "%${([^\n]-)}"})
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index 3c4fa3bbd..22d63eb30 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -524,6 +524,20 @@ function _get_filter_value(package, name)
return value
end
+-- get target file path
+function _get_target_filepath(package)
+ local targetfile
+ for _, target in ipairs(package:targets()) do
+ if target:is_binary() then
+ targetfile = target:targetfile()
+ break
+ end
+ end
+ if targetfile then
+ return path.normalize(path.join(package:bindir(), path.filename(targetfile)))
+ end
+end
+
-- get specvars
function _get_specvars(package)
local specvars = table.clone(package:specvars())
@@ -537,6 +551,7 @@ function _get_specvars(package)
return _get_uninstallcmds(package)
end
specvars.PACKAGE_NSIS_DISPLAY_NAME = _get_filter_value(package, "nsis_displayname") or package:name()
+ specvars.PACKAGE_NSIS_DISPLAY_ICON = _get_filter_value(package, "nsis_displayicon") or _get_target_filepath(package) or ""
specvars.PACKAGE_NSIS_INSTALL_SECTIONS = function ()
local result = {}
local cmds = package:get("nsis_installcmds")
diff --git a/xmake/scripts/xpack/nsis/makensis.nsi b/xmake/scripts/xpack/nsis/makensis.nsi
index ffcb39c7c..a1827f348 100644
--- a/xmake/scripts/xpack/nsis/makensis.nsi
+++ b/xmake/scripts/xpack/nsis/makensis.nsi
@@ -167,8 +167,8 @@ Function RMDirIfExists
fileDoesNotExist:
FunctionEnd
-Function unRMDirIfExists
-!define unRMDirIfExists '!insertmacro un.RMDirIfExistsCall'
+Function un.RMDirIfExists
+!define unRMDirIfExists '!insertmacro unRMDirIfExistsCall'
!macro unRMDirIfExistsCall _PATH
push '${_PATH}'
Call un.RMDirIfExists
@@ -297,7 +297,9 @@ Section "${PACKAGE_NAME} (required)" InstallExeutable
!macro AddReg RootKey
WriteRegStr ${RootKey} ${RegUninstall} "NoAdmin" "$NoAdmin"
WriteRegStr ${RootKey} ${RegUninstall} "DisplayName" "${PACKAGE_NSIS_DISPLAY_NAME}"
- WriteRegStr ${RootKey} ${RegUninstall} "DisplayIcon" '"$InstDir\${PACKAGE_BINDIR}\${PACKAGE_FILENAME}"' ; TODO
+ !if "${PACKAGE_NSIS_DISPLAY_ICON}" != ""
+ WriteRegStr ${RootKey} ${RegUninstall} "DisplayIcon" '"$InstDir\${PACKAGE_NSIS_DISPLAY_ICON}"'
+ !endif
WriteRegStr ${RootKey} ${RegUninstall} "Comments" "${PACKAGE_DESCRIPTION}"
WriteRegStr ${RootKey} ${RegUninstall} "Publisher" "${PACKAGE_COPYRIGHT}"
WriteRegStr ${RootKey} ${RegUninstall} "UninstallString" '"$InstDir\uninstall.exe"'