summaryrefslogtreecommitdiff
path: root/xmake/core/tool/toolchain.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-05-26 22:33:23 +0800
committerruki <[email protected]>2023-05-26 22:33:23 +0800
commitd0c5ff95b69965b3ef51d5f54544bd6d81e0d5f8 (patch)
treed8d40c34fd258d4e9987b16a7b50322f71f2a02e /xmake/core/tool/toolchain.lua
parent3bc1882be93ab58f774322b74d19d2fe92bd09e5 (diff)
improve to pass toolchain in tools.xmake #3774
Diffstat (limited to 'xmake/core/tool/toolchain.lua')
-rw-r--r--xmake/core/tool/toolchain.lua20
1 files changed, 19 insertions, 1 deletions
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua
index 87a28cb69..b230bf674 100644
--- a/xmake/core/tool/toolchain.lua
+++ b/xmake/core/tool/toolchain.lua
@@ -278,6 +278,11 @@ function _instance:check()
return checkok
end
+-- do load manually, it will call on_load()
+function _instance:load()
+ self:_load()
+end
+
-- check cross toolchain
function _instance:check_cross_toolchain()
return sandbox_module.import("toolchains.cross.check", {rootdir = os.programdir(), anonymous = true})(self)
@@ -311,7 +316,15 @@ end
-- save toolchain to file
function _instance:savefile(filepath)
- return io.save(filepath, {name = self:name(), info = self:info():info(), cachekey = self:cachekey(), configs = self._CONFIGS})
+ if not self:_is_loaded() then
+ os.raise("we can only save toolchain(%s) after it has been loaded!", self:name())
+ end
+ -- we strip on_load/on_check scripts to solve some issues
+ -- @see https://github.com/xmake-io/xmake/issues/3774
+ local info = table.clone(self:info():info())
+ info.load = nil
+ info.check = nil
+ return io.save(filepath, {name = self:name(), info = info, cachekey = self:cachekey(), configs = self._CONFIGS})
end
-- on check (builtin)
@@ -349,6 +362,11 @@ function _instance:_load()
end
end
+-- is loaded?
+function _instance:_is_loaded()
+ return self:info():get("__loaded")
+end
+
-- get the tool description from the tool kind
function _instance:_description(toolkind)
local descriptions = self._DESCRIPTIONS