add Rscons::BuildTarget

Return a BuildTarget object from Environment#method_missing when a build target is registered.
This commit is contained in:
josh committed 2014-06-12 13:31:17 -04:00
1 parent 87b25d7bfd
commit 1b50a9dd3c
8 files changed
+69 -15

No files matched your search

+3 -4
View File
@@ -432,21 +432,20 @@ EOF
it 'rebuilds when user-specified dependencies change' do
test_dir('simple')
env = Rscons::Environment.new do |env|
env.Program('simple.exe', Dir['*.c'])
env.Program('simple.exe', Dir['*.c']).depends("file.ld")
File.open("file.ld", "w") do |fh|
fh.puts("foo")
end
env.depends('simple.exe', 'file.ld')
end
lines.should == ["CC simple.o", "LD simple.exe"]
File.exists?('simple.o').should be_true
`./simple.exe`.should == "This is a simple C program\n"
e2 = Rscons::Environment.new do |env|
env.Program('simple.exe', Dir['*.c'])
program = env.Program('simple.exe', Dir['*.c'])
env.depends(program, "file.ld")
File.open("file.ld", "w") do |fh|
fh.puts("bar")
end
env.depends('simple.exe', 'file.ld')
end
lines.should == ["LD simple.exe"]
e3 = Rscons::Environment.new do |env|
+2 -2
View File
@@ -5,13 +5,13 @@ module Rscons
subject {Program.new}
it "supports overriding CC construction variable" do
subject.should_receive(:standard_build).with("LD prog#{env["PROGSUFFIX"]}", "prog#{env["PROGSUFFIX"]}", ["sp-c++", "-o", "prog#{env["PROGSUFFIX"]}", "prog.o"], ["prog.o"], env, :cache)
subject.should_receive(:standard_build).with("LD prog", "prog", ["sp-c++", "-o", "prog", "prog.o"], ["prog.o"], env, :cache)
subject.run("prog", ["prog.o"], :cache, env, "CC" => "sp-c++")
end
it "supports overriding LDCMD construction variable" do
subject.should_receive(:standard_build).with("LD prog.exe", "prog.exe", ["special", "LD!", "prog.o"], ["prog.o"], env, :cache)
subject.run("prog", ["prog.o"], :cache, env, "LDCMD" => ["special", "LD!", "${_SOURCES}"])
subject.run("prog.exe", ["prog.o"], :cache, env, "LDCMD" => ["special", "LD!", "${_SOURCES}"])
end
end
end
+3 -3
View File
@@ -295,11 +295,11 @@ module Rscons
it "records the target when the target method is a known builder" do
env = Environment.new
env.instance_variable_get(:@targets).should == {}
env.Program("target", ["src1", "src2"], var: "val")
target = env.instance_variable_get(:@targets)["target"]
env.Object("target.o", ["src1.c", "src2.c"], var: "val")
target = env.instance_variable_get(:@targets)["target.o"]
target.should_not be_nil
target[:builder].is_a?(Builder).should be_true
target[:sources].should == ["src1", "src2"]
target[:sources].should == ["src1.c", "src2.c"]
target[:vars].should == {var: "val"}
target[:args].should == []
end