summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-08-11 22:43:02 +0800
committerruki <[email protected]>2023-08-11 22:43:02 +0800
commite9bb721deae72ae84f0f262b673496dbd60a08bd (patch)
tree9e12cba2618dfff68b5b8df636d7dd83e56965ce
parent40f70328407b66a02fb45484ec290703317fa654 (diff)
fix target toolchains
-rw-r--r--xmake/actions/config/main.lua2
-rw-r--r--xmake/core/project/target.lua16
2 files changed, 16 insertions, 2 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 47f542706..30150f81f 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -130,7 +130,7 @@ function _check_target_toolchains()
target_toolchains = hashset.from(table.wrap(target_toolchains))
for _, toolchain_inst in pairs(target:toolchains()) do
-- check toolchains for `target/set_toolchains()`
- if not toolchain_inst:check() and target_toolchains:has(toolchain_inst:name()) then
+ if target_toolchains:has(toolchain_inst:name()) and not toolchain_inst:check() then
raise("toolchain(\"%s\"): not found!", toolchain_inst:name())
end
end
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index efebba746..4d4bf94dc 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -2078,6 +2078,7 @@ function _instance:toolchains()
-- load target toolchains first
toolchains = {}
+ local has_standalone = false
local target_toolchains = self:get("toolchains")
if target_toolchains then
for _, name in ipairs(table.wrap(target_toolchains)) do
@@ -2092,13 +2093,26 @@ function _instance:toolchains()
if not toolchain_inst then
os.raise(errors)
end
+ if toolchain_inst:is_standalone() then
+ has_standalone = true
+ end
table.insert(toolchains, toolchain_inst)
end
end
-- we need merge target and platform toolchains,
-- because we maybe only set partial toolchains in target, e.g. nasm toolchain
- table.join2(toolchains, self:platform():toolchains())
+ for _, toolchain_inst in ipairs(self:platform():toolchains()) do
+ if toolchain_inst:is_standalone() then
+ -- we can only add one standalone toolchain
+ if not has_standalone then
+ table.insert(toolchains, toolchain_inst)
+ end
+ has_standalone = true
+ else
+ table.insert(toolchains, toolchain_inst)
+ end
+ end
self:_memcache():set("toolchains", toolchains)
end