add Rscons.vars back again at least for now

This commit is contained in:
Josh Holtrop 2018-10-30 17:19:53 -04:00
parent 8d766e4804
commit 053df2360f
3 changed files with 22 additions and 1 deletions

View File

@ -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

View File

@ -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.

View File

@ -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