add specs testing configure :set_define option and fix the same
This commit is contained in:
parent
dff80587ac
commit
b88131eb2f
@ -0,0 +1,7 @@
|
||||
configure do
|
||||
check_c_header "not___found.h", fail: false, set_define: "HAVE_NOT___FOUND_H"
|
||||
end
|
||||
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.Object("simple.o", "simple.c")
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
configure do
|
||||
check_c_header "string.h", set_define: "HAVE_STRING_H"
|
||||
end
|
||||
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.Object("simple.o", "simple.c")
|
||||
end
|
@ -398,6 +398,9 @@ module Rscons
|
||||
success_message = options[:success_message] || "found"
|
||||
if status == 0
|
||||
Ansi.write($stdout, :green, "#{success_message}\n")
|
||||
if options[:set_define]
|
||||
store_append("CPPDEFINES" => options[:set_define])
|
||||
end
|
||||
else
|
||||
if options.has_key?(:fail) and not options[:fail]
|
||||
Ansi.write($stdout, :yellow, "not found\n")
|
||||
@ -406,9 +409,6 @@ module Rscons
|
||||
raise ConfigureFailure.new
|
||||
end
|
||||
end
|
||||
if options[:set_define]
|
||||
store_append("CPPDEFINES" => options[:set_define])
|
||||
end
|
||||
end
|
||||
|
||||
# Check if a directory contains a certain executable.
|
||||
|
@ -1659,6 +1659,30 @@ EOF
|
||||
expect(result.status).to eq 0
|
||||
expect(result.stdout).to match /Checking for C header 'not___found\.h'... not found/
|
||||
end
|
||||
|
||||
it "sets the specified define when the header is found" do
|
||||
test_dir "configure"
|
||||
result = run_rscons(rsconscript: "check_c_header_success_set_define.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/
|
||||
result = run_rscons(rsconscript: "check_c_header_success_set_define.rb", op: "build")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
expect(result.stdout).to match /-DHAVE_STRING_H/
|
||||
end
|
||||
|
||||
it "does not set the specified define when the header is not found" do
|
||||
test_dir "configure"
|
||||
result = run_rscons(rsconscript: "check_c_header_no_fail_set_define.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/
|
||||
result = run_rscons(rsconscript: "check_c_header_no_fail_set_define.rb", op: "build")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
expect(result.stdout).to_not match /-DHAVE_/
|
||||
end
|
||||
end
|
||||
|
||||
context "check_cxx_header" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user