Output a better error when pkg-config is not found - close #169

This commit is contained in:
Josh Holtrop 2023-09-08 21:04:28 -04:00
parent b490daa480
commit a7b962c11a
3 changed files with 18 additions and 1 deletions

View File

@ -0,0 +1,5 @@
ENV["PATH"] = ""
configure do
check_cfg package: "mypackage"
end

View File

@ -125,7 +125,12 @@ module Rscons
elsif program = options[:program]
Ansi.write($stdout, "Checking '", :cyan, program, :reset, "'... ")
end
program ||= "pkg-config"
unless program
program = "pkg-config"
unless Util.find_executable(program)
raise RsconsError.new("Error: executable '#{program}' not found")
end
end
args = options[:args] || %w[--cflags --libs]
command = [program, *args, package].compact
stdout, _, status = log_and_test_command(command)

View File

@ -2369,6 +2369,13 @@ EOF
expect(result.stdout).to_not match /gcc.*-o.*myconfigtest1.*-DMYPACKAGE/
expect(result.stdout).to match /gcc.*-o.*myconfigtest2.*-DMYPACKAGE/
end
it "indicates that pkg-config command cannot be found" do
test_dir "configure"
result = run_rscons(args: %w[-f check_cfg_no_pkg_config.rb configure])
expect(result.stderr).to match /Error: executable 'pkg-config' not found/
expect(result.status).to_not eq 0
end
end
context "when passed a program" do