Skip to content

Commit 8f2b49d

Browse files
committed
improve to find cl
1 parent 63c49fb commit 8f2b49d

File tree

7 files changed

+22
-36
lines changed

7 files changed

+22
-36
lines changed

xmake/modules/detect/tools/find_ar.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ end
5151
-- @endcode
5252
--
5353
function main(opt)
54-
opt = opt or {}
54+
opt = opt or {}
5555
opt.check = opt.check or _check
56+
opt.norunfile = true
5657
return find_program(opt.program or "ar", opt)
5758
end

xmake/modules/detect/tools/find_cl.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ import("lib.detect.find_programver")
3535
-- @endcode
3636
--
3737
function main(opt)
38-
39-
-- init options
40-
opt = opt or {}
41-
opt.check = opt.check or function (program)
38+
opt = opt or {}
39+
opt.norunfile = true
40+
opt.check = opt.check or function (program)
4241
local ok = try { function () os.runv(program, {}, {envs = opt.envs}); return true end }
4342
if not ok then
4443
-- @see https://github.com/xmake-io/xmake/issues/3057

xmake/modules/detect/tools/find_clang_cl.lua

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,10 @@ import("lib.detect.find_programver")
3535
-- @endcode
3636
--
3737
function main(opt)
38-
39-
-- init options
4038
opt = opt or {}
41-
42-
-- find program
43-
local program = find_program(opt.program or "clang-cl.exe", opt)
44-
45-
-- find program version
39+
opt.norunfile = true
4640
local version = nil
41+
local program = find_program(opt.program or "clang-cl.exe", opt)
4742
if program and opt and opt.version then
4843
version = find_programver(program, opt)
4944
end

xmake/modules/detect/tools/find_link.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function main(opt)
4343

4444
-- init options
4545
opt = opt or {}
46+
opt.norunfile = true
4647
opt.check = opt.check or function (program)
4748
local toolchain = opt.toolchain
4849
if toolchain and toolchain:name() == "masm32" then

xmake/modules/detect/tools/find_llvm_ar.lua

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,13 @@ import("lib.detect.find_programver")
3737
-- @endcode
3838
--
3939
function main(opt)
40-
41-
-- init options
4240
opt = opt or {}
41+
opt.norunfile = true
4342
opt.check = opt.check or "-h"
4443
opt.command = opt.command or "--version"
4544

46-
-- find program
47-
local program = find_program(opt.program or "llvm-ar", opt)
48-
49-
-- find program version
5045
local version = nil
46+
local program = find_program(opt.program or "llvm-ar", opt)
5147
if program and opt.version then
5248
version = find_programver(program, opt)
5349
end

xmake/modules/detect/tools/find_ml.lua

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@ import("lib.detect.find_programver")
3535
-- @endcode
3636
--
3737
function main(opt)
38+
opt = opt or {}
39+
opt.norunfile = true
40+
opt.check = opt.check or function (program)
41+
os.runv(program, {}, {envs = opt.envs})
42+
end
3843

39-
-- init options
40-
opt = opt or {}
41-
opt.check = opt.check or function (program) os.runv(program, {}, {envs = opt.envs}) end
42-
43-
-- find program
44-
local program = find_program(opt.program or "ml.exe", opt)
45-
46-
-- find program version
4744
local version = nil
45+
local program = find_program(opt.program or "ml.exe", opt)
4846
if program and opt and opt.version then
4947
opt.command = opt.command or function () local _, info = os.iorunv(program, {}, {envs = opt.envs}); return info end
5048
opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end

xmake/modules/detect/tools/find_ml64.lua

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,19 @@ import("lib.detect.find_programver")
3535
-- @endcode
3636
--
3737
function main(opt)
38+
opt = opt or {}
39+
opt.norunfile = true
40+
opt.check = opt.check or function (program)
41+
os.runv(program, {}, {envs = opt.envs})
42+
end
3843

39-
-- init options
40-
opt = opt or {}
41-
opt.check = opt.check or function (program) os.runv(program, {}, {envs = opt.envs}) end
42-
43-
-- find program
44-
local program = find_program(opt.program or "ml64.exe", opt)
45-
46-
-- find program version
4744
local version = nil
45+
local program = find_program(opt.program or "ml64.exe", opt)
4846
if program and opt and opt.version then
4947
opt.command = opt.command or function () local _, info = os.iorunv(program, {}, {envs = opt.envs}); return info end
5048
opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end
5149
version = find_programver(program, opt)
5250
end
53-
54-
-- ok?
5551
return program, version
5652
end
5753

0 commit comments

Comments
 (0)