From 06b9c98ed0c95e3d025194cc67e0fef6f8a41222 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 28 Feb 2019 21:09:56 -0500 Subject: [PATCH] support false :use value for configure operations - close #93 --- build_tests/configure/check_lib_use_false.rb | 10 +++++++++ lib/rscons/configure_op.rb | 22 ++++++++++++-------- spec/build_tests_spec.rb | 9 ++++++++ 3 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 build_tests/configure/check_lib_use_false.rb diff --git a/build_tests/configure/check_lib_use_false.rb b/build_tests/configure/check_lib_use_false.rb new file mode 100644 index 0000000..75f03ac --- /dev/null +++ b/build_tests/configure/check_lib_use_false.rb @@ -0,0 +1,10 @@ +configure do + check_lib "m", use: false +end + +build do + Environment.new(echo: :command) do |env| + env.Copy("test1.c", "simple.c") + env.Program("test2.exe", "test1.c") + end +end diff --git a/lib/rscons/configure_op.rb b/lib/rscons/configure_op.rb index 2ecccbf..cf6f810 100644 --- a/lib/rscons/configure_op.rb +++ b/lib/rscons/configure_op.rb @@ -360,15 +360,19 @@ module Rscons # @return [Hash] # Configuration Hash for storing vars. def store_common(options) - usename = - if options[:use] - options[:use].to_s - else - "_default_" - end - cache = Cache.instance - cache["configuration_data"]["vars"] ||= {} - cache["configuration_data"]["vars"][usename] ||= {} + if options[:use] == false + {} + else + usename = + if options[:use] + options[:use].to_s + else + "_default_" + end + cache = Cache.instance + cache["configuration_data"]["vars"] ||= {} + cache["configuration_data"]["vars"][usename] ||= {} + end end # Perform processing common to several configure checks. diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index 7e58287..ed5184b 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -1806,6 +1806,15 @@ EOF expect(result.stdout).to_not match /gcc.*test1.*-lm/ expect(result.stdout).to match /gcc.*test2.*-lm/ end + + it "does not link against the checked library if :use is set to false" do + test_dir "configure" + result = run_rscons(rsconscript: "check_lib_use_false.rb", op: "build") + expect(result.stderr).to eq "" + expect(result.status).to eq 0 + expect(result.stdout).to match /Checking for library 'm'... found/ + expect(result.stdout).to_not match /-lm/ + end end context "check_program" do