refactor into Environment#run_builder()

This commit is contained in:
Josh Holtrop 2013-10-15 13:36:25 -04:00
parent cd266c511e
commit 013995bbc0

View File

@ -136,11 +136,11 @@ module Rscons
if @targets[target][:source].map do |src| if @targets[target][:source].map do |src|
targets_processed.include?(src) or not @targets.include?(src) or process_target.call(src) targets_processed.include?(src) or not @targets.include?(src) or process_target.call(src)
end.all? end.all?
@targets[target][:builder].run(target, run_builder(@targets[target][:builder],
@targets[target][:source], target,
cache, @targets[target][:source],
self, cache,
@targets[target][:vars] || {}) @targets[target][:vars] || {})
else else
false false
end end
@ -238,6 +238,7 @@ module Rscons
# @param sources [Array] List of source files to build. # @param sources [Array] List of source files to build.
# @param suffixes [Array] List of suffixes to try to convert source files into. # @param suffixes [Array] List of suffixes to try to convert source files into.
# @param cache [Cache] The Cache. # @param cache [Cache] The Cache.
# @param vars [Hash] Extra variables to pass to the builder.
# Return a list of the converted file names. # Return a list of the converted file names.
def build_sources(sources, suffixes, cache, vars = {}) def build_sources(sources, suffixes, cache, vars = {})
sources.map do |source| sources.map do |source|
@ -249,7 +250,7 @@ module Rscons
converted_fname = get_build_fname(source, suffix) converted_fname = get_build_fname(source, suffix)
builder = @builders.values.find { |b| b.produces?(converted_fname, source, self) } builder = @builders.values.find { |b| b.produces?(converted_fname, source, self) }
if builder if builder
converted = builder.run(converted_fname, [source], cache, self, vars) converted = run_builder(builder, converted_fname, [source], cache, vars)
return nil unless converted return nil unless converted
break break
end end
@ -258,5 +259,16 @@ module Rscons
end end
end end
end end
# Invoke a builder to build the given target based on the given sources.
# @param builder [Builder] The Builder to use.
# @param target [String] The target output file.
# @param sources [Array] List of source files.
# @param cache [Cache] The Cache.
# @param vars [Hash] Extra variables to pass to the builder.
# Return the result of the builder's run() method.
def run_builder(builder, target, sources, cache, vars)
builder.run(target, sources, cache, self, vars)
end
end end
end end