allow phony targets in conjunction with a build root

This commit is contained in:
Josh Holtrop 2016-01-12 10:14:10 -05:00
parent bab4641b6e
commit 0442b876a5
2 changed files with 30 additions and 23 deletions

View File

@ -509,8 +509,12 @@ module Rscons
#
# @return [String] The expanded path.
def expand_path(path)
if Rscons.phony_target?(path)
path
else
path.sub(%r{^\^(?=[\\/])}, @build_root)
end
end
# Execute a command using the system shell.
#

View File

@ -933,9 +933,11 @@ EOF
end
context "phony targets" do
[false, true].each do |with_build_root|
it "allows specifying a Symbol as a target name and reruns the builder if the sources or command have changed" do
test_dir("simple")
env = Rscons::Environment.new do |env|
env.build_root = "bld" if with_build_root
env.add_builder(:Checker) do |target, sources, cache, env, vars|
unless cache.up_to_date?(target, :Checker, sources, env)
puts "Checker #{sources.first}" if env.echo != :off
@ -946,7 +948,7 @@ EOF
env.Program("simple.exe", "simple.c")
env.Checker(:checker, "simple.exe")
end
expect(lines).to eq(["CC simple.o", "LD simple.exe", "Checker simple.exe"])
expect(lines).to eq(["CC #{with_build_root ? 'bld/' : ''}simple.o", "LD simple.exe", "Checker simple.exe"])
env.clone do |env|
env.Checker(:checker, "simple.exe")
@ -962,5 +964,6 @@ EOF
expect(lines).to eq(["Checker simple.exe"])
end
end
end
end