expand target and sources for construction variable references before invoking builder

This commit is contained in:
josh committed 2014-05-09 09:45:29 -04:00
1 parent bd525e2742
commit 58b41df426
2 files changed
+39 -10

No files matched your search

+26
View File
@@ -498,4 +498,30 @@ EOF
env.TestBuilder("file")
end
end
it "expands construction variables in builder target and sources before invoking the builder" do
test_dir('custom_builder')
class MySource < Rscons::Builder
def run(target, sources, cache, env, vars)
File.open(target, 'w') do |fh|
fh.puts <<EOF
#define THE_VALUE 678
EOF
end
target
end
end
Rscons::Environment.new do |env|
env["hdr"] = "inc.h"
env["src"] = "program.c"
env.add_builder(MySource.new)
env.MySource('${hdr}')
env.Program('program', "${src}")
end
lines.should == ['CC program.o', 'LD program']
File.exists?('inc.h').should be_true
`./program`.should == "The value is 678\n"
end
end