summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-03-02 00:42:45 +0800
committerruki <[email protected]>2021-03-02 00:42:45 +0800
commit2654dce9ac9d8cfbe30445bcdbe843d912dd16b9 (patch)
treeb9c97b1bada019ae9ff18b33e656035769e0352c
parent8793a25af4513c1b4820105023d45e458fedaaf0 (diff)
fix find_program
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_program.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
index 01b423f10..4e5eadc14 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
@@ -44,7 +44,7 @@ function sandbox_lib_detect_find_program._do_check(program, opt)
-- do not attempt to run program? check it fastly
if opt.norun then
- return os.isfile(program) and program or nil
+ return os.isfile(program)
end
-- no check script? attempt to run it directly
@@ -53,7 +53,7 @@ function sandbox_lib_detect_find_program._do_check(program, opt)
if not ok and option.get("verbose") and option.get("diagnosis") then
utils.cprint("${color.warning}checkinfo: ${clear dim}" .. errors)
end
- return ok and program or nil
+ return ok
end
-- check it
@@ -69,21 +69,25 @@ function sandbox_lib_detect_find_program._do_check(program, opt)
if not ok and option.get("verbose") and option.get("diagnosis") then
utils.cprint("${color.warning}checkinfo: ${clear dim}" .. errors)
end
- return ok and program or nil
+ return ok
end
-- check program
function sandbox_lib_detect_find_program._check(program, opt)
+ local findname = program
if os.subhost() == "windows" then
if not program:endswith(".exe") and not program:endswith(".cmd") and not program:endswith(".bat") then
- program = program .. ".exe"
+ findname = program .. ".exe"
end
elseif os.subhost() == "msys" and os.isfile(program) and os.filesize(program) < 256 then
-- only a sh script on msys2? e.g. c:/msys64/usr/bin/7z
-- we need use sh to wrap it, otherwise os.exec cannot run it
program = "sh " .. program
+ findname = program
+ end
+ if sandbox_lib_detect_find_program._do_check(findname, opt) then
+ return program
end
- return sandbox_lib_detect_find_program._do_check(program, opt)
end
-- find program from the given paths
@@ -203,10 +207,11 @@ function sandbox_lib_detect_find_program._find(name, paths, opt)
-- attempt to find it from the some default $PATH and system directories
local syspaths = {}
+ --[[
local envpaths = os.getenv("PATH")
if envpaths then
table.join2(syspaths, path.splitenv(envpaths))
- end
+ end]]
if os.host() ~= "windows" then
table.insert(syspaths, "/usr/local/bin")
table.insert(syspaths, "/usr/bin")