mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* NEWS (with all sufficient information):
* lib/rake: Update to rake 10.1.0 * bin/rake: ditto. * test/rake: ditto. * NEWS: Update NEWS to include rake 10.1.0 and links to release notes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
52c1331763
commit
9cadc95b28
83 changed files with 1724 additions and 2954 deletions
122
lib/rake/task.rb
122
lib/rake/task.rb
|
@ -21,13 +21,6 @@ module Rake
|
|||
# Application owning this task.
|
||||
attr_accessor :application
|
||||
|
||||
# Comment for this task. Restricted to a single line of no more than 50
|
||||
# characters.
|
||||
attr_reader :comment
|
||||
|
||||
# Full text of the (possibly multi-line) comment.
|
||||
attr_reader :full_comment
|
||||
|
||||
# Array of nested namespaces names used for task lookup by this task.
|
||||
attr_reader :scope
|
||||
|
||||
|
@ -53,7 +46,7 @@ module Rake
|
|||
|
||||
# List of prerequisite tasks
|
||||
def prerequisite_tasks
|
||||
prerequisites.collect { |pre| lookup_prerequisite(pre) }
|
||||
prerequisites.map { |pre| lookup_prerequisite(pre) }
|
||||
end
|
||||
|
||||
def lookup_prerequisite(prerequisite_name)
|
||||
|
@ -61,6 +54,24 @@ module Rake
|
|||
end
|
||||
private :lookup_prerequisite
|
||||
|
||||
# List of all unique prerequisite tasks including prerequisite tasks'
|
||||
# prerequisites.
|
||||
# Includes self when cyclic dependencies are found.
|
||||
def all_prerequisite_tasks
|
||||
seen = {}
|
||||
collect_prerequisites(seen)
|
||||
seen.values
|
||||
end
|
||||
|
||||
def collect_prerequisites(seen)
|
||||
prerequisite_tasks.each do |pre|
|
||||
next if seen[pre.name]
|
||||
seen[pre.name] = pre
|
||||
pre.collect_prerequisites(seen)
|
||||
end
|
||||
end
|
||||
protected :collect_prerequisites
|
||||
|
||||
# First source from a rule (nil if no sources)
|
||||
def source
|
||||
@sources.first if defined?(@sources)
|
||||
|
@ -69,17 +80,16 @@ module Rake
|
|||
# Create a task named +task_name+ with no actions or prerequisites. Use
|
||||
# +enhance+ to add actions and prerequisites.
|
||||
def initialize(task_name, app)
|
||||
@name = task_name.to_s
|
||||
@prerequisites = []
|
||||
@actions = []
|
||||
@name = task_name.to_s
|
||||
@prerequisites = []
|
||||
@actions = []
|
||||
@already_invoked = false
|
||||
@full_comment = nil
|
||||
@comment = nil
|
||||
@lock = Monitor.new
|
||||
@application = app
|
||||
@scope = app.current_scope
|
||||
@arg_names = nil
|
||||
@locations = []
|
||||
@comments = []
|
||||
@lock = Monitor.new
|
||||
@application = app
|
||||
@scope = app.current_scope
|
||||
@arg_names = nil
|
||||
@locations = []
|
||||
end
|
||||
|
||||
# Enhance a task with prerequisites or actions. Returns self.
|
||||
|
@ -141,8 +151,7 @@ module Rake
|
|||
|
||||
# Clear the existing comments on a rake task.
|
||||
def clear_comments
|
||||
@full_comment = nil
|
||||
@comment = nil
|
||||
@comments = []
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -172,7 +181,8 @@ module Rake
|
|||
protected :invoke_with_call_chain
|
||||
|
||||
def add_chain_to(exception, new_chain)
|
||||
exception.extend(InvocationExceptionMixin) unless exception.respond_to?(:chain)
|
||||
exception.extend(InvocationExceptionMixin) unless
|
||||
exception.respond_to?(:chain)
|
||||
exception.chain = new_chain if exception.chain.nil?
|
||||
end
|
||||
private :add_chain_to
|
||||
|
@ -190,8 +200,8 @@ module Rake
|
|||
end
|
||||
|
||||
# Invoke all the prerequisites of a task in parallel.
|
||||
def invoke_prerequisites_concurrently(task_args, invocation_chain) # :nodoc:
|
||||
futures = prerequisite_tasks.collect do |p|
|
||||
def invoke_prerequisites_concurrently(task_args, invocation_chain)# :nodoc:
|
||||
futures = prerequisite_tasks.map do |p|
|
||||
prereq_args = task_args.new_scope(p.arg_names)
|
||||
application.thread_pool.future(p) do |r|
|
||||
r.invoke_with_call_chain(prereq_args, invocation_chain)
|
||||
|
@ -216,9 +226,7 @@ module Rake
|
|||
application.trace "** Execute (dry run) #{name}"
|
||||
return
|
||||
end
|
||||
if application.options.trace
|
||||
application.trace "** Execute #{name}"
|
||||
end
|
||||
application.trace "** Execute #{name}" if application.options.trace
|
||||
application.enhance_with_matching_rule(name) if @actions.empty?
|
||||
@actions.each do |act|
|
||||
case act.arity
|
||||
|
@ -238,39 +246,58 @@ module Rake
|
|||
# Timestamp for this task. Basic tasks return the current time for their
|
||||
# time stamp. Other tasks can be more sophisticated.
|
||||
def timestamp
|
||||
prerequisite_tasks.collect { |pre| pre.timestamp }.max || Time.now
|
||||
Time.now
|
||||
end
|
||||
|
||||
# Add a description to the task. The description can consist of an option
|
||||
# argument list (enclosed brackets) and an optional comment.
|
||||
def add_description(description)
|
||||
return if ! description
|
||||
return unless description
|
||||
comment = description.strip
|
||||
add_comment(comment) if comment && ! comment.empty?
|
||||
end
|
||||
|
||||
# Writing to the comment attribute is the same as adding a description.
|
||||
def comment=(description)
|
||||
add_description(description)
|
||||
def comment=(comment)
|
||||
add_comment(comment)
|
||||
end
|
||||
|
||||
# Add a comment to the task. If a comment already exists, separate
|
||||
# the new comment with " / ".
|
||||
def add_comment(comment)
|
||||
if @full_comment
|
||||
@full_comment << " / "
|
||||
else
|
||||
@full_comment = ''
|
||||
end
|
||||
@full_comment << comment
|
||||
if @full_comment =~ /\A([^.]+?\.)( |$)/
|
||||
@comment = $1
|
||||
else
|
||||
@comment = @full_comment
|
||||
end
|
||||
@comments << comment unless @comments.include?(comment)
|
||||
end
|
||||
private :add_comment
|
||||
|
||||
# Full collection of comments. Multiple comments are separated by
|
||||
# newlines.
|
||||
def full_comment
|
||||
transform_comments("\n")
|
||||
end
|
||||
|
||||
# First line (or sentence) of all comments. Multiple comments are
|
||||
# separated by a "/".
|
||||
def comment
|
||||
transform_comments(" / ") { |c| first_sentence(c) }
|
||||
end
|
||||
|
||||
# Transform the list of comments as specified by the block and
|
||||
# join with the separator.
|
||||
def transform_comments(separator, &block)
|
||||
if @comments.empty?
|
||||
nil
|
||||
else
|
||||
block ||= lambda { |c| c }
|
||||
@comments.map(&block).join(separator)
|
||||
end
|
||||
end
|
||||
private :transform_comments
|
||||
|
||||
# Get the first sentence in a string. The sentence is terminated
|
||||
# by the first period or the end of the line. Decimal points do
|
||||
# not count as periods.
|
||||
def first_sentence(string)
|
||||
string.split(/\.[ \t]|\.$|\n/).first
|
||||
end
|
||||
private :first_sentence
|
||||
|
||||
# Set the names of the arguments for this task. +args+ should be
|
||||
# an array of symbols, one for each argument name.
|
||||
def set_arg_names(args)
|
||||
|
@ -287,11 +314,11 @@ module Rake
|
|||
result << "timestamp: #{timestamp}\n"
|
||||
result << "pre-requisites: \n"
|
||||
prereqs = prerequisite_tasks
|
||||
prereqs.sort! {|a,b| a.timestamp <=> b.timestamp}
|
||||
prereqs.sort! { |a, b| a.timestamp <=> b.timestamp }
|
||||
prereqs.each do |p|
|
||||
result << "--#{p.name} (#{p.timestamp})\n"
|
||||
end
|
||||
latest_prereq = prerequisite_tasks.collect { |pre| pre.timestamp }.max
|
||||
latest_prereq = prerequisite_tasks.map { |pre| pre.timestamp }.max
|
||||
result << "latest-prerequisite time: #{latest_prereq}\n"
|
||||
result << "................................\n\n"
|
||||
return result
|
||||
|
@ -342,7 +369,8 @@ module Rake
|
|||
# this kind of task. Generic tasks will accept the scope as
|
||||
# part of the name.
|
||||
def scope_name(scope, task_name)
|
||||
(scope + [task_name]).join(':')
|
||||
# (scope + [task_name]).join(':')
|
||||
scope.path_with_task_name(task_name)
|
||||
end
|
||||
|
||||
end # class << Rake::Task
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue