Skip to content

Commit dfe41c4

Browse files
committed
improve to check toolchain state
1 parent 57df37f commit dfe41c4

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

xmake/core/tool/toolchain.lua

+12-4
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ end
208208

209209
-- get the program and name of the given tool kind
210210
function _instance:tool(toolkind)
211+
assert(self:_is_checked())
211212
-- ensure to do load for initializing toolset first
212213
-- @note we cannot call self:check() here, because it can only be called on config
213214
self:_load()
@@ -270,7 +271,8 @@ end
270271
-- do check, we only check it once for all architectures
271272
function _instance:check()
272273
local checkok = true
273-
if not self._CHECKED then
274+
local checked = self:_is_checked()
275+
if not checked then
274276
local on_check = self:_on_check()
275277
if on_check then
276278
local ok, results_or_errors = sandbox.load(on_check, self)
@@ -280,7 +282,9 @@ function _instance:check()
280282
os.raise(results_or_errors)
281283
end
282284
end
283-
self._CHECKED = true
285+
-- we need to persist this state
286+
self:config_set("__checked", true)
287+
self:configs_save()
284288
end
285289
return checkok
286290
end
@@ -374,6 +378,11 @@ function _instance:_is_loaded()
374378
return self:info():get("__loaded")
375379
end
376380

381+
-- is checked?
382+
function _instance:_is_checked()
383+
return self:config("__checked") == true
384+
end
385+
377386
-- get the tool description from the tool kind
378387
function _instance:_description(toolkind)
379388
local descriptions = self._DESCRIPTIONS
@@ -708,8 +717,6 @@ function toolchain.load_fromfile(filepath, opt)
708717
local scope_opt = {interpreter = toolchain._interpreter(), deduplicate = true, enable_filter = true}
709718
local info = scopeinfo.new("toolchain", fileinfo.info, scope_opt)
710719
local instance = toolchain.load_withinfo(fileinfo.name, info, opt)
711-
-- we need to skip check
712-
instance._CHECKED = true
713720
return instance
714721
end
715722

@@ -800,6 +807,7 @@ function toolchain.toolconfig(toolchains, name, opt)
800807
local toolconfig = cache:get2(cachekey, name)
801808
if toolconfig == nil then
802809
for _, toolchain_inst in ipairs(toolchains) do
810+
assert(toolchain_inst:_is_checked())
803811
local values = toolchain_inst:get(name)
804812
if values then
805813
toolconfig = toolconfig or {}

0 commit comments

Comments
 (0)