summaryrefslogtreecommitdiff
path: root/xmake
diff options
context:
space:
mode:
authorruki <[email protected]>2025-01-07 00:40:57 +0800
committerruki <[email protected]>2025-01-07 00:40:57 +0800
commitae8a596c609e01b21caa5825f3fd2eec0bdb7507 (patch)
tree20ab76b862913222a52c932d5688eb9c0dc176b3 /xmake
parentf6904d729ce7ca99fad237e5e0641ee015b97faf (diff)
support for inner namespace access
Diffstat (limited to 'xmake')
-rw-r--r--xmake/actions/build/build.lua2
-rw-r--r--xmake/actions/build/build_files.lua3
-rw-r--r--xmake/actions/config/main.lua9
-rw-r--r--xmake/actions/package/local/main.lua2
-rw-r--r--xmake/actions/package/remote/main.lua2
-rw-r--r--xmake/core/base/private/instance_deps.lua12
-rw-r--r--xmake/core/project/project.lua11
-rw-r--r--xmake/core/project/target.lua12
-rw-r--r--xmake/plugins/project/make/makefile.lua2
-rw-r--r--xmake/plugins/project/ninja/build_ninja.lua2
-rw-r--r--xmake/plugins/project/vsxmake/getinfo.lua2
11 files changed, 44 insertions, 15 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua
index f4b371de7..28a33db78 100644
--- a/xmake/actions/build/build.lua
+++ b/xmake/actions/build/build.lua
@@ -217,7 +217,7 @@ function _add_batchjobs_for_target_and_deps(batchjobs, rootjob, target, jobrefs,
jobrefs[target:name()] = job_build_after
jobrefs_before[target:name()] = job_build_before
for _, depname in ipairs(target:get("deps")) do
- local dep = project.target(depname)
+ local dep = project.target(depname, {namespace = target:namespace()})
local targetjob = job_build
-- @see https://github.com/xmake-io/xmake/discussions/2500
if dep:policy("build.across_targets_in_parallel") == false then
diff --git a/xmake/actions/build/build_files.lua b/xmake/actions/build/build_files.lua
index f5604f0bd..ad85d8b2a 100644
--- a/xmake/actions/build/build_files.lua
+++ b/xmake/actions/build/build_files.lua
@@ -106,7 +106,8 @@ function _add_batchjobs_for_target_and_deps(batchjobs, rootjob, jobrefs, target,
jobrefs[target:name()] = targetjob_root
if not option.get("shallow") then
for _, depname in ipairs(target:get("deps")) do
- _add_batchjobs_for_target_and_deps(batchjobs, targetjob, jobrefs, project.target(depname), filepatterns)
+ _add_batchjobs_for_target_and_deps(batchjobs, targetjob, jobrefs,
+ project.target(depname, {namespace = target:namespace()}), filepatterns)
end
end
end
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 9f0cc08fd..0f69142a5 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -102,12 +102,11 @@ end
-- check target
function _check_target(target, checked_targets)
- if not checked_targets[target:name()] then
- checked_targets[target:name()] = target
+ if not checked_targets[target:fullname()] then
+ checked_targets[target:fullname()] = target
for _, depname in ipairs(target:get("deps")) do
- assert(depname ~= target:name(), "the target(%s) cannot depend self!", depname)
- local deptarget = project.target(depname)
- assert(deptarget, "unknown target(%s) for %s.deps!", depname, target:name())
+ local deptarget = project.target(depname, {namespace = target:namespace()})
+ assert(deptarget, "unknown target(%s) for %s.deps!", depname, target:fullname())
_check_target(deptarget, checked_targets)
end
end
diff --git a/xmake/actions/package/local/main.lua b/xmake/actions/package/local/main.lua
index 42133b142..3035946ff 100644
--- a/xmake/actions/package/local/main.lua
+++ b/xmake/actions/package/local/main.lua
@@ -30,7 +30,7 @@ import("target.action.install")
function _get_librarydeps(target)
local librarydeps = {}
for _, depname in ipairs(target:get("deps")) do
- local dep = project.target(depname)
+ local dep = project.target(depname, {namespace = target:namespace()})
if not ((target:is_binary() or target:is_shared()) and dep:is_static()) then
table.insert(librarydeps, dep:name():lower())
end
diff --git a/xmake/actions/package/remote/main.lua b/xmake/actions/package/remote/main.lua
index f73126618..58c89b302 100644
--- a/xmake/actions/package/remote/main.lua
+++ b/xmake/actions/package/remote/main.lua
@@ -30,7 +30,7 @@ import("core.base.bit")
function _get_librarydeps(target)
local librarydeps = {}
for _, depname in ipairs(target:get("deps")) do
- local dep = project.target(depname)
+ local dep = project.target(depname, {namespace = target:namespace()})
if not ((target:is_binary() or target:is_shared()) and dep:is_static()) then
table.insert(librarydeps, dep:name():lower())
end
diff --git a/xmake/core/base/private/instance_deps.lua b/xmake/core/base/private/instance_deps.lua
index 17145ac6f..2c9c1a7e2 100644
--- a/xmake/core/base/private/instance_deps.lua
+++ b/xmake/core/base/private/instance_deps.lua
@@ -46,6 +46,12 @@ function instance_deps.load_deps(instance, instances, deps, orderdeps, depspath,
-- @see https://github.com/xmake-io/xmake/issues/3144
local depname = plaindeps[total + 1 - idx]
local depinst = instances[depname]
+ if depinst == nil and instance.namespace then
+ local namespace = instance:namespace()
+ if namespace then
+ depinst = instances[namespace .. "::" .. depname]
+ end
+ end
if depinst then
local continue_walk = true
if walkdep then
@@ -79,6 +85,12 @@ function instance_deps._sort_instance(instance, instances, orderinstances, insta
instancerefs[instance:name()] = true
for _, depname in ipairs(table.wrap(instance:get("deps"))) do
local depinst = instances[depname]
+ if depinst == nil and instance.namespace then
+ local namespace = instance:namespace()
+ if namespace then
+ depinst = instances[namespace .. "::" .. depname]
+ end
+ end
if depinst then
local depspath_sub
if depspath then
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 77793d3e5..f395f5f6b 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -911,9 +911,16 @@ function project.is_loaded()
end
-- get the given target
-function project.target(name)
+function project.target(name, opt)
+ opt = opt or {}
local targets = project.targets()
- return targets and targets[name]
+ if targets then
+ local t = targets[name]
+ if not t and opt.namespace then
+ t = targets[opt.namespace .. "::" .. name]
+ end
+ return t
+ end
end
-- add the given target, @note if the target name is the same, it will be replaced
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 2669875b5..eed55c0bf 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -257,6 +257,9 @@ function _instance:_build_deps()
-- @see https://github.com/xmake-io/xmake/issues/4689
instance_deps.load_deps(self, instances, {}, self._INHERITDEPS, {self:fullname()}, function (t, dep)
local depinherit = t:extraconf("deps", dep:name(), "inherit")
+ if depinherit == nil then
+ depinherit = t:extraconf("deps", dep:fullname(), "inherit")
+ end
return depinherit == nil or depinherit
end)
end
@@ -1107,7 +1110,14 @@ end
function _instance:dep(name)
local deps = self:deps()
if deps then
- return deps[name]
+ local dep = deps[name]
+ if dep == nil then
+ local namespace = self:namespace()
+ if namespace then
+ dep = deps[namespace .. "::" .. name]
+ end
+ end
+ return dep
end
end
diff --git a/xmake/plugins/project/make/makefile.lua b/xmake/plugins/project/make/makefile.lua
index 12b1b77e0..3d4d5507f 100644
--- a/xmake/plugins/project/make/makefile.lua
+++ b/xmake/plugins/project/make/makefile.lua
@@ -547,7 +547,7 @@ function _add_build_target(makefile, target, targetflags, outputdir)
-- make dependence for the dependent targets
for _, depname in ipairs(target:get("deps")) do
- local dep = project.target(depname)
+ local dep = project.target(depname, {namespace = target:namespace()})
makefile:write(" " .. (dep:is_phony() and depname or _get_relative_unix_path(dep:targetfile(), outputdir)))
end
diff --git a/xmake/plugins/project/ninja/build_ninja.lua b/xmake/plugins/project/ninja/build_ninja.lua
index 1264ed60c..94d6495ef 100644
--- a/xmake/plugins/project/ninja/build_ninja.lua
+++ b/xmake/plugins/project/ninja/build_ninja.lua
@@ -367,7 +367,7 @@ function _add_build_for_target(ninjafile, target, outputdir)
ninjafile:print(" || $")
ninjafile:write(" ")
for _, dep in ipairs(deps) do
- ninjafile:write(" " .. _get_relative_unix_path(project.target(dep):targetfile(), outputdir))
+ ninjafile:write(" " .. _get_relative_unix_path(project.target(dep, {namespace = target:namespace()}):targetfile(), outputdir))
end
end
ninjafile:print("")
diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua
index e566ab160..12d6497c0 100644
--- a/xmake/plugins/project/vsxmake/getinfo.lua
+++ b/xmake/plugins/project/vsxmake/getinfo.lua
@@ -585,7 +585,7 @@ function main(outputdir, vsinfo)
if target:get("default") == true then
table.insert(targetnames, 1, targetname)
elseif target:is_binary() then
- local first_target = targetnames[1] and project.target(targetnames[1])
+ local first_target = targetnames[1] and project.target(targetnames[1], {namespace = target:namespace()})
if not first_target or first_target:get("default") ~= true then
table.insert(targetnames, 1, targetname)
else