Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix find_program ~ don't report errors for failed simple checks #247

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions xmake/core/sandbox/modules/import/lib/detect/find_program.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,15 @@ function sandbox_lib_detect_find_program._check(program, opt)
return os.isfile(program)
end

-- no check script? attempt to run it directly
if not opt.check then
return 0 == os.execv(program, {"--version"}, {stdout = os.nuldev(), stderr = os.nuldev()})
-- no check function? attempt to run it directly
if not opt.check or type(opt.check) ~= "function" then
return 0 == os.execv(program, {opt.check or "--version"}, {stdout = os.nuldev(), stderr = os.nuldev()})
end

-- check it
local ok = false
local errors = nil
if type(opt.check) == "string" then
ok, errors = os.runv(program, {opt.check})
else
ok, errors = sandbox.load(opt.check, program)
end
ok, errors = sandbox.load(opt.check, program)

-- check failed? print verbose error info
if not ok then
Expand Down