lib/rscons/environment.rb in rscons-1.8.1 vs lib/rscons/environment.rb in rscons-1.9.0
- old
+ new
@@ -278,37 +278,39 @@
# When a block is passed to Environment.new, this method is automatically
# called after the block returns.
#
# @return [void]
def process
- expand_paths!
while @targets.size > 0
+ expand_paths!
targets = @targets
@targets = {}
cache = Cache.instance
cache.clear_checksum_cache!
- targets_processed = {}
+ targets_processed = Set.new
process_target = proc do |target|
- targets_processed[target] ||= begin
- targets[target][:sources].each do |src|
- if targets.include?(src) and not targets_processed.include?(src)
- process_target.call(src)
+ unless targets_processed.include?(target)
+ targets_processed << target
+ targets[target].each do |target_params|
+ target_params[:sources].each do |src|
+ if targets.include?(src) and not targets_processed.include?(src)
+ process_target.call(src)
+ end
end
+ result = run_builder(target_params[:builder],
+ target,
+ target_params[:sources],
+ cache,
+ target_params[:vars] || {})
+ unless result
+ raise BuildError.new("Failed to build #{target}")
+ end
end
- result = run_builder(targets[target][:builder],
- target,
- targets[target][:sources],
- cache,
- targets[target][:vars] || {})
- unless result
- raise BuildError.new("Failed to build #{target}")
- end
- result
end
end
begin
- targets.each do |target, target_params|
+ targets.each_key do |target|
process_target.call(target)
end
ensure
cache.write
end
@@ -402,11 +404,12 @@
# @param vars [Hash] Construction variable overrides.
# @param args [Object] Any extra arguments passed to the {Builder}.
#
# @return [void]
def add_target(target, builder, sources, vars, args)
- @targets[target] = {
+ @targets[target] ||= []
+ @targets[target] << {
builder: builder,
sources: sources,
vars: vars,
args: args,
}
@@ -677,28 +680,31 @@
# source file names before passing them to the builder. It also expands
# "^/" prefixes to the Environment's build root if a build root is defined.
#
# @return [void]
def expand_paths!
- @targets = @targets.reduce({}) do |result, (target, target_params)|
- sources = target_params[:sources].map do |source|
- source = expand_path(source) if @build_root
- expand_varref(source)
- end
+ @targets = @targets.reduce({}) do |result, (target, target_params_list)|
target = expand_path(target) if @build_root
target = expand_varref(target)
- result[target] = target_params.merge(sources: sources)
+ result[target] = target_params_list.map do |target_params|
+ sources = target_params[:sources].map do |source|
+ source = expand_path(source) if @build_root
+ expand_varref(source)
+ end.flatten
+ target_params.merge(sources: sources)
+ end
result
end
end
# Parse dependencies for a given target from a Makefile.
#
# This method is used internally by Rscons builders.
#
# @param mf_fname [String] File name of the Makefile to read.
- # @param target [String] Name of the target to gather dependencies for.
+ # @param target [String, nil]
+ # Name of the target to gather dependencies for, nil for any/all.
#
# @return [Array<String>] Paths of dependency files.
def self.parse_makefile_deps(mf_fname, target)
deps = []
buildup = ''
@@ -707,10 +713,10 @@
buildup += ' ' + $1
else
buildup += ' ' + line
if buildup =~ /^(.*): (.*)$/
mf_target, mf_deps = $1.strip, $2
- if mf_target == target
+ if target.nil? or mf_target == target
deps += mf_deps.split(' ').map(&:strip)
end
end
buildup = ''
end