Skip to content

Commit 63c49fb

Browse files
committed
improve to find gcc/clang
1 parent f9e895a commit 63c49fb

File tree

5 files changed

+7
-1
lines changed

5 files changed

+7
-1
lines changed

xmake/core/sandbox/modules/import/lib/detect/find_program.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ function sandbox_lib_detect_find_program._do_check(program, opt)
4343
-- do not attempt to run program? check it fastly
4444
if opt.norun then
4545
return os.isfile(program)
46+
elseif opt.norunfile and path.is_absolute(program) and os.isfile(program) then
47+
return true
4648
end
4749

4850
-- no check script? attempt to run it directly
@@ -295,6 +297,7 @@ end
295297
-- - opt.paths the program paths (e.g. dirs, paths, winreg paths, script paths)
296298
-- - opt.check the check script or command
297299
-- - opt.norun do not attempt to run program to check program fastly
300+
-- - opt.norunfile do not attempt to run program to check program if it's valid file path.
298301
-- - opt.system true: only find it from system, false: only find it from xmake/packages
299302
--
300303
-- @return the program name or path

xmake/modules/detect/tools/find_clang.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import("lib.detect.find_programver")
3737
--
3838
function main(opt)
3939
opt = opt or {}
40+
opt.norunfile = true
4041
local program = find_program(opt.program or "clang", opt)
4142
local version = nil
4243
if program and opt and opt.version then

xmake/modules/detect/tools/find_clangxx.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import("lib.detect.find_programver")
3737
--
3838
function main(opt)
3939
opt = opt or {}
40+
opt.norunfile = true
4041
local program = find_program(opt.program or "clang++", opt)
4142
local version = nil
4243
if program and opt and opt.version then

xmake/modules/detect/tools/find_gcc.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ end
5353
--
5454
function main(opt)
5555
opt = opt or {}
56+
opt.norunfile = true
5657
local program = find_program(opt.program or "gcc", opt)
5758
local version = nil
5859
if program and opt.version then

xmake/modules/detect/tools/find_gxx.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ import("detect.tools.find_gcc")
3737
-- @endcode
3838
--
3939
function main(opt)
40-
4140
opt = opt or {}
41+
opt.norunfile = true
4242
local program = find_program(opt.program or "g++", opt)
4343
local version = nil
4444
if program and opt and opt.version then

0 commit comments

Comments
 (0)