allow passing a VarSet into cache methods - close #47

This commit is contained in:
Josh Holtrop 2018-08-22 16:32:05 -04:00
parent 8cb02a7e34
commit 53ba7dad41
3 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,20 @@
class TestBuilder < Rscons::Builder
def run(options)
target, sources, cache, env = options.values_at(:target, :sources, :cache, :env)
command = Rscons::VarSet.new("A" => "a", "B" => "b")
unless cache.up_to_date?(target, command, sources, env)
File.open(target, "w") do |fh|
fh.puts("hi")
end
msg = "#{self.class.name} #{target}"
env.print_builder_run_message(msg, msg)
cache.register_build(target, command, sources, env)
end
target
end
end
Rscons::Environment.new do |env|
env.add_builder(TestBuilder.new)
env.TestBuilder("foo")
end

View File

@ -143,6 +143,13 @@ module Rscons
end
end
# Return a String representing the VarSet.
#
# @return [String] Representation of the VarSet.
def inspect
to_h.inspect
end
# Return an array containing the values associated with the given keys.
#
# @param keys [Array<String, Symbol>]

View File

@ -1261,6 +1261,18 @@ EOF
"LD simple.exe",
]
end
it "allows a VarSet to be passed in as the command parameter" do
test_dir("simple")
result = run_test(rsconsfile: "cache_varset.rb")
expect(result.stderr).to eq ""
expect(lines(result.stdout)).to eq [
"TestBuilder foo",
]
result = run_test(rsconsfile: "cache_varset.rb")
expect(result.stderr).to eq ""
expect(result.stdout).to eq ""
end
end
context "Object builder" do