diff --git a/build_tests/simple/builder_as_source.rb b/build_tests/simple/builder_as_source.rb new file mode 100644 index 0000000..953fcad --- /dev/null +++ b/build_tests/simple/builder_as_source.rb @@ -0,0 +1,6 @@ +build do + Environment.new do |env| + object = env.Object("simple.o", "simple.c") + env.Program("simple.exe", object) + end +end diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index f69af9e..e6e439b 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -310,6 +310,7 @@ module Rscons end target = expand_path(expand_varref(target)) sources = Array(sources).map do |source| + source = source.target if sources.is_a?(Builder) expand_path(expand_varref(source)) end.flatten builder = @builders[method.to_s].new( diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index 476186a..aac7a34 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -173,6 +173,14 @@ EOF expect(`./simple.exe`).to eq "This is a simple C program\n" end + it "allows specifying a Builder object as the source to another build target" do + test_dir("simple") + result = run_rscons(rsconscript: "builder_as_source.rb") + expect(result.stderr).to eq "" + expect(File.exists?("simple.o")).to be_truthy + expect(`./simple.exe`).to eq "This is a simple C program\n" + end + it 'prints commands as they are executed' do test_dir('simple') result = run_rscons(rsconscript: "command.rb")