summaryrefslogtreecommitdiff
path: root/xmake/plugins
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-14 00:49:46 +0800
committerruki <[email protected]>2023-11-14 00:49:46 +0800
commited01c2796c2485eb5a9ee6935605985bea6ad5aa (patch)
tree6b5b212a35ebdeb6d2e1a3399c8edb102a3f1f71 /xmake/plugins
parent201d366fbef21d81a00e7bb80f2be384a69cf714 (diff)
add custom cmds
Diffstat (limited to 'xmake/plugins')
-rw-r--r--xmake/plugins/pack/nsis/main.lua35
1 files changed, 30 insertions, 5 deletions
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index f9d6c609b..8058d747c 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -52,6 +52,28 @@ function _get_makensis()
return makensis, oldenvs
end
+-- get install commands
+function _get_installcmds(package)
+ return ""
+end
+
+-- get uninstall commands
+function _get_uninstallcmds(package)
+ return ""
+end
+
+-- get specvars
+function _get_specvars(package)
+ local specvars = table.clone(package:specvars())
+ specvars.PACKAGE_INSTALLCMDS = function ()
+ return _get_installcmds(package)
+ end
+ specvars.PACKAGE_UNINSTALLCMDS = function ()
+ return _get_uninstallcmds(package)
+ end
+ return specvars
+end
+
-- pack nsis package
function _pack_nsis(makensis, package, opt)
@@ -63,13 +85,16 @@ function _pack_nsis(makensis, package, opt)
end
-- replace variables in specfile
- local specvars = package:specvars()
+ local specvars = _get_specvars(package)
local pattern = package:extraconf("specfile", "pattern") or "%${([^\n]-)}"
- io.gsub(specfile, "(" .. pattern .. ")", function(_, variable)
- variable = variable:trim()
- local value = specvars[variable]
+ io.gsub(specfile, "(" .. pattern .. ")", function(_, name)
+ name = name:trim()
+ local value = specvars[name]
+ if type(value) == "function" then
+ value = value()
+ end
if value ~= nil then
- dprint(" > replace %s -> %s", variable, value)
+ dprint(" > replace %s -> %s", name, value)
end
if type(value) == "table" then
dprint("invalid variable value", value)