summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-02 19:07:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-02 19:07:55 +0000
commit719b0f8e3037e1033726b6487d7b0d9fc1412e7d (patch)
treec5a08c8c9abae9b7f0514f680f56553a7a03656a /lib
parenta0f667c33e24928374d494c9c33d0082355785e1 (diff)
* lib/rake: updated to rake code to rake-0.8.7 source code base.
* lib/rake/loaders/makefile.rb (Rake::MakefileLoader#process_line): respace dependencies too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rake.rb122
-rw-r--r--lib/rake/loaders/makefile.rb2
-rw-r--r--lib/rake/rdoctask.rb4
-rw-r--r--lib/rake/testtask.rb15
-rw-r--r--lib/rake/win32.rb18
5 files changed, 89 insertions, 72 deletions
diff --git a/lib/rake.rb b/lib/rake.rb
index c288e80..f14b9b5 100644
--- a/lib/rake.rb
+++ b/lib/rake.rb
@@ -27,7 +27,7 @@
# as a library via a require statement, but it can be distributed
# independently as an application.
-RAKEVERSION = '0.8.4'
+RAKEVERSION = '0.8.7'
require 'rbconfig'
require 'fileutils'
@@ -38,6 +38,8 @@ require 'ostruct'
require 'rake/win32'
+$trace = false
+
######################################################################
# Rake extensions to Module.
#
@@ -201,7 +203,7 @@ class String
when '%f'
result << File.basename(self)
when '%n'
- result << File.basename(self, '.*')
+ result << File.basename(self).ext
when '%d'
result << File.dirname(self)
when '%x'
@@ -278,7 +280,7 @@ module Rake
end
- # ##########################################################################
+ ####################################################################
# Mixin for creating easily cloned objects.
#
module Cloneable
@@ -303,6 +305,27 @@ module Rake
end
####################################################################
+ # Exit status class for times the system just gives us a nil.
+ class PseudoStatus
+ attr_reader :exitstatus
+ def initialize(code=0)
+ @exitstatus = code
+ end
+ def to_i
+ @exitstatus << 8
+ end
+ def >>(n)
+ to_i >> n
+ end
+ def stopped?
+ false
+ end
+ def exited?
+ true
+ end
+ end
+
+ ####################################################################
# TaskAguments manage the arguments passed to a task.
#
class TaskArguments
@@ -432,7 +455,7 @@ end # module Rake
module Rake
- # #########################################################################
+ ###########################################################################
# A Task is the basic unit of work in a Rakefile. Tasks have associated
# actions (possibly more than one) and a list of prerequisites. When
# invoked, a task will first ensure that all of its prerequisites have an
@@ -732,7 +755,7 @@ module Rake
end # class Rake::Task
- # #########################################################################
+ ###########################################################################
# A FileTask is a task that includes time based dependencies. If any of a
# FileTask's prerequisites have a timestamp that is later than the file
# represented by this task, then the file must be rebuilt (using the
@@ -774,7 +797,7 @@ module Rake
end
end # class Rake::FileTask
- # #########################################################################
+ ###########################################################################
# A FileCreationTask is a file task that when used as a dependency will be
# needed if and only if the file has not been created. Once created, it is
# not re-triggered if any of its dependencies are newer, nor does trigger
@@ -793,7 +816,7 @@ module Rake
end
end
- # #########################################################################
+ ###########################################################################
# Same as a regular task, but the immediate prerequisites are done in
# parallel using Ruby threads.
#
@@ -808,7 +831,7 @@ module Rake
end
end # module Rake
-# ###########################################################################
+## ###########################################################################
# Task Definition Functions ...
# Declare a basic task.
@@ -927,12 +950,18 @@ def import(*fns)
end
end
-# ###########################################################################
+#############################################################################
# This a FileUtils extension that defines several additional commands to be
# added to the FileUtils utility functions.
#
module FileUtils
- RUBY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']).
+ RUBY_EXT = ((RbConfig::CONFIG['ruby_install_name'] =~ /\.(com|cmd|exe|bat|rb|sh)$/) ?
+ "" :
+ RbConfig::CONFIG['EXEEXT'])
+
+ RUBY = File.join(
+ RbConfig::CONFIG['bindir'],
+ RbConfig::CONFIG['ruby_install_name'] + RUBY_EXT).
sub(/.*\s.*/m, '"\&"')
OPT_TABLE['sh'] = %w(noop verbose)
@@ -958,7 +987,7 @@ module FileUtils
options = (Hash === cmd.last) ? cmd.pop : {}
unless block_given?
show_command = cmd.join(" ")
- show_command = show_command[0,42] + "..."
+ show_command = show_command[0,42] + "..." unless $trace
# TODO code application logic heref show_command.length > 45
block = lambda { |ok, status|
ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
@@ -974,7 +1003,9 @@ module FileUtils
rake_output_message cmd.join(" ") if options[:verbose]
unless options[:noop]
res = rake_system(*cmd)
- block.call(res, $?)
+ status = $?
+ status = PseudoStatus.new(1) if !res && status.nil?
+ block.call(res, status)
end
end
@@ -1027,7 +1058,7 @@ module FileUtils
end
end
-# ###########################################################################
+#############################################################################
# RakeFileUtils provides a custom version of the FileUtils methods that
# respond to the <tt>verbose</tt> and <tt>nowrite</tt> commands.
#
@@ -1158,7 +1189,7 @@ module RakeFileUtils
extend self
end
-# ###########################################################################
+#############################################################################
# Include the FileUtils file manipulation functions in the top level module,
# but mark them private so that they don't unintentionally define methods on
# other objects.
@@ -1170,7 +1201,7 @@ private(*RakeFileUtils.instance_methods(false))
######################################################################
module Rake
- # #########################################################################
+ ###########################################################################
# A FileList is essentially an array with a few helper methods defined to
# make file manipulation a bit easier.
#
@@ -1228,21 +1259,17 @@ module Rake
# Now do the delegation.
DELEGATING_METHODS.each_with_index do |sym, i|
if SPECIAL_RETURN.include?(sym)
- class_eval <<-END, __FILE__, __LINE__+1
- def #{sym}(*args, &block)
- resolve
- result = @items.send(:#{sym}, *args, &block)
- FileList.new.import(result)
- end
- END
+ define_method(sym) do |*args, &block|
+ resolve
+ result = @items.send(sym, *args, &block)
+ FileList.new.import(result)
+ end
else
- class_eval <<-END, __FILE__, __LINE__+1
- def #{sym}(*args, &block)
- resolve
- result = @items.send(:#{sym}, *args, &block)
- result.object_id == @items.object_id ? self : result
- end
- END
+ define_method(sym) do |*args, &block|
+ resolve
+ result = @items.send(sym, *args, &block)
+ result.object_id == @items.object_id ? self : result
+ end
end
end
@@ -1450,7 +1477,7 @@ module Rake
collect { |fn| fn.pathmap(spec) }
end
- # Return a new file list with <tt>String#ext</tt> method applied
+ # Return a new FileList with <tt>String#ext</tt> method applied
# to each member of the array.
#
# This method is a shortcut for:
@@ -1468,9 +1495,9 @@ module Rake
# name, line number, and the matching line of text. If no block is given,
# a standard emac style file:linenumber:line message will be printed to
# standard out.
- def egrep(pattern, *opt)
+ def egrep(pattern, *options)
each do |fn|
- open(fn, "rb", *opt) do |inf|
+ open(fn, "rb", *options) do |inf|
count = 0
inf.each do |line|
count += 1
@@ -1576,7 +1603,7 @@ end # module Rake
# Alias FileList to be available at the top level.
FileList = Rake::FileList
-# ###########################################################################
+#############################################################################
module Rake
# Default Rakefile loader used by +import+.
@@ -1603,7 +1630,7 @@ module Rake
EARLY = EarlyTime.instance
end # module Rake
-# ###########################################################################
+#############################################################################
# Extensions to time to allow comparisons with an early time class.
#
class Time
@@ -1960,11 +1987,9 @@ module Rake
# application. The define any tasks. Finally, call +top_level+ to run your top
# level tasks.
def run
- standard_exception_handling do
- init
- load_rakefile
- top_level
- end
+ init
+ load_rakefile
+ top_level
end
# Initialize the command line parameters and app name.
@@ -2041,7 +2066,7 @@ module Rake
# Exit with error message
$stderr.puts "#{name} aborted!"
$stderr.puts ex.message
- if options.trace
+ if options.trace or true
$stderr.puts ex.backtrace.join("\n")
else
$stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
@@ -2362,24 +2387,13 @@ module Rake
# The directory path containing the system wide rakefiles.
def system_dir
- @system_dir ||=
- begin
- if ENV['RAKE_SYSTEM']
- ENV['RAKE_SYSTEM']
- else
- standard_system_dir
- end
- end
+ @system_dir ||= ENV['RAKE_SYSTEM'] || standard_system_dir
end
# The standard directory containing system wide rake files.
- if Win32.windows?
- def standard_system_dir #:nodoc:
- Win32.win32_system_dir
- end
- else
+ unless method_defined?(:standard_system_dir)
def standard_system_dir #:nodoc:
- File.expand_path('.rake', '~')
+ File.expand_path('~/.rake')
end
end
private :standard_system_dir
diff --git a/lib/rake/loaders/makefile.rb b/lib/rake/loaders/makefile.rb
index c77d428..9a2ac80 100644
--- a/lib/rake/loaders/makefile.rb
+++ b/lib/rake/loaders/makefile.rb
@@ -21,7 +21,7 @@ module Rake
def process_line(line)
file_tasks, args = line.split(':', 2)
return if args.nil?
- dependents = args.split
+ dependents = args.split.map {|arg| respace(arg)}
file_tasks.scan(/\S+/) do |file_task|
file_task = respace(file_task)
file file_task => dependents
diff --git a/lib/rake/rdoctask.rb b/lib/rake/rdoctask.rb
index de020f4..9198806 100644
--- a/lib/rake/rdoctask.rb
+++ b/lib/rake/rdoctask.rb
@@ -19,7 +19,7 @@ module Rake
# Rebuild the rdoc files from scratch, even if they are not out
# of date.
#
- # Simple example:
+ # Simple Example:
#
# Rake::RDocTask.new do |rd|
# rd.main = "README.rdoc"
@@ -132,7 +132,7 @@ module Rake
args = option_list + @rdoc_files
if @external
argstring = args.join(' ')
- sh %{ruby -Ivendor vender/rd #{argstring}}
+ sh %{ruby -Ivendor vendor/rd #{argstring}}
else
require 'rdoc/rdoc'
RDoc::RDoc.new.document(args)
diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb
index 3444012..c400205 100644
--- a/lib/rake/testtask.rb
+++ b/lib/rake/testtask.rb
@@ -93,7 +93,7 @@ module Rake
# Create the tasks defined by this task lib.
def define
- lib_path = @libs.collect {|path| "-I#{File.expand_path(path)}"}
+ lib_path = @libs.join(File::PATH_SEPARATOR)
desc "Run tests" + (@name==:test ? "" : " for #{@name}")
task @name do
run_code = ''
@@ -103,11 +103,11 @@ module Rake
when :direct
"-e 'ARGV.each{|f| load f}'"
when :testrb
- "-S testrb #{fix}"
+ "-S testrb"
when :rake
rake_loader
end
- @ruby_opts.unshift( *lib_path )
+ @ruby_opts.unshift( "-I\"#{lib_path}\"" )
@ruby_opts.unshift( "-w" ) if @warning
ruby @ruby_opts.join(" ") +
" \"#{run_code}\" " +
@@ -133,15 +133,6 @@ module Rake
end
end
- def fix # :nodoc:
- case RUBY_VERSION
- when '1.8.2'
- find_file 'rake/ruby182_test_unit_fix'
- else
- nil
- end || ''
- end
-
def rake_loader # :nodoc:
find_file('rake/rake_test_loader') or
fail "unable to find rake test loader"
diff --git a/lib/rake/win32.rb b/lib/rake/win32.rb
index 96f66d6..0ab31c2 100644
--- a/lib/rake/win32.rb
+++ b/lib/rake/win32.rb
@@ -5,9 +5,10 @@ module Rake
module Win32
class << self
# True if running on a windows system.
- def windows?
- # assume other DOSish systems are extinct.
- File::ALT_SEPARATOR == '\\'
+ if File::ALT_SEPARATOR == '\\' # assume other DOSish systems are extinct.
+ def windows?; true end
+ else
+ def windows?; false end
end
end
@@ -29,6 +30,17 @@ module Rake
end
File.expand_path('Rake', win32_shared_path)
end
+
+ # Normalize a win32 path so that the slashes are all forward slashes.
+ def normalize(path)
+ path.tr('\\', '/')
+ end
end if windows?
end
+
+ if Win32.windows?
+ def standard_system_dir
+ Win32.win32_system_dir
+ end
+ end
end