mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
updated to rake code to rake-0.8.3 source code base
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c5746c45b2
commit
ea94d40f4a
3 changed files with 90 additions and 53 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2008-09-25 Jim Weirich <jim@tardis.local>
|
||||||
|
|
||||||
|
* lib/rake.rb: Update rake source to version 0.8.3. This
|
||||||
|
version includes some fixes for running Rake on windows. (1)
|
||||||
|
better APPDATA/HOMExxx/USERPROFILE integration for system
|
||||||
|
rakefiles, (2) Better handling of the :ruby command when
|
||||||
|
installed in directory containing spaces.
|
||||||
|
|
||||||
Thu Sep 25 11:22:51 2008
|
Thu Sep 25 11:22:51 2008
|
||||||
|
|
||||||
* lib/rdoc*: Update to RDoc 2.2.1 r185.
|
* lib/rdoc*: Update to RDoc 2.2.1 r185.
|
||||||
|
|
81
lib/rake.rb
81
lib/rake.rb
|
@ -29,7 +29,7 @@
|
||||||
# as a library via a require statement, but it can be distributed
|
# as a library via a require statement, but it can be distributed
|
||||||
# independently as an application.
|
# independently as an application.
|
||||||
|
|
||||||
RAKEVERSION = '0.8.2'
|
RAKEVERSION = '0.8.3'
|
||||||
|
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
@ -38,6 +38,8 @@ require 'monitor'
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
require 'ostruct'
|
require 'ostruct'
|
||||||
|
|
||||||
|
require 'rake/win32'
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Rake extensions to Module.
|
# Rake extensions to Module.
|
||||||
#
|
#
|
||||||
|
@ -72,7 +74,7 @@ end # module Module
|
||||||
#
|
#
|
||||||
class String
|
class String
|
||||||
rake_extension("ext") do
|
rake_extension("ext") do
|
||||||
# Replace the file extension with +newext+. If there is no extension on
|
# Replace the file extension with +newext+. If there is no extenson on
|
||||||
# the string, append the new extension to the end. If the new extension
|
# the string, append the new extension to the end. If the new extension
|
||||||
# is not given, or is the empty string, remove any existing extension.
|
# is not given, or is the empty string, remove any existing extension.
|
||||||
#
|
#
|
||||||
|
@ -145,7 +147,7 @@ class String
|
||||||
# * <b>%x</b> -- The file extension of the path. An empty string if there
|
# * <b>%x</b> -- The file extension of the path. An empty string if there
|
||||||
# is no extension.
|
# is no extension.
|
||||||
# * <b>%X</b> -- Everything *but* the file extension.
|
# * <b>%X</b> -- Everything *but* the file extension.
|
||||||
# * <b>%s</b> -- The alternate file separator if defined, otherwise use
|
# * <b>%s</b> -- The alternate file separater if defined, otherwise use
|
||||||
# the standard file separator.
|
# the standard file separator.
|
||||||
# * <b>%%</b> -- A percent sign.
|
# * <b>%%</b> -- A percent sign.
|
||||||
#
|
#
|
||||||
|
@ -160,8 +162,8 @@ class String
|
||||||
# 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
|
# 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
|
||||||
#
|
#
|
||||||
# Also the %d, %p, $f, $n, %x, and %X operators can take a
|
# Also the %d, %p, $f, $n, %x, and %X operators can take a
|
||||||
# pattern/replacement argument to perform simple string substitutions on a
|
# pattern/replacement argument to perform simple string substititions on a
|
||||||
# particular part of the path. The pattern and replacement are separated
|
# particular part of the path. The pattern and replacement are speparated
|
||||||
# by a comma and are enclosed by curly braces. The replacement spec comes
|
# by a comma and are enclosed by curly braces. The replacement spec comes
|
||||||
# after the % character but before the operator letter. (e.g.
|
# after the % character but before the operator letter. (e.g.
|
||||||
# "%{old,new}d"). Muliple replacement specs should be separated by
|
# "%{old,new}d"). Muliple replacement specs should be separated by
|
||||||
|
@ -261,11 +263,6 @@ module Rake
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Error indicating a problem in locating the home directory on a
|
|
||||||
# Win32 system.
|
|
||||||
class Win32HomeError < RuntimeError
|
|
||||||
end
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Rake module singleton methods.
|
# Rake module singleton methods.
|
||||||
#
|
#
|
||||||
|
@ -942,7 +939,8 @@ end
|
||||||
# added to the FileUtils utility functions.
|
# added to the FileUtils utility functions.
|
||||||
#
|
#
|
||||||
module FileUtils
|
module FileUtils
|
||||||
RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).
|
||||||
|
sub(/.*\s.*/m, '"\&"')
|
||||||
|
|
||||||
OPT_TABLE['sh'] = %w(noop verbose)
|
OPT_TABLE['sh'] = %w(noop verbose)
|
||||||
OPT_TABLE['ruby'] = %w(noop verbose)
|
OPT_TABLE['ruby'] = %w(noop verbose)
|
||||||
|
@ -988,23 +986,14 @@ module FileUtils
|
||||||
end
|
end
|
||||||
|
|
||||||
def rake_system(*cmd)
|
def rake_system(*cmd)
|
||||||
if Rake.application.windows?
|
if Rake::Win32.windows?
|
||||||
rake_win32_system(*cmd)
|
Rake::Win32.rake_system(*cmd)
|
||||||
else
|
else
|
||||||
system(*cmd)
|
system(*cmd)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private :rake_system
|
private :rake_system
|
||||||
|
|
||||||
def rake_win32_system(*cmd)
|
|
||||||
if cmd.size == 1
|
|
||||||
system("call #{cmd}")
|
|
||||||
else
|
|
||||||
system(*cmd)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
private :rake_win32_system
|
|
||||||
|
|
||||||
# Run a Ruby interpreter with the given arguments.
|
# Run a Ruby interpreter with the given arguments.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -2047,10 +2036,10 @@ module Rake
|
||||||
yield
|
yield
|
||||||
rescue SystemExit => ex
|
rescue SystemExit => ex
|
||||||
# Exit silently with current status
|
# Exit silently with current status
|
||||||
raise
|
exit(ex.status)
|
||||||
rescue OptionParser::InvalidOption => ex
|
rescue SystemExit, OptionParser::InvalidOption => ex
|
||||||
# Exit silently
|
# Exit silently
|
||||||
exit(false)
|
exit(1)
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
# Exit with error message
|
# Exit with error message
|
||||||
$stderr.puts "rake aborted!"
|
$stderr.puts "rake aborted!"
|
||||||
|
@ -2061,7 +2050,7 @@ module Rake
|
||||||
$stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
|
$stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
|
||||||
$stderr.puts "(See full trace by running task with --trace)"
|
$stderr.puts "(See full trace by running task with --trace)"
|
||||||
end
|
end
|
||||||
exit(false)
|
exit(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2144,7 +2133,7 @@ module Rake
|
||||||
end
|
end
|
||||||
|
|
||||||
def windows?
|
def windows?
|
||||||
Config::CONFIG['host_os'] =~ /mswin/
|
Win32.windows?
|
||||||
end
|
end
|
||||||
|
|
||||||
def truncate(string, width)
|
def truncate(string, width)
|
||||||
|
@ -2345,7 +2334,7 @@ module Rake
|
||||||
rakefile, location = find_rakefile_location
|
rakefile, location = find_rakefile_location
|
||||||
if (! options.ignore_system) &&
|
if (! options.ignore_system) &&
|
||||||
(options.load_system || rakefile.nil?) &&
|
(options.load_system || rakefile.nil?) &&
|
||||||
directory?(system_dir)
|
system_dir && File.directory?(system_dir)
|
||||||
puts "(in #{Dir.pwd})" unless options.silent
|
puts "(in #{Dir.pwd})" unless options.silent
|
||||||
glob("#{system_dir}/*.rake") do |name|
|
glob("#{system_dir}/*.rake") do |name|
|
||||||
add_import name
|
add_import name
|
||||||
|
@ -2374,38 +2363,24 @@ module Rake
|
||||||
|
|
||||||
# The directory path containing the system wide rakefiles.
|
# The directory path containing the system wide rakefiles.
|
||||||
def system_dir
|
def system_dir
|
||||||
if ENV['RAKE_SYSTEM']
|
@system_dir ||=
|
||||||
ENV['RAKE_SYSTEM']
|
begin
|
||||||
elsif windows?
|
if ENV['RAKE_SYSTEM']
|
||||||
win32_system_dir
|
ENV['RAKE_SYSTEM']
|
||||||
else
|
elsif Win32.windows?
|
||||||
standard_system_dir
|
Win32.win32_system_dir
|
||||||
end
|
else
|
||||||
|
standard_system_dir
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# The standard directory containing system wide rake files.
|
# The standard directory containing system wide rake files.
|
||||||
def standard_system_dir #:nodoc:
|
def standard_system_dir #:nodoc:
|
||||||
File.join(File.expand_path('~'), '.rake')
|
File.join(File.expand_path('~'), '.rake')
|
||||||
end
|
end
|
||||||
private :standard_system_dir
|
private :standard_system_dir
|
||||||
|
|
||||||
# The standard directory containing system wide rake files on Win
|
|
||||||
# 32 systems.
|
|
||||||
def win32_system_dir #:nodoc:
|
|
||||||
win32home = File.join(ENV['APPDATA'], 'Rake')
|
|
||||||
unless directory?(win32home)
|
|
||||||
raise Win32HomeError, "Unable to determine home path environment variable."
|
|
||||||
else
|
|
||||||
win32home
|
|
||||||
end
|
|
||||||
end
|
|
||||||
private :win32_system_dir
|
|
||||||
|
|
||||||
def directory?(path)
|
|
||||||
File.directory?(path)
|
|
||||||
end
|
|
||||||
private :directory?
|
|
||||||
|
|
||||||
# Collect the list of tasks on the command line. If no tasks are
|
# Collect the list of tasks on the command line. If no tasks are
|
||||||
# given, return a list containing only the default task.
|
# given, return a list containing only the default task.
|
||||||
# Environmental assignments are processed at this time as well.
|
# Environmental assignments are processed at this time as well.
|
||||||
|
|
54
lib/rake/win32.rb
Normal file
54
lib/rake/win32.rb
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
module Rake
|
||||||
|
|
||||||
|
# Win 32 interface methods for Rake. Windows specific functionality
|
||||||
|
# will be placed here to collect that knowledge in one spot.
|
||||||
|
module Win32
|
||||||
|
|
||||||
|
# Error indicating a problem in locating the home directory on a
|
||||||
|
# Win32 system.
|
||||||
|
class Win32HomeError < RuntimeError
|
||||||
|
end
|
||||||
|
|
||||||
|
class << self
|
||||||
|
# True if running on a windows system.
|
||||||
|
def windows?
|
||||||
|
Config::CONFIG['host_os'] =~ /mswin/
|
||||||
|
end
|
||||||
|
|
||||||
|
# Run a command line on windows.
|
||||||
|
def rake_system(*cmd)
|
||||||
|
if cmd.size == 1
|
||||||
|
system("call #{cmd}")
|
||||||
|
else
|
||||||
|
system(*cmd)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# The standard directory containing system wide rake files on
|
||||||
|
# Win 32 systems. Try the following environment variables (in
|
||||||
|
# order):
|
||||||
|
#
|
||||||
|
# * APPDATA
|
||||||
|
# * HOMEDRIVE + HOMEPATH
|
||||||
|
# * USERPROFILE
|
||||||
|
#
|
||||||
|
# If the above are not defined, the return nil.
|
||||||
|
def win32_system_dir #:nodoc:
|
||||||
|
win32_shared_path = ENV['APPDATA']
|
||||||
|
if win32_shared_path.nil? && ENV['HOMEDRIVE'] && ENV['HOMEPATH']
|
||||||
|
win32_shared_path = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
|
||||||
|
end
|
||||||
|
win32_shared_path ||= ENV['USERPROFILE']
|
||||||
|
raise Win32HomeError, "Unable to determine home path environment variable." if
|
||||||
|
win32_shared_path.nil? or win32_shared_path.empty?
|
||||||
|
normalize(File.join(win32_shared_path, 'Rake'))
|
||||||
|
end
|
||||||
|
|
||||||
|
# Normalize a win32 path so that the slashes are all forward slashes.
|
||||||
|
def normalize(path)
|
||||||
|
path.gsub(/\\/, '/')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue