diff --git a/README.md b/README.md index 72924e5..ddbecde 100644 --- a/README.md +++ b/README.md @@ -388,6 +388,7 @@ http://rubydoc.info/github/holtrop/rscons/frames. - fix Rscons.set_suffix to append the given suffix if the filename has none - rework Preprocess builder to consider deep dependencies - remove ${CFLAGS} from default CPP_CMD +- fix variable references that expand to arrays in build target sources ### v1.8.1 diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 808393e..a230c9e 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -683,7 +683,7 @@ module Rscons sources = target_params[:sources].map do |source| source = expand_path(source) if @build_root expand_varref(source) - end + end.flatten target = expand_path(target) if @build_root target = expand_varref(target) result[target] = target_params.merge(sources: sources) diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index 6fb7ee1..63e6598 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -754,4 +754,14 @@ EOF expect(File.read("pp")).to match(%r{abc88xyz}m) end + it "allows construction variable references which expand to arrays in sources of a build target" do + test_dir("simple") + Rscons::Environment.new do |env| + env["sources"] = Dir["*.c"] + env.Program("simple", "${sources}") + end + expect(File.exists?("simple.o")).to be_truthy + expect(`./simple`).to eq "This is a simple C program\n" + end + end