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/detect/tools/find_link.lua | |
| parent | 01dd21d4f3bccda1ff18ad1213b959feeaae37eb (diff) | |
improve to find cl/link
Diffstat (limited to 'xmake/modules/detect/tools/find_link.lua')
| -rw-r--r-- | xmake/modules/detect/tools/find_link.lua | 12 |
1 files changed, 8 insertions, 4 deletions
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) |
