change Builder#create_build_target and BuildTarget#initialize to accept a Hash of options

This commit is contained in:
Josh Holtrop 2014-06-16 12:17:33 -04:00
parent d9eea10363
commit 8fc95b5d69
4 changed files with 25 additions and 14 deletions

View File

@ -3,11 +3,16 @@ module Rscons
class BuildTarget class BuildTarget
# Create a BuildTarget object. # Create a BuildTarget object.
# #
# @param env [Environment] The Environment. # @param options [Hash] Options to create the BuildTarget with.
# @param target [String] Name of the target file. # @option options [Environment] :env
def initialize(env, target) # The Environment.
@env = env # @option options [String] :target
@target = target # The user-supplied target name.
# @option options [Array<String>] :sources
# The user-supplied source file name(s).
def initialize(options)
@env = options[:env]
@target = options[:target]
end end
# Manually record a given target as depending on the specified files. # Manually record a given target as depending on the specified files.

View File

@ -24,12 +24,17 @@ module Rscons
# Builder sub-classes can override this method to manipulate parameters # Builder sub-classes can override this method to manipulate parameters
# (for example, add a suffix to the user-given target file name). # (for example, add a suffix to the user-given target file name).
# #
# @param env [Environment] The Environment. # @param options [Hash] Options to create the BuildTarget with.
# @param target [String] The user-supplied target name. # @option options [Environment] :env
# The Environment.
# @option options [String] :target
# The user-supplied target name.
# @option options [Array<String>] :sources
# The user-supplied source file name(s).
# #
# @return [BuildTarget] # @return [BuildTarget]
def create_build_target(env, target) def create_build_target(options)
BuildTarget.new(env, target) BuildTarget.new(options)
end end
# Return whether this builder object is capable of producing a given target # Return whether this builder object is capable of producing a given target

View File

@ -18,11 +18,12 @@ module Rscons
} }
end end
def create_build_target(env, target) def create_build_target(options)
unless target =~ /\./ my_options = options.dup
target += env.expand_varref("${PROGSUFFIX}") unless my_options[:target] =~ /\./
my_options[:target] += options[:env].expand_varref("${PROGSUFFIX}")
end end
super(env, target) super(my_options)
end end
def run(target, sources, cache, env, vars) def run(target, sources, cache, env, vars)

View File

@ -261,7 +261,7 @@ module Rscons
end end
sources = Array(sources) sources = Array(sources)
builder = @builders[method.to_s] 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) add_target(build_target.to_s, builder, sources, vars, rest)
build_target build_target
else else