implement ConfigureOp#check_cxx_header
This commit is contained in:
parent
6bb0a55a55
commit
85b0111a6e
3
build_tests/configure/check_cxx_header_failure.rb
Normal file
3
build_tests/configure/check_cxx_header_failure.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
configure do
|
||||||
|
check_cxx_header "not___found.h"
|
||||||
|
end
|
3
build_tests/configure/check_cxx_header_no_fail.rb
Normal file
3
build_tests/configure/check_cxx_header_no_fail.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
configure do
|
||||||
|
check_cxx_header "not___found.h", fail: false
|
||||||
|
end
|
3
build_tests/configure/check_cxx_header_success.rb
Normal file
3
build_tests/configure/check_cxx_header_success.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
configure do
|
||||||
|
check_cxx_header "string.h"
|
||||||
|
end
|
@ -99,6 +99,11 @@ module Rscons
|
|||||||
co.check_c_header(*cch)
|
co.check_c_header(*cch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if cchs = @script.check_cxx_headers
|
||||||
|
cchs.each do |cch|
|
||||||
|
co.check_cxx_header(*cch)
|
||||||
|
end
|
||||||
|
end
|
||||||
rescue ConfigureOp::ConfigureFailure
|
rescue ConfigureOp::ConfigureFailure
|
||||||
rv = 1
|
rv = 1
|
||||||
end
|
end
|
||||||
|
@ -119,6 +119,27 @@ module Rscons
|
|||||||
common_config_checks(status, options)
|
common_config_checks(status, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check for a C++ header.
|
||||||
|
def check_cxx_header(header_name, options = {})
|
||||||
|
$stdout.write("Checking for C++ header '#{header_name}'... ")
|
||||||
|
File.open("#{@work_dir}/cfgtest.cxx", "wb") do |fh|
|
||||||
|
fh.puts <<-EOF
|
||||||
|
#include "#{header_name}"
|
||||||
|
int main(int argc, char * argv[]) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
end
|
||||||
|
vars = {
|
||||||
|
"LD" => "${CXX}",
|
||||||
|
"_SOURCES" => "#{@work_dir}/cfgtest.cxx",
|
||||||
|
"_TARGET" => "#{@work_dir}/cfgtest.exe",
|
||||||
|
}
|
||||||
|
command = @env.build_command("${LDCMD}", vars)
|
||||||
|
_, _, status = log_and_test_command(command)
|
||||||
|
common_config_checks(status, options)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Test a C compiler.
|
# Test a C compiler.
|
||||||
|
@ -1646,6 +1646,32 @@ EOF
|
|||||||
expect(result.stdout).to match /Checking for C header 'not___found\.h'... not found/
|
expect(result.stdout).to match /Checking for C header 'not___found\.h'... not found/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "check_cxx_header" do
|
||||||
|
it "succeeds when the requested header is found" do
|
||||||
|
test_dir "configure"
|
||||||
|
result = run_rscons(rsconsfile: "check_cxx_header_success.rb", op: "configure")
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(result.status).to eq 0
|
||||||
|
expect(result.stdout).to match /Checking for C\+\+ header 'string\.h'... found/
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fails when the requested header is not found" do
|
||||||
|
test_dir "configure"
|
||||||
|
result = run_rscons(rsconsfile: "check_cxx_header_failure.rb", op: "configure")
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(result.status).to_not eq 0
|
||||||
|
expect(result.stdout).to match /Checking for C\+\+ header 'not___found\.h'... not found/
|
||||||
|
end
|
||||||
|
|
||||||
|
it "succeeds when the requested header is not found but :fail is set to false" do
|
||||||
|
test_dir "configure"
|
||||||
|
result = run_rscons(rsconsfile: "check_cxx_header_no_fail.rb", op: "configure")
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(result.status).to eq 0
|
||||||
|
expect(result.stdout).to match /Checking for C\+\+ header 'not___found\.h'... not found/
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user