default configure checks :fail option to false if :set_define is specified

This commit is contained in:
Josh Holtrop 2019-07-09 22:00:50 -04:00
parent cf4f80c9ae
commit ba98af1424
3 changed files with 19 additions and 5 deletions

View File

@ -1,5 +1,5 @@
configure do
check_c_header "not___found.h", fail: false, set_define: "HAVE_NOT___FOUND_H"
check_c_header "not___found.h", set_define: "HAVE_NOT___FOUND_H"
end
build do

View File

@ -247,7 +247,7 @@ Example calls:
```ruby
configure do
check_c_header "getopt.h", fail: false, set_define: "HAVE_GETOPT_H"
check_c_header "getopt.h", set_define: "HAVE_GETOPT_H"
check_c_header "FreeType2.h"
check_cxx_header "memory"
end
@ -259,6 +259,8 @@ end
If the `:fail` option is set to `false`, then the absence of the header file
will not result in the configure option failing.
The `:fail` option defaults to `true` if the `:set_define` option is not
defined, and defaults to `false` if the `:set_define` option is defined.
##### `:set_define`
@ -302,6 +304,8 @@ end
If the `:fail` option is set to `false`, then the absence of the library
will not result in the configure option failing.
The `:fail` option defaults to `true` if the `:set_define` option is not
defined, and defaults to `false` if the `:set_define` option is defined.
##### `:set_define`
@ -354,6 +358,8 @@ for configuration flags.
If the `:fail` option is set to `false`, then the absence of the package or
program requested will not result in the configure option failing.
The `:fail` option defaults to `true` if the `:set_define` option is not
defined, and defaults to `false` if the `:set_define` option is defined.
##### `:set_define`

View File

@ -411,6 +411,8 @@ module Rscons
# Common check options.
# @option options [Boolean] :fail
# Whether to fail configuration if the requested item is not found.
# This defaults to true if the :set_define option is not specified,
# otherwise defaults to false if :set_define option is specified.
# @option options [String] :set_define
# A define to set (in CPPDEFINES) if the requested item is found.
# @option options [String] :success_message
@ -423,11 +425,17 @@ module Rscons
store_append("CPPDEFINES" => [options[:set_define]])
end
else
if options.has_key?(:fail) and not options[:fail]
Ansi.write($stdout, :yellow, "not found\n")
else
should_fail =
if options.has_key?(:fail)
options[:fail]
else
!options[:set_define]
end
if should_fail
Ansi.write($stdout, :red, "not found\n")
raise ConfigureFailure.new
else
Ansi.write($stdout, :yellow, "not found\n")
end
end
end