summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-12-24 00:23:14 +0800
committerruki <[email protected]>2020-12-24 00:23:14 +0800
commitaaa7d03b06906cb3be220e8b2817ff795569350b (patch)
treeea8c5c655ce7619e37749ff8140863c059d2010c
parent84f4b0127ebe1d646a996ead1ee9127a831dece4 (diff)
improve find_program
-rw-r--r--xmake/core/base/os.lua2
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_program.lua9
2 files changed, 4 insertions, 7 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 62b0c34de..099ceb799 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -764,8 +764,6 @@ function os.iorunv(program, argv, opt)
-- remove the temporary output and error file
os.rm(outfile)
os.rm(errfile)
-
- -- ok?
return ok == 0, outdata, errdata, errors
end
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 a2cd2105e..51cc45e69 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
@@ -55,12 +55,11 @@ function sandbox_lib_detect_find_program._check(program, opt)
-- no check script? attempt to run it directly
if not opt.check then
- local stdout, stderr
- if not option.get("diagnosis") then
- stdout = os.nuldev()
- stderr = os.nuldev()
+ local ok, errors = os.runv(program, {"--version"}, {envs = opt.envs})
+ if not ok and option.get("diagnosis") then
+ utils.cprint("${color.warning}checkinfo: ${clear dim}" .. errors)
end
- return 0 == os.execv(program, {"--version"}, {stdout = stdout, stderr = stderr, envs = opt.envs})
+ return ok
end
-- check it