diff options
| -rw-r--r-- | xmake/includes/xpack/xmake.lua | 10 | ||||
| -rw-r--r-- | xmake/plugins/pack/main.lua | 16 |
2 files changed, 23 insertions, 3 deletions
diff --git a/xmake/includes/xpack/xmake.lua b/xmake/includes/xpack/xmake.lua index bb7d03435..f7198600d 100644 --- a/xmake/includes/xpack/xmake.lua +++ b/xmake/includes/xpack/xmake.lua @@ -64,13 +64,19 @@ local apis = { script = { -- add custom load script "xpack.on_load", + -- add custom package script before packing package + "xpack.before_package", + -- rewrite custom package script + "xpack.on_package", + -- add custom package script after packing package + "xpack.after_package", -- add custom commands script before installing "xpack.before_installcmd", -- add custom commands script before uninstalling "xpack.before_uninstallcmd", - -- add custom install commands script, we will also get it from target/rules + -- rewrite custom install commands script, we will also get it from target/rules "xpack.on_installcmd", - -- add custom uninstall commands script, we will also get it from target/rules + -- rewrite custom uninstall commands script, we will also get it from target/rules "xpack.on_uninstallcmd", -- add custom commands script after installing "xpack.after_installcmd", diff --git a/xmake/plugins/pack/main.lua b/xmake/plugins/pack/main.lua index dfaac68d8..a0c94f998 100644 --- a/xmake/plugins/pack/main.lua +++ b/xmake/plugins/pack/main.lua @@ -34,11 +34,25 @@ function _load_package(package, format) end end +function _on_package(package) + import(package:format())(package) +end + function _pack_package(package) assert(package:formats(), "xpack(%s): formats not found, please use `set_formats()` to set it.", package:name()) + local scripts = { + package:script("package_before"), + package:script("package", _on_package), + package:script("package_after") + } for _, format in package:formats():keys() do _load_package(package, format) - import(format)(package) + for i = 1, 3 do + local script = scripts[i] + if script ~= nil then + script(package) + end + end end end |
