From 053df2360fabc1d063849364c9185f25b00c688a Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 30 Oct 2018 17:19:53 -0400 Subject: [PATCH] add Rscons.vars back again at least for now --- build_tests/simple/cache_debugging.rb | 2 +- lib/rscons.rb | 7 +++++++ spec/build_tests_spec.rb | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/build_tests/simple/cache_debugging.rb b/build_tests/simple/cache_debugging.rb index cd6a00e..67b7865 100644 --- a/build_tests/simple/cache_debugging.rb +++ b/build_tests/simple/cache_debugging.rb @@ -17,7 +17,7 @@ class DebugBuilder < Rscons::Builder strict_deps = true end unless cache.up_to_date?(target, command, sources, env, debug: true, strict_deps: strict_deps) - desc = "#{self.class.name} #{target}" + desc = "#{name} #{target}" return false unless env.execute(desc, command) cache.register_build(target, command, sources, env) end diff --git a/lib/rscons.rb b/lib/rscons.rb index 7d79514..8273e42 100644 --- a/lib/rscons.rb +++ b/lib/rscons.rb @@ -57,6 +57,13 @@ module Rscons @application ||= Application.new end + # Access any variables set on the rscons command-line. + # + # @return [VarSet] + def vars(*args) + application.vars(*args) + end + # Return whether the given path is an absolute filesystem path. # # @param path [String] the path to examine. diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index a639086..579c096 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -1287,6 +1287,7 @@ EOF it "prints a message when the target does not exist" do test_dir("simple") result = run_rscons(rsconsfile: "cache_debugging.rb") + expect(result.stderr).to eq "" expect(result.stdout).to match /Target foo\.o needs rebuilding because it does not exist on disk/ end @@ -1294,54 +1295,67 @@ EOF test_dir("simple") FileUtils.touch("foo.o") result = run_rscons(rsconsfile: "cache_debugging.rb") + expect(result.stderr).to eq "" expect(result.stdout).to match /Target foo\.o needs rebuilding because there is no cached build information for it/ end it "prints a message when the target file has changed on disk" do test_dir("simple") result = run_rscons(rsconsfile: "cache_debugging.rb") + expect(result.stderr).to eq "" File.open("foo.o", "wb") {|fh| fh.puts "hi"} result = run_rscons(rsconsfile: "cache_debugging.rb") + expect(result.stderr).to eq "" expect(result.stdout).to match /Target foo\.o needs rebuilding because it has been changed on disk since being built last/ end it "prints a message when the command has changed" do test_dir("simple") result = run_rscons(rsconsfile: "cache_debugging.rb") + expect(result.stderr).to eq "" result = run_rscons(rsconsfile: "cache_debugging.rb", op: %w[build command_change=yes]) + expect(result.stderr).to eq "" expect(result.stdout).to match /Target foo\.o needs rebuilding because the command used to build it has changed/ end it "prints a message when strict_deps is in use and the set of dependencies does not match" do test_dir("simple") result = run_rscons(rsconsfile: "cache_debugging.rb", op: %w[build strict_deps1=yes]) + expect(result.stderr).to eq "" result = run_rscons(rsconsfile: "cache_debugging.rb", op: %w[build strict_deps2=yes]) + expect(result.stderr).to eq "" expect(result.stdout).to match /Target foo\.o needs rebuilding because the :strict_deps option is given and the set of dependencies does not match the previous set of dependencies/ end it "prints a message when there is a new dependency" do test_dir("simple") result = run_rscons(rsconsfile: "cache_debugging.rb") + expect(result.stderr).to eq "" result = run_rscons(rsconsfile: "cache_debugging.rb", op: %w[build new_dep=yes]) + expect(result.stderr).to eq "" expect(result.stdout).to match /Target foo\.o needs rebuilding because there are new dependencies/ end it "prints a message when there is a new user-specified dependency" do test_dir("simple") result = run_rscons(rsconsfile: "cache_debugging.rb") + expect(result.stderr).to eq "" result = run_rscons(rsconsfile: "cache_debugging.rb", op: %w[build new_user_dep=yes]) + expect(result.stderr).to eq "" expect(result.stdout).to match /Target foo\.o needs rebuilding because the set of user-specified dependency files has changed/ end it "prints a message when a dependency file has changed" do test_dir("simple") result = run_rscons(rsconsfile: "cache_debugging.rb") + expect(result.stderr).to eq "" f = File.read("simple.c", mode: "rb") f += "\n" File.open("simple.c", "wb") do |fh| fh.write(f) end result = run_rscons(rsconsfile: "cache_debugging.rb") + expect(result.stderr).to eq "" expect(result.stdout).to match /Target foo\.o needs rebuilding because dependency file simple\.c has changed/ end end