diff options
| author | ruki <[email protected]> | 2017-06-14 23:04:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-14 23:04:41 +0800 |
| commit | d8f66856927cb9575be311a2102c8a6ad1deea51 (patch) | |
| tree | 33b0421fe6ecb67229ab50e0655d539655cdef1c /xmake/modules/lib/detect/find_tool.lua | |
| parent | ac365d846275293099f0f4dc76c1988995be2b26 (diff) | |
improve find_tool and os.execv
Diffstat (limited to 'xmake/modules/lib/detect/find_tool.lua')
| -rw-r--r-- | xmake/modules/lib/detect/find_tool.lua | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/xmake/modules/lib/detect/find_tool.lua b/xmake/modules/lib/detect/find_tool.lua index 9d4a54635..f04b06602 100644 --- a/xmake/modules/lib/detect/find_tool.lua +++ b/xmake/modules/lib/detect/find_tool.lua @@ -31,7 +31,7 @@ function _find_from_modules(name, opt) -- "detect.tool.find_xxx" exists? if os.isfile(path.join(os.programdir(), "modules", "detect", "tool", "find_" .. name .. ".lua")) then - local find_tool = import("detect.tool.find_" .. name, {anonymous = true}) + local find_tool = import("detect.tool.find_" .. name) if find_tool then return find_tool(opt) end @@ -41,18 +41,19 @@ end -- find tool -- -- @param name the tool name --- @param opt the options, .e.g {pathes = {"/usr/bin"}, check = function (tool) os.run("%s -h", tool) end, version = true} +-- @param opt the options, .e.g {program = "xcrun -sdk macosx clang", pathes = {"/usr/bin"}, check = function (tool) os.run("%s -h", tool) end, version = true} -- -- @return the tool name or path, version -- -- @code -- --- local tool = find_tool("ccache") --- local tool = find_tool("ccache", {pathes = {"/usr/bin", "/usr/local/bin"}}) --- local tool = find_tool("ccache", {check= "--help"}) -- simple check command: ccache --help --- local tool = find_tool("ccache", {check = function (tool) os.run("%s -h", tool) end}) --- local tool = find_tool("ccache", {pathes = {"$(env PATH)", "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger)"}}) --- local tool = find_tool("ccache", {pathes = {"$(env PATH)", function () return "/usr/bin"end}}) +-- local tool = find_tool("clang") +-- local tool = find_tool("clang", {program = "xcrun -sdk macosx clang"}) +-- local tool = find_tool("clang", {pathes = {"/usr/bin", "/usr/local/bin"}}) +-- local tool = find_tool("clang", {check= "--help"}) -- simple check command: ccache --help +-- local tool = find_tool("clang", {check = function (tool) os.run("%s -h", tool) end}) +-- local tool = find_tool("clang", {pathes = {"$(env PATH)", "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger)"}}) +-- local tool = find_tool("clang", {pathes = {"$(env PATH)", function () return "/usr/bin"end}}) -- local tool, version = find_tool("ccache", {version = true}) -- -- @endcode @@ -69,7 +70,7 @@ function main(name, opt) end -- find tool - tool = find_program(name, opt.pathes, opt.check) + tool = find_program(opt.program or name, opt.pathes, opt.check) -- find tool version local version = nil |
