summaryrefslogtreecommitdiff
path: root/xmake
diff options
context:
space:
mode:
authorruki <[email protected]>2025-01-07 22:43:17 +0800
committerruki <[email protected]>2025-01-07 22:43:17 +0800
commitc184146581f86d95536dafcadd64e8ae000341f2 (patch)
tree786c1bfd54940bf7fc62dceea09829fc945c9b1c /xmake
parent27b25397a70585921df496503060e3bf04f0f38b (diff)
add namespace for toolchain
Diffstat (limited to 'xmake')
-rw-r--r--xmake/core/project/project.lua4
-rw-r--r--xmake/core/project/target.lua1
-rw-r--r--xmake/core/tool/toolchain.lua18
3 files changed, 22 insertions, 1 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 8afcee6b9..72bec34d5 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -1112,8 +1112,12 @@ end
-- get the given toolchain
function project.toolchain(name, opt)
+ opt = opt or {}
local toolchain_name = toolchain.parsename(name) -- we need to ignore `@packagename`
local info = project._toolchains()[toolchain_name]
+ if info == nil and opt.namespace then
+ info = project._toolchains()[opt.namespace .. "::" .. toolchain_name]
+ end
if info then
return toolchain.load_withinfo(name, info, opt)
end
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 9d5a9c07a..3f1875854 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -2495,6 +2495,7 @@ function _instance:toolchains()
local toolchain_opt = table.copy(self:extraconf("toolchains", name))
toolchain_opt.arch = self:arch()
toolchain_opt.plat = self:plat()
+ toolchain_opt.namespace = self:namespace()
local toolchain_inst, errors = toolchain.load(name, toolchain_opt)
-- attempt to load toolchain from project
if not toolchain_inst and target._project() then
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua
index 29bd5a09f..a19413d34 100644
--- a/xmake/core/tool/toolchain.lua
+++ b/xmake/core/tool/toolchain.lua
@@ -42,7 +42,12 @@ local sandbox_module = require("sandbox/modules/import/core/sandbox/module")
-- new an instance
function _instance.new(name, info, cachekey, is_builtin, configs)
local instance = table.inherit(_instance)
- instance._NAME = name
+ local parts = name:split("::", {plain = true})
+ instance._NAME = parts[#parts]
+ table.remove(parts)
+ if #parts > 0 then
+ instance._NAMESPACE = table.concat(parts, "::")
+ end
instance._INFO = info
instance._IS_BUILTIN = is_builtin
instance._CACHE = toolchain._localcache()
@@ -68,6 +73,17 @@ function _instance:name()
return self._NAME
end
+-- get the namespace
+function _instance:namespace()
+ return self._NAMESPACE
+end
+
+-- get the full name
+function _instance:fullname()
+ local namespace = self:namespace()
+ return namespace and namespace .. "::" .. self:name() or self:name()
+end
+
-- get toolchain platform
function _instance:plat()
return self._PLAT or self:config("plat")