summaryrefslogtreecommitdiff
path: root/xmake/core/platform/tool.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core/platform/tool.lua')
-rw-r--r--xmake/core/platform/tool.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/xmake/core/platform/tool.lua b/xmake/core/platform/tool.lua
index 36047f410..479d7a38e 100644
--- a/xmake/core/platform/tool.lua
+++ b/xmake/core/platform/tool.lua
@@ -157,19 +157,24 @@ function tool.load(name, root)
local script, errors = loadfile(toolpath)
if script then
- -- load tool
- local tool = script()
+ -- load tool
+ local ok, result = pcall(script)
+ if not ok then
+ utils.error(result)
+ utils.error("load %s failed!", toolpath)
+ assert(false)
+ end
-- init tool
- if tool and tool.init then
- tool:init(name)
+ if result and result.init then
+ result:init(name)
end
-- save tool to the cache
- tool._TOOLS[name] = tool
+ tool._TOOLS[name] = result
-- ok?
- return tool
+ return result
else
utils.error(errors)
utils.error("load %s failed!", toolpath)