summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-08-11 22:59:49 +0800
committerruki <[email protected]>2023-08-11 22:59:49 +0800
commit704cc78dd4fa1e108f946fc51fcd538ea05d01de (patch)
tree32cece84ccac8ed0931566144136ee2b369cdfbb
parent793c35405c44f43ce6bdadc19f75b3f275f22367 (diff)
improve platform check for target toolchains
-rw-r--r--xmake/actions/config/main.lua14
-rw-r--r--xmake/core/platform/platform.lua6
-rw-r--r--xmake/core/project/target.lua2
3 files changed, 16 insertions, 6 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 47f542706..eaa61f490 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -125,6 +125,14 @@ function _check_target_toolchains()
if target:is_enabled() and (target:get("toolchains") or
not target:is_plat(config.get("plat")) or
not target:is_arch(config.get("arch"))) then
+
+ -- check platform toolchains first
+ -- `target/set_plat()` and target:toolchains() need it
+ local ok, errors = target:platform():check()
+ if not ok then
+ raise(errors)
+ end
+
local target_toolchains = target:get("toolchains")
if target_toolchains then
target_toolchains = hashset.from(table.wrap(target_toolchains))
@@ -134,12 +142,6 @@ function _check_target_toolchains()
raise("toolchain(\"%s\"): not found!", toolchain_inst:name())
end
end
- else
- -- check platform toolchains for `target/set_plat()`
- local ok, errors = target:platform():check()
- if not ok then
- raise(errors)
- end
end
elseif not target:get("toolset") then
-- we only abort it when we know that toolchains of platform and target do not found
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua
index 01d5b0e5e..148120d49 100644
--- a/xmake/core/platform/platform.lua
+++ b/xmake/core/platform/platform.lua
@@ -234,6 +234,10 @@ end
-- do check
function _instance:check()
+ local checked = self._CHECKED
+ if checked ~= nil then
+ return checked
+ end
-- check toolchains
local toolchains = self:toolchains({all = true})
@@ -256,11 +260,13 @@ function _instance:check()
end
end
if #toolchains == 0 then
+ self._CHECKED = false
return false, "toolchains not found!"
end
-- save valid toolchains
config.set("__toolchains_" .. self:name() .. "_" .. self:arch(), toolchains_valid)
+ self._CHECKED = true
return true
end
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index e9a603476..ca46a7b69 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -2101,6 +2101,8 @@ function _instance:toolchains()
-- we always need a standalone toolchain
-- because we maybe only set partial toolchains in target, e.g. nasm toolchain
+ --
+ -- @note platform has been checked in config/_check_target_toolchains
if not has_standalone then
for _, toolchain_inst in ipairs(self:platform():toolchains()) do
if toolchain_inst:is_standalone() then