summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-22 22:35:52 +0800
committerruki <[email protected]>2023-11-22 22:35:52 +0800
commit98179c982c6d67a88e6918959d8c434fdbbe7a25 (patch)
treee43859d61a081f4a5d92fb52d92ea50526979c2c
parent72eaaf884bd49781a783ea4c65b52e322fb5419d (diff)
install xpack component
-rw-r--r--xmake/plugins/pack/main.lua10
-rw-r--r--xmake/plugins/pack/nsis/main.lua13
-rw-r--r--xmake/plugins/pack/xpack_component.lua26
3 files changed, 44 insertions, 5 deletions
diff --git a/xmake/plugins/pack/main.lua b/xmake/plugins/pack/main.lua
index 76cc77912..3f145cf86 100644
--- a/xmake/plugins/pack/main.lua
+++ b/xmake/plugins/pack/main.lua
@@ -27,6 +27,12 @@ import("actions.build.main", {rootdir = os.programdir(), alias = "build_action"}
import("xpack")
function _load_package(package)
+
+ -- ensure build and output directories
+ os.tryrm(package:buildir())
+ os.mkdir(package:outputdir())
+
+ -- load it
local script = package:script("load")
if script then
script(package)
@@ -39,10 +45,6 @@ end
function _pack_package(package)
- -- ensure build and output directories
- os.tryrm(package:buildir())
- os.mkdir(package:outputdir())
-
-- get need formats
local formats_need = option.get("formats")
if formats_need then
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index 282b20a2d..e44d41d8b 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -152,6 +152,16 @@ function _get_commands_string(package, cmds, opt)
return table.concat(cmdstrs, "\n ")
end
+-- get install commands of component
+function _get_component_installcmds(component)
+ return _get_commands_string(component, batchcmds.get_installcmds(component):cmds(), {install = true})
+end
+
+-- get uninstall commands of component
+function _get_component_uninstallcmds(component)
+ return _get_commands_string(component, batchcmds.get_uninstallcmds(component):cmds(), {install = false})
+end
+
-- get install commands
function _get_installcmds(package)
return _get_commands_string(package, batchcmds.get_installcmds(package):cmds(), {install = true})
@@ -211,8 +221,9 @@ function _get_specvars(package)
local result = {}
for name, component in table.orderpairs(package:components()) do
local tag = "Install" .. name
+ local cmd = _get_component_installcmds(component)
table.insert(result, string.format('Section "%s" %s', component:title(), tag))
- -- TODO add commands
+ table.insert(result, cmd)
table.insert(result, "SectionEnd")
end
return table.concat(result, "\n ")
diff --git a/xmake/plugins/pack/xpack_component.lua b/xmake/plugins/pack/xpack_component.lua
index bb274d08a..59d2fae8f 100644
--- a/xmake/plugins/pack/xpack_component.lua
+++ b/xmake/plugins/pack/xpack_component.lua
@@ -240,6 +240,32 @@ function xpack_component:installfiles()
return self:_copiedfiles("installfiles", self:package():installdir())
end
+-- get the root directory, this is just a temporary sandbox installation path,
+-- we may replace it with the actual installation path in the specfile
+function xpack_component:rootdir()
+ return self:package():rootdir()
+end
+
+-- get the installed directory
+function xpack_component:installdir(...)
+ return self:package():installdir(...)
+end
+
+-- get the binary directory
+function xpack_component:bindir()
+ return self:package():bindir()
+end
+
+-- get the library directory
+function xpack_component:libdir()
+ return self:package():libdir()
+end
+
+-- get the include directory
+function xpack_component:includedir()
+ return self:package():includedir()
+end
+
-- new a xpack_component
function new(name, info, package)
return xpack_component {name, info:clone(), package}