summaryrefslogtreecommitdiff
path: root/xmake/core/platform/platform.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-19 22:35:36 +0800
committerruki <[email protected]>2020-05-19 09:33:37 +0800
commit5dfb51f3e1c06c07097158153f39c45830029685 (patch)
tree8b0932b4241526189860332e8b49f2db13794c04 /xmake/core/platform/platform.lua
parent694bff5b15ada2850b21ce0588d6963654ab0dc2 (diff)
add envs toolchain
Diffstat (limited to 'xmake/core/platform/platform.lua')
-rw-r--r--xmake/core/platform/platform.lua34
1 files changed, 26 insertions, 8 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua
index 1bb76db92..3e3b537d1 100644
--- a/xmake/core/platform/platform.lua
+++ b/xmake/core/platform/platform.lua
@@ -129,16 +129,34 @@ end
-- get the program and name of the given tool kind
function _instance:tool(toolkind)
- local toolchains = self:toolchains()
- for idx, toolchain_inst in ipairs(toolchains) do
- local program, toolname = toolchain_inst:tool(toolkind)
- if program then
- -- move this toolchain to head
- table.remove(toolchains, idx)
- table.insert(toolchains, 1, toolchain_inst)
- return program, toolname
+
+ -- init tools
+ local tools = self._TOOLS
+ if not tools then
+ tools = {}
+ self._TOOLS = tools
+ end
+
+ -- get tool program
+ local program, toolname
+ local toolinfo = tools[toolkind]
+ if toolinfo == nil then
+ toolinfo = {}
+ local toolchains = self:toolchains()
+ for idx, toolchain_inst in ipairs(toolchains) do
+ program, toolname = toolchain_inst:tool(toolkind)
+ if program then
+ toolinfo[1] = program
+ toolinfo[2] = toolname
+ break
+ end
end
+ tools[toolkind] = toolinfo
+ else
+ program = toolinfo[1]
+ toolname = toolinfo[2]
end
+ return program, toolname
end
-- get tool configuration from the toolchains