add :check_cpppath option to check_c_header and check_cxx_header
configuration methods add :check_d_import_path option to check_d_import configuration method - #107
This commit is contained in:
parent
3aac190ad6
commit
6e590b62a6
10
build_tests/configure/check_c_header_cpppath.rb
Normal file
10
build_tests/configure/check_c_header_cpppath.rb
Normal file
@ -0,0 +1,10 @@
|
||||
configure do
|
||||
check_c_header "string.h", check_cpppath: ["./usr1"]
|
||||
check_c_header "frobulous.h", check_cpppath: ["./usr2"]
|
||||
end
|
||||
|
||||
build do
|
||||
Environment.new do |env|
|
||||
env.Object("test.o", "test.c")
|
||||
end
|
||||
end
|
10
build_tests/configure/check_cxx_header_cpppath.rb
Normal file
10
build_tests/configure/check_cxx_header_cpppath.rb
Normal file
@ -0,0 +1,10 @@
|
||||
configure do
|
||||
check_cxx_header "string.h", check_cpppath: ["./usr1"]
|
||||
check_cxx_header "frobulous.h", check_cpppath: ["./usr2"]
|
||||
end
|
||||
|
||||
build do
|
||||
Environment.new do |env|
|
||||
env.Object("test.o", "test.cc")
|
||||
end
|
||||
end
|
10
build_tests/configure/check_d_import_d_import_path.rb
Normal file
10
build_tests/configure/check_d_import_d_import_path.rb
Normal file
@ -0,0 +1,10 @@
|
||||
configure do
|
||||
check_d_import "std.stdio", check_d_import_path: ["./usr1"]
|
||||
check_d_import "frobulous", check_d_import_path: ["./usr2"]
|
||||
end
|
||||
|
||||
build do
|
||||
Environment.new do |env|
|
||||
env.Object("test.o", "test.d")
|
||||
end
|
||||
end
|
@ -127,6 +127,7 @@ module Rscons
|
||||
|
||||
# Check for a C header.
|
||||
def check_c_header(header_name, options = {})
|
||||
check_cpppath = [nil] + (options[:check_cpppath] || [])
|
||||
Ansi.write($stdout, "Checking for C header '", :cyan, header_name, :reset, "'... ")
|
||||
File.open("#{@work_dir}/cfgtest.c", "wb") do |fh|
|
||||
fh.puts <<-EOF
|
||||
@ -142,13 +143,27 @@ module Rscons
|
||||
"_TARGET" => "#{@work_dir}/cfgtest.o",
|
||||
"_DEPFILE" => "#{@work_dir}/cfgtest.mf",
|
||||
}
|
||||
command = BasicEnvironment.new.build_command("${CCCMD}", vars)
|
||||
_, _, status = log_and_test_command(command)
|
||||
status = 1
|
||||
check_cpppath.each do |cpppath|
|
||||
env = BasicEnvironment.new
|
||||
if cpppath
|
||||
env["CPPPATH"] += Array(cpppath)
|
||||
end
|
||||
command = env.build_command("${CCCMD}", vars)
|
||||
_, _, status = log_and_test_command(command)
|
||||
if status == 0
|
||||
if cpppath
|
||||
store_append({"CPPPATH" => Array(cpppath)}, options)
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
common_config_checks(status, options)
|
||||
end
|
||||
|
||||
# Check for a C++ header.
|
||||
def check_cxx_header(header_name, options = {})
|
||||
check_cpppath = [nil] + (options[:check_cpppath] || [])
|
||||
Ansi.write($stdout, "Checking for C++ header '", :cyan, header_name, :reset, "'... ")
|
||||
File.open("#{@work_dir}/cfgtest.cxx", "wb") do |fh|
|
||||
fh.puts <<-EOF
|
||||
@ -164,13 +179,27 @@ module Rscons
|
||||
"_TARGET" => "#{@work_dir}/cfgtest.o",
|
||||
"_DEPFILE" => "#{@work_dir}/cfgtest.mf",
|
||||
}
|
||||
command = BasicEnvironment.new.build_command("${CXXCMD}", vars)
|
||||
_, _, status = log_and_test_command(command)
|
||||
status = 1
|
||||
check_cpppath.each do |cpppath|
|
||||
env = BasicEnvironment.new
|
||||
if cpppath
|
||||
env["CPPPATH"] += Array(cpppath)
|
||||
end
|
||||
command = env.build_command("${CXXCMD}", vars)
|
||||
_, _, status = log_and_test_command(command)
|
||||
if status == 0
|
||||
if cpppath
|
||||
store_append({"CPPPATH" => Array(cpppath)}, options)
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
common_config_checks(status, options)
|
||||
end
|
||||
|
||||
# Check for a D import.
|
||||
def check_d_import(d_import, options = {})
|
||||
check_d_import_path = [nil] + (options[:check_d_import_path] || [])
|
||||
Ansi.write($stdout, "Checking for D import '", :cyan, d_import, :reset, "'... ")
|
||||
File.open("#{@work_dir}/cfgtest.d", "wb") do |fh|
|
||||
fh.puts <<-EOF
|
||||
@ -186,8 +215,21 @@ module Rscons
|
||||
"_TARGET" => "#{@work_dir}/cfgtest.o",
|
||||
"_DEPFILE" => "#{@work_dir}/cfgtest.mf",
|
||||
}
|
||||
command = BasicEnvironment.new.build_command("${DCCMD}", vars)
|
||||
_, _, status = log_and_test_command(command)
|
||||
status = 1
|
||||
check_d_import_path.each do |d_import_path|
|
||||
env = BasicEnvironment.new
|
||||
if d_import_path
|
||||
env["D_IMPORT_PATH"] += Array(d_import_path)
|
||||
end
|
||||
command = env.build_command("${DCCMD}", vars)
|
||||
_, _, status = log_and_test_command(command)
|
||||
if status == 0
|
||||
if d_import_path
|
||||
store_append({"D_IMPORT_PATH" => Array(d_import_path)}, options)
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
common_config_checks(status, options)
|
||||
end
|
||||
|
||||
|
@ -1835,6 +1835,21 @@ EOF
|
||||
expect(result.status).to eq 0
|
||||
expect(result.stdout).to_not match /-DHAVE_/
|
||||
end
|
||||
|
||||
it "modifies CPPPATH based on check_cpppath" do
|
||||
test_dir "configure"
|
||||
FileUtils.mkdir_p("usr1")
|
||||
FileUtils.mkdir_p("usr2")
|
||||
File.open("usr2/frobulous.h", "wb") do |fh|
|
||||
fh.puts("#define FOO 42")
|
||||
end
|
||||
result = run_rscons(rsconscript: "check_c_header_cpppath.rb", op: "configure")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
result = run_rscons(rsconscript: "check_c_header_cpppath.rb", rscons_args: %w[-v])
|
||||
expect(result.stdout).to_not match %r{-I./usr1}
|
||||
expect(result.stdout).to match %r{-I./usr2}
|
||||
end
|
||||
end
|
||||
|
||||
context "check_cxx_header" do
|
||||
@ -1861,6 +1876,21 @@ EOF
|
||||
expect(result.status).to eq 0
|
||||
expect(result.stdout).to match /Checking for C\+\+ header 'not___found\.h'... not found/
|
||||
end
|
||||
|
||||
it "modifies CPPPATH based on check_cpppath" do
|
||||
test_dir "configure"
|
||||
FileUtils.mkdir_p("usr1")
|
||||
FileUtils.mkdir_p("usr2")
|
||||
File.open("usr2/frobulous.h", "wb") do |fh|
|
||||
fh.puts("#define FOO 42")
|
||||
end
|
||||
result = run_rscons(rsconscript: "check_cxx_header_cpppath.rb", op: "configure")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
result = run_rscons(rsconscript: "check_cxx_header_cpppath.rb", rscons_args: %w[-v])
|
||||
expect(result.stdout).to_not match %r{-I./usr1}
|
||||
expect(result.stdout).to match %r{-I./usr2}
|
||||
end
|
||||
end
|
||||
|
||||
context "check_d_import" do
|
||||
@ -1887,6 +1917,21 @@ EOF
|
||||
expect(result.status).to eq 0
|
||||
expect(result.stdout).to match /Checking for D import 'not\.found'... not found/
|
||||
end
|
||||
|
||||
it "modifies D_IMPORT_PATH based on check_d_import_path" do
|
||||
test_dir "configure"
|
||||
FileUtils.mkdir_p("usr1")
|
||||
FileUtils.mkdir_p("usr2")
|
||||
File.open("usr2/frobulous.d", "wb") do |fh|
|
||||
fh.puts("int foo = 42;")
|
||||
end
|
||||
result = run_rscons(rsconscript: "check_d_import_d_import_path.rb", op: "configure")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
result = run_rscons(rsconscript: "check_d_import_d_import_path.rb", rscons_args: %w[-v])
|
||||
expect(result.stdout).to_not match %r{-I./usr1}
|
||||
expect(result.stdout).to match %r{-I./usr2}
|
||||
end
|
||||
end
|
||||
|
||||
context "check_lib" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user