From ba98af142437a7d6f85736e3c94e7dd3ac5c101f Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 9 Jul 2019 22:00:50 -0400 Subject: [PATCH] default configure checks :fail option to false if :set_define is specified --- .../configure/check_c_header_no_fail_set_define.rb | 2 +- doc/user_guide.md | 8 +++++++- lib/rscons/configure_op.rb | 14 +++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/build_tests/configure/check_c_header_no_fail_set_define.rb b/build_tests/configure/check_c_header_no_fail_set_define.rb index 1ff17e3..79bb8ff 100644 --- a/build_tests/configure/check_c_header_no_fail_set_define.rb +++ b/build_tests/configure/check_c_header_no_fail_set_define.rb @@ -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 diff --git a/doc/user_guide.md b/doc/user_guide.md index 5e3cc3b..c712179 100644 --- a/doc/user_guide.md +++ b/doc/user_guide.md @@ -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` diff --git a/lib/rscons/configure_op.rb b/lib/rscons/configure_op.rb index 2bdbc50..0b5552c 100644 --- a/lib/rscons/configure_op.rb +++ b/lib/rscons/configure_op.rb @@ -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