env.depends should imply env.build_after - close #40

This commit is contained in:
Josh Holtrop 2017-06-21 10:44:52 -04:00
parent c0b12132f0
commit 15e52e488c
3 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,22 @@
class TestBuilder < Rscons::Builder
def run(options)
target, env, vars, cache = options.values_at(:target, :env, :vars, :cache)
if target == "two"
return false unless File.exists?("one")
end
wait_time = env.expand_varref("${wait_time}", vars)
command = ["ruby", "-e", "require 'fileutils'; sleep #{wait_time}; FileUtils.touch('#{target}');"]
standard_threaded_build("TestBuilder", target, command, [], env, cache)
end
def finalize(options)
standard_finalize(options)
end
end
Rscons::Environment.new do |env|
env.add_builder(TestBuilder.new)
env.TestBuilder("one", [], "wait_time" => "3")
env.TestBuilder("two", [], "wait_time" => "0")
env.depends("two", "one")
end

View File

@ -451,6 +451,7 @@ module Rscons
user_deps = user_deps.map {|ud| expand_varref(ud)} user_deps = user_deps.map {|ud| expand_varref(ud)}
@user_deps[target] ||= [] @user_deps[target] ||= []
@user_deps[target] = (@user_deps[target] + user_deps).uniq @user_deps[target] = (@user_deps[target] + user_deps).uniq
build_after(target, user_deps)
end end
# Manually record the given target(s) as needing to be built after the # Manually record the given target(s) as needing to be built after the

View File

@ -746,6 +746,12 @@ EOF
expect(result.status).to_not eq 0 expect(result.status).to_not eq 0
end end
it "orders builds to respect user dependencies" do
test_dir("simple")
result = run_test(rsconsfile: "user_dep_build_order.rb", rscons_args: %w[-j4])
expect(result.stderr).to eq ""
end
context "backward compatibility" do context "backward compatibility" do
it "allows a builder to call Environment#run_builder in a non-threaded manner" do it "allows a builder to call Environment#run_builder in a non-threaded manner" do
test_dir("simple") test_dir("simple")