diff options
| author | ruki <[email protected]> | 2020-06-20 12:38:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-06-20 12:38:44 +0800 |
| commit | 281e06a020f7704fe998be52a6ecc2711cfd4fb7 (patch) | |
| tree | 7296f3837d062dcdf6031b821dc6ea0ff1c8986d /xmake/modules | |
| parent | 01dd21d4f3bccda1ff18ad1213b959feeaae37eb (diff) | |
improve to find cl/link
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/detect/tools/find_cl.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_lib.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_link.lua | 12 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_ml.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_ml64.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/find_tool.lua | 2 |
6 files changed, 17 insertions, 13 deletions
diff --git a/xmake/modules/detect/tools/find_cl.lua b/xmake/modules/detect/tools/find_cl.lua index 48289cfbc..a6f5d2fa6 100644 --- a/xmake/modules/detect/tools/find_cl.lua +++ b/xmake/modules/detect/tools/find_cl.lua @@ -38,7 +38,7 @@ function main(opt) -- init options opt = opt or {} - opt.check = opt.check or function (program) os.run(program) end + opt.check = opt.check or function (program) os.runv(program, {}, {envs = opt.envs}) end -- find program local program = find_program(opt.program or "cl.exe", opt) diff --git a/xmake/modules/detect/tools/find_lib.lua b/xmake/modules/detect/tools/find_lib.lua index 9c5b4be74..2b65c978b 100644 --- a/xmake/modules/detect/tools/find_lib.lua +++ b/xmake/modules/detect/tools/find_lib.lua @@ -50,9 +50,9 @@ function main(opt) io.writefile(sourcefile, "int test(void)\n{return 0;}") -- check it - os.run("cl -c -Fo%s %s", objectfile, sourcefile) - os.run("link -lib -out:%s %s", libraryfile, objectfile) - verinfo = os.iorun("%s -list %s", program, libraryfile) + os.runv("cl", {"-c", "-Fo" .. objectfile, sourcefile}, {envs = opt.envs}) + os.runv("link", {"-lib", "-out:" .. libraryfile, objectfile}, {envs = opt.envs}) + verinfo = os.iorunv(program, {"-list", libraryfile}, {envs = opt.envs}) -- remove files os.rm(objectfile) diff --git a/xmake/modules/detect/tools/find_link.lua b/xmake/modules/detect/tools/find_link.lua index 71fba5323..5814cba09 100644 --- a/xmake/modules/detect/tools/find_link.lua +++ b/xmake/modules/detect/tools/find_link.lua @@ -21,6 +21,7 @@ -- imports import("lib.detect.find_program") import("lib.detect.find_programver") +import("lib.detect.find_tool") -- find link -- @@ -43,17 +44,20 @@ function main(opt) opt = opt or {} opt.check = opt.check or function (program) + -- find cl + local cl = assert(find_tool("cl", {envs = opt.envs})) + -- make an stub source file local binaryfile = os.tmpfile() .. ".exe" local objectfile = os.tmpfile() .. ".obj" local sourcefile = os.tmpfile() .. ".c" - -- main entry + -- compile sourcefile first io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}") + os.runv(cl.program, {"-c", "-Fo" .. objectfile, sourcefile}, {envs = opt.envs}) - -- check it - os.run("cl -c -Fo%s %s", objectfile, sourcefile) - verinfo = os.iorun("%s -out:%s %s", program, binaryfile, objectfile) + -- do link + verinfo = os.iorunv(program, {"-lib", "-out:" .. binaryfile, objectfile}, {envs = opt.envs}) -- remove files os.rm(objectfile) diff --git a/xmake/modules/detect/tools/find_ml.lua b/xmake/modules/detect/tools/find_ml.lua index dda0da3e1..c5da1eaee 100644 --- a/xmake/modules/detect/tools/find_ml.lua +++ b/xmake/modules/detect/tools/find_ml.lua @@ -38,7 +38,7 @@ function main(opt) -- init options opt = opt or {} - opt.check = opt.check or function (program) os.run(program) end + opt.check = opt.check or function (program) os.runv(program, {}, {envs = opt.envs}) end -- find program local program = find_program(opt.program or "ml.exe", opt) @@ -46,7 +46,7 @@ function main(opt) -- find program version local version = nil if program and opt and opt.version then - opt.command = opt.command or function () local _, info = os.iorun(program); return info end + opt.command = opt.command or function () local _, info = os.iorunv(program, {}, {envs = opt.envs}); return info end opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end version = find_programver(program, opt) end diff --git a/xmake/modules/detect/tools/find_ml64.lua b/xmake/modules/detect/tools/find_ml64.lua index bb2083ae7..f446fbeeb 100644 --- a/xmake/modules/detect/tools/find_ml64.lua +++ b/xmake/modules/detect/tools/find_ml64.lua @@ -38,7 +38,7 @@ function main(opt) -- init options opt = opt or {} - opt.check = opt.check or function (program) os.run(program) end + opt.check = opt.check or function (program) os.runv(program, {}, {envs = opt.envs}) end -- find program local program = find_program(opt.program or "ml64.exe", opt) @@ -46,7 +46,7 @@ function main(opt) -- find program version local version = nil if program and opt and opt.version then - opt.command = opt.command or function () local _, info = os.iorun(program); return info end + opt.command = opt.command or function () local _, info = os.iorunv(program, {}, {envs = opt.envs}); return info end opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end version = find_programver(program, opt) end diff --git a/xmake/modules/lib/detect/find_tool.lua b/xmake/modules/lib/detect/find_tool.lua index 7e40c0b0e..83f543ebf 100644 --- a/xmake/modules/lib/detect/find_tool.lua +++ b/xmake/modules/lib/detect/find_tool.lua @@ -41,7 +41,7 @@ end -- @param name the tool name -- @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 --- force = true, cachekey = "xxx"} +-- force = true, cachekey = "xxx", envs = {PATH = "xxx"}} -- -- @return {name = "", program = "", version = ""} or nil -- |
