allow passing a VarSet into cache methods - close #47
This commit is contained in:
parent
8cb02a7e34
commit
53ba7dad41
20
build_tests/simple/cache_varset.rb
Normal file
20
build_tests/simple/cache_varset.rb
Normal 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
|
@ -143,6 +143,13 @@ module Rscons
|
|||||||
end
|
end
|
||||||
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.
|
# Return an array containing the values associated with the given keys.
|
||||||
#
|
#
|
||||||
# @param keys [Array<String, Symbol>]
|
# @param keys [Array<String, Symbol>]
|
||||||
|
@ -1261,6 +1261,18 @@ EOF
|
|||||||
"LD simple.exe",
|
"LD simple.exe",
|
||||||
]
|
]
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context "Object builder" do
|
context "Object builder" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user