summaryrefslogtreecommitdiff
path: root/xmake/plugins/pack/xpack.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-01-09 10:19:14 +0800
committerGitHub <[email protected]>2025-01-09 10:19:14 +0800
commit8e24b5a44dcffbee1444d715909a64014e11e866 (patch)
treea2f0aaf7b582dae30d4db636efd199ccb158e0d8 /xmake/plugins/pack/xpack.lua
parent1cf6a7f479837b471a5f91410359d86983828e6a (diff)
parent6317ffd0fe312360eb5f6e079320c01c95870ad0 (diff)
Merge pull request #6001 from xmake-io/namespace
Support for namespace
Diffstat (limited to 'xmake/plugins/pack/xpack.lua')
-rw-r--r--xmake/plugins/pack/xpack.lua26
1 files changed, 22 insertions, 4 deletions
diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua
index 203fcbe6d..5cd3431a5 100644
--- a/xmake/plugins/pack/xpack.lua
+++ b/xmake/plugins/pack/xpack.lua
@@ -32,13 +32,24 @@ import("filter")
import("xpack_component")
-- define module
-local xpack = xpack or object {_init = {"_name", "_info"}}
+local xpack = xpack or object {_init = {"_name", "_info", "_namespace"}}
-- get name
function xpack:name()
return self._name
end
+-- get namespace
+function xpack:namespace()
+ return self._namespace
+end
+
+-- get fullname
+function xpack:fullname()
+ local namespace = self:namespace()
+ return namespace and namespace .. "::" .. self:name() or self:name()
+end
+
-- get values
function xpack:get(name)
if self._info then
@@ -131,7 +142,7 @@ function xpack:targets()
local targetnames = self:get("targets")
if targetnames then
for _, name in ipairs(targetnames) do
- local target = project.target(name)
+ local target = project.target(name, {namespace = self:namespace()})
if target then
table.insert(targets, target)
else
@@ -148,7 +159,7 @@ end
function xpack:target(name)
local targetnames = self:get("targets")
if targetnames and table.contains(table.wrap(targetnames), name) then
- return project.target(name)
+ return project.target(name, {namespace = self:namespace()})
end
end
@@ -506,7 +517,14 @@ 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:clone()}
+ local parts = name:split("::", {plain = true})
+ name = parts[#parts]
+ table.remove(parts)
+ local namespace
+ if #parts > 0 then
+ namespace = table.concat(parts, "::")
+ end
+ return xpack {name, info:clone(), namespace}
end
-- get xpack packages