summaryrefslogtreecommitdiff
path: root/xmake/plugins/pack/xpack.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-22 00:44:19 +0800
committerruki <[email protected]>2023-11-22 00:44:19 +0800
commit574d9bca0e5d7a01fdf2500ac83c75f5927bb69d (patch)
tree6eee243e73bc7f6f80505ecd97a0683ae9b1f8f1 /xmake/plugins/pack/xpack.lua
parentfaaeb0ccf5d4b56f058cda41aab9c59fb018f8cd (diff)
load xpack components
Diffstat (limited to 'xmake/plugins/pack/xpack.lua')
-rw-r--r--xmake/plugins/pack/xpack.lua35
1 files changed, 28 insertions, 7 deletions
diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua
index 07e162c67..79acbb16a 100644
--- a/xmake/plugins/pack/xpack.lua
+++ b/xmake/plugins/pack/xpack.lua
@@ -497,9 +497,35 @@ function xpack:includedir()
return self:installdir(includedir)
end
--- new a xpack
+-- get the components
+function xpack:components()
+ local components = _g.components
+ if components == nil then
+ components = {}
+ local xpack_component_scope = project.scope("xpack_component")
+ for _, component_name in ipairs(self:get("components")) do
+ local scope = xpack_component_scope[component_name]
+ if scope then
+ local instance = xpack_component.new(component_name, scope, self)
+ components[component_name] = instance
+ else
+ raise("unknown xpack component(%s) in xpack(%s)", component_name, self:name())
+ end
+ end
+ _g.components = components
+ end
+ return components
+end
+
+-- get the given component
+function xpack:component(name)
+ return self:components()[name]
+end
+
+-- new a xpack, and we need to clone scope info,
+-- because two different format packages maybe have same scope
function _new(name, info)
- return xpack {name, info}
+ return xpack {name, info:clone()}
end
-- get xpack packages
@@ -538,8 +564,3 @@ function packages()
end
return packages
end
-
--- get the given package
-function package(name)
- return packages()[name]
-end