diff --git a/lib/rscons/build_target.rb b/lib/rscons/build_target.rb index 03795f7..33fb060 100644 --- a/lib/rscons/build_target.rb +++ b/lib/rscons/build_target.rb @@ -3,11 +3,16 @@ module Rscons class BuildTarget # Create a BuildTarget object. # - # @param env [Environment] The Environment. - # @param target [String] Name of the target file. - def initialize(env, target) - @env = env - @target = target + # @param options [Hash] Options to create the BuildTarget with. + # @option options [Environment] :env + # The Environment. + # @option options [String] :target + # The user-supplied target name. + # @option options [Array] :sources + # The user-supplied source file name(s). + def initialize(options) + @env = options[:env] + @target = options[:target] end # Manually record a given target as depending on the specified files. diff --git a/lib/rscons/builder.rb b/lib/rscons/builder.rb index cc12d2e..3af964a 100644 --- a/lib/rscons/builder.rb +++ b/lib/rscons/builder.rb @@ -24,12 +24,17 @@ module Rscons # Builder sub-classes can override this method to manipulate parameters # (for example, add a suffix to the user-given target file name). # - # @param env [Environment] The Environment. - # @param target [String] The user-supplied target name. + # @param options [Hash] Options to create the BuildTarget with. + # @option options [Environment] :env + # The Environment. + # @option options [String] :target + # The user-supplied target name. + # @option options [Array] :sources + # The user-supplied source file name(s). # # @return [BuildTarget] - def create_build_target(env, target) - BuildTarget.new(env, target) + def create_build_target(options) + BuildTarget.new(options) end # Return whether this builder object is capable of producing a given target diff --git a/lib/rscons/builders/program.rb b/lib/rscons/builders/program.rb index 76116b6..89fab29 100644 --- a/lib/rscons/builders/program.rb +++ b/lib/rscons/builders/program.rb @@ -18,11 +18,12 @@ module Rscons } end - def create_build_target(env, target) - unless target =~ /\./ - target += env.expand_varref("${PROGSUFFIX}") + def create_build_target(options) + my_options = options.dup + unless my_options[:target] =~ /\./ + my_options[:target] += options[:env].expand_varref("${PROGSUFFIX}") end - super(env, target) + super(my_options) end def run(target, sources, cache, env, vars) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 45c49de..9e40dc1 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -261,7 +261,7 @@ module Rscons end sources = Array(sources) builder = @builders[method.to_s] - build_target = builder.create_build_target(self, target) + build_target = builder.create_build_target(env: self, target: target, sources: sources) add_target(build_target.to_s, builder, sources, vars, rest) build_target else