diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index d5f8ea4..931549b 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -660,6 +660,13 @@ module Rscons end end + # Print the Environment's construction variables for debugging. + def dump + @varset.to_h.sort.each do |var, val| + puts "#{var} => #{val.inspect}" + end + end + private # Expand target and source paths before invoking builders. diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index d00b104..095e047 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -721,4 +721,15 @@ EOF expect(`./two_sources`).to eq "This is a C program with two sources.\n" end + it "supports dumping an Environment's construction variables" do + test_dir("simple") + env = Rscons::Environment.new do |env| + env["CFLAGS"] += %w[-O2 -fomit-frame-pointer] + end + env.dump + result = lines + expect(result.include?(%{CFLAGS => ["-O2", "-fomit-frame-pointer"]})).to be_truthy + expect(result.include?(%{CPPPATH => []})).to be_truthy + end + end