summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-08-14 23:15:15 +0800
committerruki <[email protected]>2024-08-23 08:14:31 +0800
commitdfe41c4f149feb3fd1d9460313bd5b9dc87e0ec3 (patch)
tree24974d2d6b2a6d8e54805352ad22787c43a63df9
parent57df37f3d8e15a74cf9148471ba0cf6d13a11c53 (diff)
improve to check toolchain state
-rw-r--r--xmake/core/tool/toolchain.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua
index be4e82810..bfd90e88c 100644
--- a/xmake/core/tool/toolchain.lua
+++ b/xmake/core/tool/toolchain.lua
@@ -208,6 +208,7 @@ end
-- get the program and name of the given tool kind
function _instance:tool(toolkind)
+ assert(self:_is_checked())
-- ensure to do load for initializing toolset first
-- @note we cannot call self:check() here, because it can only be called on config
self:_load()
@@ -270,7 +271,8 @@ end
-- do check, we only check it once for all architectures
function _instance:check()
local checkok = true
- if not self._CHECKED then
+ local checked = self:_is_checked()
+ if not checked then
local on_check = self:_on_check()
if on_check then
local ok, results_or_errors = sandbox.load(on_check, self)
@@ -280,7 +282,9 @@ function _instance:check()
os.raise(results_or_errors)
end
end
- self._CHECKED = true
+ -- we need to persist this state
+ self:config_set("__checked", true)
+ self:configs_save()
end
return checkok
end
@@ -374,6 +378,11 @@ function _instance:_is_loaded()
return self:info():get("__loaded")
end
+-- is checked?
+function _instance:_is_checked()
+ return self:config("__checked") == true
+end
+
-- get the tool description from the tool kind
function _instance:_description(toolkind)
local descriptions = self._DESCRIPTIONS
@@ -708,8 +717,6 @@ function toolchain.load_fromfile(filepath, opt)
local scope_opt = {interpreter = toolchain._interpreter(), deduplicate = true, enable_filter = true}
local info = scopeinfo.new("toolchain", fileinfo.info, scope_opt)
local instance = toolchain.load_withinfo(fileinfo.name, info, opt)
- -- we need to skip check
- instance._CHECKED = true
return instance
end
@@ -800,6 +807,7 @@ function toolchain.toolconfig(toolchains, name, opt)
local toolconfig = cache:get2(cachekey, name)
if toolconfig == nil then
for _, toolchain_inst in ipairs(toolchains) do
+ assert(toolchain_inst:_is_checked())
local values = toolchain_inst:get(name)
if values then
toolconfig = toolconfig or {}