lib/rake.rb in drake-0.8.2.1.0.11 vs lib/rake.rb in drake-0.8.2.1.0.12

- old
+ new

@@ -27,14 +27,13 @@ # # This is the main file for the Rake application. Normally it is referenced # as a library via a require statement, but it can be distributed # independently as an application. -RAKEVERSION = '0.8.2.1.0.11' +RAKEVERSION = '0.8.2.1.0.12' require 'rbconfig' -require 'getoptlong' require 'fileutils' require 'singleton' require 'monitor' require 'optparse' require 'ostruct' @@ -579,10 +578,11 @@ if application.parallel_lock.locked? raise "Calling Task#invoke within a task is not allowed." end application.parallel_lock.synchronize { application.parallel_tasks.clear + application.parallel_parent_flags.clear base_invoke(*args) application.invoke_parallel_tasks } end end @@ -608,29 +608,36 @@ nil else invoke_prerequisites_parallel(task_args, new_chain) end - if needed? - if application.num_threads == 1 + if application.num_threads == 1 + # + # single-threaded mode + # + if needed? execute(task_args) - else + end + else + # + # parallel mode + # + # Either the task knows it's needed or we've marked it as + # such. See next comments. + # + if application.parallel_parent_flags[self] or needed? # gather tasks for batch execution application.parallel_tasks[name] = [task_args, prereqs] # # Since this is a dry run, parents must be manually marked # as needed. Files are not created or modified, so the # the 'needed?' flag does not propagate. # - unless invocation_chain == InvocationChain::EMPTY or - invocation_chain.value.needed? - invocation_chain.value.instance_eval { - def needed? - true - end - } + unless invocation_chain == InvocationChain::EMPTY + application. + parallel_parent_flags[invocation_chain.value] = true end end end end end @@ -1759,10 +1766,11 @@ alias :last_comment :last_description # Backwards compatibility attr_accessor :num_threads attr_reader :parallel_tasks #:nodoc: attr_reader :parallel_lock #:nodoc: + attr_reader :parallel_parent_flags #:nodoc: def initialize super @tasks = Hash.new @rules = Array.new @@ -1770,9 +1778,10 @@ @last_description = nil @num_threads = 1 @parallel_tasks = Hash.new @parallel_lock = Mutex.new + @parallel_parent_flags = Hash.new end def create_rule(*args, &block) pattern, arg_names, deps = resolve_args(args) pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern