diff options
| author | ruki <[email protected]> | 2023-11-14 00:49:46 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-11-14 00:49:46 +0800 |
| commit | ed01c2796c2485eb5a9ee6935605985bea6ad5aa (patch) | |
| tree | 6b5b212a35ebdeb6d2e1a3399c8edb102a3f1f71 | |
| parent | 201d366fbef21d81a00e7bb80f2be384a69cf714 (diff) | |
add custom cmds
| -rw-r--r-- | xmake/plugins/pack/nsis/main.lua | 35 | ||||
| -rw-r--r-- | xmake/scripts/xpack/nsis/makensis.nsi | 6 |
2 files changed, 35 insertions, 6 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) diff --git a/xmake/scripts/xpack/nsis/makensis.nsi b/xmake/scripts/xpack/nsis/makensis.nsi index 26528fce8..358eee744 100644 --- a/xmake/scripts/xpack/nsis/makensis.nsi +++ b/xmake/scripts/xpack/nsis/makensis.nsi @@ -186,7 +186,8 @@ Section "${PACKAGE_NAME} (required)" InstallExeutable goto file_not_found_or_end file_not_found_or_end: - ; install files there + ; add install commands + ${PACKAGE_INSTALLCMDS} ; add uninstaller WriteUninstaller "uninstall.exe" @@ -277,6 +278,9 @@ FunctionEnd Section "Uninstall" + ; add uninstall commands + ${PACKAGE_UNINSTALLCMDS} + ; remove directories used RMDir /r "$InstDir" |
