From 3436dc3a64ec53a8385fa727702ab785d986ae63 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 6 Jun 2017 16:36:44 -0400 Subject: [PATCH] Expand target and sources before calling Builder#create_build_target --- lib/rscons/builders/program.rb | 2 +- lib/rscons/environment.rb | 64 +++++++++++++++++----------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lib/rscons/builders/program.rb b/lib/rscons/builders/program.rb index 45f9f8f..4ea813c 100644 --- a/lib/rscons/builders/program.rb +++ b/lib/rscons/builders/program.rb @@ -41,7 +41,7 @@ module Rscons def create_build_target(options) env, target, vars = options.values_at(:env, :target, :vars) my_options = options.dup - unless env.expand_varref(target, vars) =~ /\./ + unless target["."] my_options[:target] += env.expand_varref("${PROGSUFFIX}", vars) end super(my_options) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 38fd1d9..81fff73 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -417,48 +417,25 @@ module Rscons def method_missing(method, *args) if @builders.has_key?(method.to_s) target, sources, vars, *rest = args - unless vars.nil? or vars.is_a?(Hash) or vars.is_a?(VarSet) + vars ||= {} + unless vars.is_a?(Hash) or vars.is_a?(VarSet) raise "Unexpected construction variable set: #{vars.inspect}" end - sources = Array(sources) builder = @builders[method.to_s] + target = expand_path(target) + target = expand_varref(target) + sources = Array(sources).map do |source| + source = expand_path(source) + expand_varref(source) + end.flatten build_target = builder.create_build_target(env: self, target: target, sources: sources, vars: vars) - add_target(build_target.to_s, builder, sources, vars || {}, rest) + add_target(build_target.to_s, builder, sources, vars, rest) build_target else super end end - # Add a build target. - # - # @param target [String] Build target file name. - # @param builder [Builder] The {Builder} to use to build the target. - # @param sources [Array] Source file name(s). - # @param vars [Hash] Construction variable overrides. - # @param args [Object] Deprecated; unused. - # - # @return [void] - def add_target(target, builder, sources, vars, args) - target = expand_path(target) - target = expand_varref(target) - sources = sources.map do |source| - source = expand_path(source) - expand_varref(source) - end.flatten - setup_info = builder.setup( - target: target, - sources: sources, - env: self, - vars: vars) - @job_set.add_job( - builder: builder, - target: target, - sources: sources, - vars: vars, - setup_info: setup_info) - end - # Manually record a given target as depending on the specified files. # # @param target [String,BuildTarget] Target file. @@ -853,6 +830,29 @@ module Rscons private + # Add a build target. + # + # @param target [String] Build target file name. + # @param builder [Builder] The {Builder} to use to build the target. + # @param sources [Array] Source file name(s). + # @param vars [Hash] Construction variable overrides. + # @param args [Object] Deprecated; unused. + # + # @return [void] + def add_target(target, builder, sources, vars, args) + setup_info = builder.setup( + target: target, + sources: sources, + env: self, + vars: vars) + @job_set.add_job( + builder: builder, + target: target, + sources: sources, + vars: vars, + setup_info: setup_info) + end + # Start a threaded command in a new thread. # # @param tc [ThreadedCommand]