summaryrefslogtreecommitdiff
path: root/xmake/core/tool
diff options
context:
space:
mode:
authorruki <[email protected]>2021-02-13 10:37:00 +0800
committerruki <[email protected]>2021-02-13 10:37:00 +0800
commit3e1f4c096a20cadbefa55bc3e38d900845f0ec9c (patch)
tree17e4e95518b1cf2ae9300b153daf5a2b2ba24c36 /xmake/core/tool
parent9f09d39ed2e59a9bf4f1beecee0f79f27645ece3 (diff)
improve toolconfig
Diffstat (limited to 'xmake/core/tool')
-rw-r--r--xmake/core/tool/toolchain.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua
index eb880932e..7a1ca6c05 100644
--- a/xmake/core/tool/toolchain.lua
+++ b/xmake/core/tool/toolchain.lua
@@ -600,5 +600,45 @@ function toolchain.load_withinfo(name, info, opt)
return instance
end
+-- get tool configuration from the toolchains
+function toolchain.toolconfig(toolchains, name, opt)
+
+ -- init tool configs cache
+ opt = opt or {}
+ local toolconfigs = toolchain._TOOLCONFIGS
+ if not toolconfigs then
+ toolconfigs = {}
+ toolchain._TOOLCONFIGS = toolconfigs
+ end
+
+ -- get configuration
+ local cachekey = (opt.cachekey or "") .. name
+ local toolconfig = toolconfigs[cachekey]
+ if toolconfig == nil then
+
+ -- get them from all toolchains
+ for _, toolchain_inst in ipairs(toolchains) do
+ local values = toolchain_inst:get(name)
+ if values then
+ toolconfig = toolconfig or {}
+ table.join2(toolconfig, values)
+ end
+ local after_get = opt.after_get
+ if after_get then
+ values = after_get(toolchain_inst, name)
+ if values then
+ toolconfig = toolconfig or {}
+ table.join2(toolconfig, values)
+ end
+ end
+ end
+
+ -- cache it
+ toolconfig = toolconfig or false
+ toolconfigs[cachekey] = toolconfig
+ end
+ return toolconfig or nil
+end
+
-- return module
return toolchain