summaryrefslogtreecommitdiff
path: root/xmake/scripts/tools/tools.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/scripts/tools/tools.lua')
-rw-r--r--xmake/scripts/tools/tools.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/xmake/scripts/tools/tools.lua b/xmake/scripts/tools/tools.lua
index 09e43dc94..4c0d0da14 100644
--- a/xmake/scripts/tools/tools.lua
+++ b/xmake/scripts/tools/tools.lua
@@ -101,6 +101,12 @@ function tools.load(name, root)
-- check
assert(name)
+ -- get it directly from cache dirst
+ tools._TOOLS = tools._TOOLS or {}
+ if tools._TOOLS[name] then
+ return tools._TOOLS[name]
+ end
+
-- find the tool file path
local toolpath = tools.find(name, root)
@@ -121,10 +127,18 @@ function tools.load(name, root)
tool.init()
end
+ -- save tool to the cache
+ tools._TOOLS[name] = tool
+
-- ok?
return tool
end
end
+-- get the given tool from the current platform
+function tools.get(name)
+ return tools.load(platform.tool(name))
+end
+
-- return module: tools
return tools