diff options
| author | ruki <[email protected]> | 2022-02-10 00:35:08 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-02-10 00:35:08 +0800 |
| commit | 0f3c0abb00dddcb71a0aba5220ef0dd6ed260a24 (patch) | |
| tree | caae5ec29ba39908004ae17329b1ed0410de7c18 | |
| parent | 763c2455abcde109ae9e9a8cbc8d0b81bbc68543 (diff) | |
improve to save toolchain
| -rw-r--r-- | xmake/core/tool/toolchain.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index b20479c61..292e940be 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -301,7 +301,7 @@ end -- save toolchain to file function _instance:savefile(filepath) - return io.save(filepath, self:info():info()) + return io.save(filepath, {name = self:name(), info = self:info():info(), configs = self._CONFIGS}) end -- on check (builtin) @@ -648,14 +648,18 @@ function toolchain.load_withinfo(name, info, opt) end -- load toolchain from file -function toolchain.load_fromfile(name, filepath, opt) +function toolchain.load_fromfile(filepath, opt) local fileinfo, errors = io.load(filepath) if not fileinfo then return nil, errors end + if not fileinfo.name or not fileinfo.info then + return nil, string.format("%s is invalid toolchain info file!", filepath) + end + opt = opt or {} local scope_opt = {interpreter = toolchain._interpreter(), deduplicate = true, enable_filter = true} - local info = scopeinfo.new("toolchain", fileinfo, scope_opt) - return toolchain.load_withinfo(name, info, opt) + local info = scopeinfo.new("toolchain", fileinfo.info, scope_opt) + return toolchain.load_withinfo(fileinfo.name, info, table.join(opt, fileinfo.configs)) end |
