Skip to content

Commit

Permalink
support namespace for xpack
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jan 7, 2025
1 parent e5ea7bc commit 9021afe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 0 additions & 2 deletions xmake/core/base/interpreter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ end

-- merge the current root values to the previous scope
function interpreter:_merge_root_scope(root, root_prev, override)

-- merge it
root_prev = root_prev or {}
for scope_kind_and_name, _ in pairs(root or {}) do
-- only merge sub-scope for each kind("target@@xxxx") or __rootkind
Expand Down
26 changes: 22 additions & 4 deletions xmake/plugins/pack/xpack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9021afe

Please sign in to comment.