drake 0.8.3.1.0.14 → 0.8.4.1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +27 -0
- data/CHANGES.drake +4 -0
- data/README +98 -198
- data/Rakefile +2 -4
- data/Rakefile.drake +0 -4
- data/doc/command_line_usage.rdoc +102 -0
- data/doc/rakefile.rdoc +4 -4
- data/doc/release_notes/rake-0.8.4.rdoc +147 -0
- data/lib/rake.rb +94 -60
- data/lib/rake/alt_system.rb +108 -0
- data/lib/rake/contrib/publisher.rb +1 -1
- data/lib/rake/contrib/sys.rb +1 -1
- data/lib/rake/gempackagetask.rb +0 -6
- data/lib/rake/loaders/makefile.rb +8 -1
- data/lib/rake/packagetask.rb +0 -1
- data/lib/rake/rdoctask.rb +79 -17
- data/lib/rake/testtask.rb +1 -1
- data/lib/rake/win32.rb +11 -10
- data/test/Rakefile.seq +1 -1
- data/test/Rakefile.simple +14 -25
- data/test/check_no_expansion.rb +5 -0
- data/test/data/sample.mf +2 -0
- data/test/rake_test_setup.rb +14 -0
- data/test/session_functional.rb +2 -0
- data/test/test_application.rb +25 -44
- data/test/test_definitions.rb +4 -1
- data/test/test_file_task.rb +20 -16
- data/test/test_filelist.rb +8 -3
- data/test/test_fileutils.rb +45 -44
- data/test/test_invocation_chain.rb +8 -2
- data/test/test_makefile_loader.rb +2 -1
- data/test/test_namespace.rb +30 -11
- data/test/test_package_task.rb +3 -1
- data/test/test_parallel.rb +4 -15
- data/test/test_pathmap.rb +3 -2
- data/test/test_pseudo_status.rb +26 -0
- data/test/test_rdoc_task.rb +88 -0
- data/test/test_require.rb +3 -1
- data/test/test_rules.rb +7 -5
- data/test/test_task_manager.rb +4 -1
- data/test/test_tasks.rb +7 -4
- data/test/test_test_task.rb +2 -0
- data/test/test_top_level_functions.rb +4 -2
- data/test/test_win32.rb +29 -14
- metadata +12 -4
data/Rakefile.drake
CHANGED
@@ -0,0 +1,102 @@
|
|
1
|
+
= Rake Command Line Usage
|
2
|
+
|
3
|
+
Rake is invoked from the command line using:
|
4
|
+
|
5
|
+
% rake [<em>options</em> ...] [<em>VAR</em>=<em>VALUE</em>] [<em>targets</em> ...]
|
6
|
+
|
7
|
+
Options are:
|
8
|
+
|
9
|
+
[<tt><em>name</em>=<em>value</em></tt>]
|
10
|
+
Set the environment variable <em>name</em> to <em>value</em>
|
11
|
+
during the execution of the <b>rake</b> command. You can access
|
12
|
+
the value by using ENV['<em>name</em>'].
|
13
|
+
|
14
|
+
[<tt>--classic-namespace</tt> (-n)]
|
15
|
+
Import the Task, FileTask, and FileCreateTask into the top-level
|
16
|
+
scope to be compatible with older versions of Rake. Alternatively
|
17
|
+
you can include the line <code>require
|
18
|
+
'rake/classic_namespace'</code> in your Rakefile to get the
|
19
|
+
classic behavior.
|
20
|
+
|
21
|
+
[<tt>--describe</tt> _pattern_ (-D)]
|
22
|
+
Describe the tasks (matching optional PATTERN), then exit.
|
23
|
+
|
24
|
+
[<tt>--dry-run</tt> (-n)]
|
25
|
+
Do a dry run. Print the tasks invoked and executed, but do not
|
26
|
+
actually execute any of the actions.
|
27
|
+
|
28
|
+
[<tt>--execute</tt> _code_ (-e)]
|
29
|
+
Execute some Ruby code and exit.
|
30
|
+
|
31
|
+
[<tt>--execute-print</tt> _code_ (-p)]
|
32
|
+
Execute some Ruby code, print the result, and exit.
|
33
|
+
|
34
|
+
[<tt>--execute-continue</tt> _code_ (-p)]
|
35
|
+
Execute some Ruby code, then continue with normal task processing.
|
36
|
+
|
37
|
+
[<tt>--help</tt> (-H)]
|
38
|
+
Display some help text and exit.
|
39
|
+
|
40
|
+
[<tt>--libdir</tt> _directory_ (-I)]
|
41
|
+
Add _directory_ to the list of directories searched for require.
|
42
|
+
|
43
|
+
[<tt>--nosearch</tt> (-N)]
|
44
|
+
Do not search for a Rakefile in parent directories.
|
45
|
+
|
46
|
+
[<tt>--prereqs</tt> (-P)]
|
47
|
+
Display a list of all tasks and their immediate prerequisites.
|
48
|
+
|
49
|
+
[<tt>--quiet</tt> (-q)]
|
50
|
+
Do not echo commands from FileUtils.
|
51
|
+
|
52
|
+
[<tt>--rakefile</tt> _filename_ (-f)]
|
53
|
+
Use _filename_ as the name of the rakefile. The default rakefile
|
54
|
+
names are +rakefile+ and +Rakefile+ (with +rakefile+ taking
|
55
|
+
precedence). If the rakefile is not found in the current
|
56
|
+
directory, +rake+ will search parent directories for a match. The
|
57
|
+
directory where the Rakefile is found will become the current
|
58
|
+
directory for the actions executed in the Rakefile.
|
59
|
+
|
60
|
+
[<tt>--rakelibdir</tt> _rakelibdir_ (-R)]
|
61
|
+
Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')
|
62
|
+
|
63
|
+
[<tt>--require</tt> _name_ (-r)]
|
64
|
+
Require _name_ before executing the Rakefile.
|
65
|
+
|
66
|
+
[<tt>--rules</tt>]
|
67
|
+
Trace the rules resolution.
|
68
|
+
|
69
|
+
[<tt>--silent (-s)</tt>]
|
70
|
+
Like --quiet, but also suppresses the 'in directory' announcement.
|
71
|
+
|
72
|
+
[<tt>--system</tt> (-g)]
|
73
|
+
Use the system wide (global) rakefiles. The project Rakefile is
|
74
|
+
ignored. By default, the system wide rakefiles are used only if no
|
75
|
+
project Rakefile is found. On Unix-like system, the system wide
|
76
|
+
rake files are located in $HOME/.rake. On a windows system they
|
77
|
+
are stored in $APPDATA/Rake.
|
78
|
+
|
79
|
+
[<tt>--no-system</tt> (-G)]
|
80
|
+
Use the project level Rakefile, ignoring the system-wide (global)
|
81
|
+
rakefiles.
|
82
|
+
|
83
|
+
[<tt>--tasks</tt> (-T)]
|
84
|
+
Display a list of the major tasks and their comments. Comments
|
85
|
+
are defined using the "desc" command.
|
86
|
+
|
87
|
+
[<tt>--trace</tt> (-t)]
|
88
|
+
Turn on invoke/execute tracing. Also enable full backtrace on
|
89
|
+
errors.
|
90
|
+
|
91
|
+
[<tt>--usage</tt> (-h)]
|
92
|
+
Display a usage message and exit.
|
93
|
+
|
94
|
+
[<tt>--verbose</tt> (-v)]
|
95
|
+
Echo the Sys commands to standard output.
|
96
|
+
|
97
|
+
[<tt>--version</tt> (-V)]
|
98
|
+
Display the program version and exit.
|
99
|
+
|
100
|
+
In addition, any command line option of the form
|
101
|
+
<em>VAR</em>=<em>VALUE</em> will be added to the environment hash
|
102
|
+
<tt>ENV</tt> and may be tested in the Rakefile.
|
data/doc/rakefile.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Rakefile Format (as of version 0.8.
|
1
|
+
= Rakefile Format (as of version 0.8.3)
|
2
2
|
|
3
3
|
First of all, there is no special format for a Rakefile. A Rakefile
|
4
4
|
contains executable Ruby code. Anything legal in a ruby script is
|
@@ -225,8 +225,8 @@ where we specify default values for the first and last names:
|
|
225
225
|
=== Tasks that Expect Parameters and Have Prerequisites
|
226
226
|
|
227
227
|
Tasks that use parameters have a slightly different format for
|
228
|
-
prerequisites. Use the
|
229
|
-
|
228
|
+
prerequisites. Use the arrow notation to indicate the prerequisites
|
229
|
+
for tasks with arguments. For example:
|
230
230
|
|
231
231
|
task :name, [:first_name, :last_name] => [:pre_name] do |t, args|
|
232
232
|
args.with_defaults(:first_name => "John", :last_name => "Dough")
|
@@ -237,7 +237,7 @@ prerequisites for tasks with arguments. For example:
|
|
237
237
|
=== Deprecated Task Parameters Format
|
238
238
|
|
239
239
|
There is an older format for declaring task parameters that omitted
|
240
|
-
the task array and used the :needs keyword to introduce the
|
240
|
+
the task argument array and used the :needs keyword to introduce the
|
241
241
|
dependencies. That format is still supported for compatibility, but
|
242
242
|
is not recommended for use.
|
243
243
|
|
@@ -0,0 +1,147 @@
|
|
1
|
+
= Rake 0.8.4 Released
|
2
|
+
|
3
|
+
Rake version 0.8.4 is a bug-fix release of rake.
|
4
|
+
|
5
|
+
NOTE: The version of Rake that comes with Ruby 1.9 has diverged
|
6
|
+
slightly from the core Rake code base. Rake 0.8.4 will work
|
7
|
+
with Ruby 1.9, but is not a strict upgrade for the Rake that
|
8
|
+
comes with Ruby 1.9. A (near) future release of Rake will unify
|
9
|
+
those two codebases.
|
10
|
+
|
11
|
+
== Letter Writing Campaign
|
12
|
+
|
13
|
+
Thanks to Aaron Patterson (@tenderlove) and Eric Hodel (@drbrain) for
|
14
|
+
their encouraging support in organizing a letter writing campaign to
|
15
|
+
lobby for the "Warning Free" release of rake 0.8.4. A special callout
|
16
|
+
goes to Jonathan D. Lord, Sr (Dr. Wingnut) whose postcard was the
|
17
|
+
first to actually reach me. (see
|
18
|
+
http://tenderlovemaking.com/2009/02/26/we-need-a-new-version-of-rake/
|
19
|
+
for details)
|
20
|
+
|
21
|
+
== Changes
|
22
|
+
|
23
|
+
=== New Features / Enhancements in Version 0.8.4
|
24
|
+
|
25
|
+
* Case is preserved on rakefile names. (patch from James
|
26
|
+
M. Lawrence/quix)
|
27
|
+
|
28
|
+
* Improved Rakefile case insensitivity testing (patch from Luis
|
29
|
+
Lavena).
|
30
|
+
|
31
|
+
* Windows system dir search order is now: HOME, HOMEDRIVE + HOMEPATH,
|
32
|
+
APPDATA, USERPROFILE (patch from Luis Lavena)
|
33
|
+
|
34
|
+
* MingGW is now recognized as a windows platform. (patch from Luis
|
35
|
+
Lavena)
|
36
|
+
|
37
|
+
=== Bug Fixes in Version 0.8.4
|
38
|
+
|
39
|
+
* Removed reference to manage_gem to fix the warning produced by the
|
40
|
+
gem package task.
|
41
|
+
|
42
|
+
* Fixed stray ARGV option problem that was interfering with
|
43
|
+
Test::Unit::Runner. (patch from Pivotal Labs)
|
44
|
+
|
45
|
+
=== Infrastructure Improvements in Version 0.8.4
|
46
|
+
|
47
|
+
* Numerous fixes to the windows test suite (patch from Luis Lavena).
|
48
|
+
|
49
|
+
* Improved Rakefile case insensitivity testing (patch from Luis
|
50
|
+
Lavena).
|
51
|
+
|
52
|
+
* Better support for windows paths in the test task (patch from Simon
|
53
|
+
Chiang/bahuvrihi)
|
54
|
+
|
55
|
+
== What is Rake
|
56
|
+
|
57
|
+
Rake is a build tool similar to the make program in many ways. But
|
58
|
+
instead of cryptic make recipes, Rake uses standard Ruby code to
|
59
|
+
declare tasks and dependencies. You have the full power of a modern
|
60
|
+
scripting language built right into your build tool.
|
61
|
+
|
62
|
+
== Availability
|
63
|
+
|
64
|
+
The easiest way to get and install rake is via RubyGems ...
|
65
|
+
|
66
|
+
gem install rake (you may need root/admin privileges)
|
67
|
+
|
68
|
+
Otherwise, you can get it from the more traditional places:
|
69
|
+
|
70
|
+
Home Page:: http://rake.rubyforge.org/
|
71
|
+
Download:: http://rubyforge.org/project/showfiles.php?group_id=50
|
72
|
+
GitHub:: git://github.com/jimweirich/rake.git
|
73
|
+
|
74
|
+
== Task Argument Examples
|
75
|
+
|
76
|
+
Prior to version 0.8.0, rake was only able to handle command line
|
77
|
+
arguments of the form NAME=VALUE that were passed into Rake via the
|
78
|
+
ENV hash. Many folks had asked for some kind of simple command line
|
79
|
+
arguments, perhaps using "--" to separate regular task names from
|
80
|
+
argument values on the command line. The problem is that there was no
|
81
|
+
easy way to associate positional arguments on the command line with
|
82
|
+
different tasks. Suppose both tasks :a and :b expect a command line
|
83
|
+
argument: does the first value go with :a? What if :b is run first?
|
84
|
+
Should it then get the first command line argument.
|
85
|
+
|
86
|
+
Rake 0.8.0 solves this problem by explicitly passing values directly
|
87
|
+
to the tasks that need them. For example, if I had a release task
|
88
|
+
that required a version number, I could say:
|
89
|
+
|
90
|
+
rake release[0.8.4]
|
91
|
+
|
92
|
+
And the string "0.8.4" will be passed to the :release task. Multiple
|
93
|
+
arguments can be passed by separating them with a comma, for example:
|
94
|
+
|
95
|
+
rake name[john,doe]
|
96
|
+
|
97
|
+
Just a few words of caution. The rake task name and its arguments
|
98
|
+
need to be a single command line argument to rake. This generally
|
99
|
+
means no spaces. If spaces are needed, then the entire rake +
|
100
|
+
argument string should be quoted. Something like this:
|
101
|
+
|
102
|
+
rake "name[billy bob, smith]"
|
103
|
+
|
104
|
+
(Quoting rules vary between operating systems and shells, so make sure
|
105
|
+
you consult the proper docs for your OS/shell).
|
106
|
+
|
107
|
+
=== Tasks that Expect Parameters
|
108
|
+
|
109
|
+
Parameters are only given to tasks that are setup to expect them. In
|
110
|
+
order to handle named parameters, the task declaration syntax for
|
111
|
+
tasks has been extended slightly.
|
112
|
+
|
113
|
+
For example, a task that needs a first name and last name might be
|
114
|
+
declared as:
|
115
|
+
|
116
|
+
task :name, :first_name, :last_name
|
117
|
+
|
118
|
+
The first argument is still the name of the task (:name in this case).
|
119
|
+
The next to argumements are the names of the parameters expected by
|
120
|
+
:name (:first_name and :last_name in the example).
|
121
|
+
|
122
|
+
To access the values of the paramters, the block defining the task
|
123
|
+
behaviour can now accept a second parameter:
|
124
|
+
|
125
|
+
task :name, :first_name, :last_name do |t, args|
|
126
|
+
puts "First name is #{args.first_name}"
|
127
|
+
puts "Last name is #{args.last_name}"
|
128
|
+
end
|
129
|
+
|
130
|
+
The first argument of the block "t" is always bound to the current
|
131
|
+
task object. The second argument "args" is an open-struct like object
|
132
|
+
that allows access to the task arguments. Extra command line
|
133
|
+
arguments to a task are ignored. Missing command line arguments are
|
134
|
+
given the nil value.
|
135
|
+
|
136
|
+
== Thanks
|
137
|
+
|
138
|
+
As usual, it was input from users that drove a alot of these changes. The
|
139
|
+
following people either contributed patches, made suggestions or made
|
140
|
+
otherwise helpful comments. Thanks to ...
|
141
|
+
|
142
|
+
* James M. Lawrence/quix
|
143
|
+
* Luis Lavena
|
144
|
+
* Pivotal Labs
|
145
|
+
* Simon Chiang/bahuvrihi
|
146
|
+
|
147
|
+
-- Jim Weirich
|
data/lib/rake.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
#--
|
4
4
|
|
5
|
-
# Copyright
|
5
|
+
# Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@weirichhouse.org)
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"), to
|
@@ -29,7 +29,7 @@
|
|
29
29
|
# as a library via a require statement, but it can be distributed
|
30
30
|
# independently as an application.
|
31
31
|
|
32
|
-
RAKEVERSION = '0.8.
|
32
|
+
RAKEVERSION = '0.8.4.1.0.15'
|
33
33
|
|
34
34
|
require 'rbconfig'
|
35
35
|
require 'fileutils'
|
@@ -41,6 +41,8 @@ require 'rake/parallel'
|
|
41
41
|
|
42
42
|
require 'rake/win32'
|
43
43
|
|
44
|
+
$trace = false
|
45
|
+
|
44
46
|
######################################################################
|
45
47
|
# Rake extensions to Module.
|
46
48
|
#
|
@@ -61,7 +63,7 @@ class Module
|
|
61
63
|
# end
|
62
64
|
#
|
63
65
|
def rake_extension(method)
|
64
|
-
if
|
66
|
+
if method_defined?(method)
|
65
67
|
$stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
|
66
68
|
else
|
67
69
|
yield
|
@@ -75,7 +77,7 @@ end # module Module
|
|
75
77
|
#
|
76
78
|
class String
|
77
79
|
rake_extension("ext") do
|
78
|
-
# Replace the file extension with +newext+. If there is no
|
80
|
+
# Replace the file extension with +newext+. If there is no extension on
|
79
81
|
# the string, append the new extension to the end. If the new extension
|
80
82
|
# is not given, or is the empty string, remove any existing extension.
|
81
83
|
#
|
@@ -85,7 +87,7 @@ class String
|
|
85
87
|
if newext != ''
|
86
88
|
newext = (newext =~ /^\./) ? newext : ("." + newext)
|
87
89
|
end
|
88
|
-
|
90
|
+
self.chomp(File.extname(self)) << newext
|
89
91
|
end
|
90
92
|
end
|
91
93
|
|
@@ -162,7 +164,7 @@ class String
|
|
162
164
|
# 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b'
|
163
165
|
# 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
|
164
166
|
#
|
165
|
-
# Also the %d, %p,
|
167
|
+
# Also the %d, %p, %f, %n, %x, and %X operators can take a
|
166
168
|
# pattern/replacement argument to perform simple string substititions on a
|
167
169
|
# particular part of the path. The pattern and replacement are speparated
|
168
170
|
# by a comma and are enclosed by curly braces. The replacement spec comes
|
@@ -208,13 +210,9 @@ class String
|
|
208
210
|
when '%d'
|
209
211
|
result << File.dirname(self)
|
210
212
|
when '%x'
|
211
|
-
result <<
|
213
|
+
result << File.extname(self)
|
212
214
|
when '%X'
|
213
|
-
|
214
|
-
result << $1
|
215
|
-
else
|
216
|
-
result << self
|
217
|
-
end
|
215
|
+
result << self.ext
|
218
216
|
when '%p'
|
219
217
|
result << self
|
220
218
|
when '%s'
|
@@ -309,6 +307,27 @@ module Rake
|
|
309
307
|
end
|
310
308
|
end
|
311
309
|
|
310
|
+
####################################################################
|
311
|
+
# Exit status class for times the system just gives us a nil.
|
312
|
+
class PseudoStatus
|
313
|
+
attr_reader :exitstatus
|
314
|
+
def initialize(code=0)
|
315
|
+
@exitstatus = code
|
316
|
+
end
|
317
|
+
def to_i
|
318
|
+
@exitstatus << 8
|
319
|
+
end
|
320
|
+
def >>(n)
|
321
|
+
to_i >> n
|
322
|
+
end
|
323
|
+
def stopped?
|
324
|
+
false
|
325
|
+
end
|
326
|
+
def exited?
|
327
|
+
true
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
312
331
|
####################################################################
|
313
332
|
# TaskAguments manage the arguments passed to a task.
|
314
333
|
#
|
@@ -822,9 +841,7 @@ module Rake
|
|
822
841
|
# Is this file task needed? Yes if it doesn't exist, or if its time stamp
|
823
842
|
# is out of date.
|
824
843
|
def needed?
|
825
|
-
|
826
|
-
return true if out_of_date?(timestamp)
|
827
|
-
false
|
844
|
+
! File.exist?(name) || out_of_date?(timestamp)
|
828
845
|
end
|
829
846
|
|
830
847
|
# Time stamp for file task.
|
@@ -879,6 +896,7 @@ module Rake
|
|
879
896
|
# parallel using Ruby threads.
|
880
897
|
#
|
881
898
|
class MultiTask < Task
|
899
|
+
private
|
882
900
|
def invoke_prerequisites(args, invocation_chain)
|
883
901
|
threads = @prerequisites.collect { |p|
|
884
902
|
Thread.new(p) { |r| application[r].invoke_with_call_chain(args, invocation_chain) }
|
@@ -1029,7 +1047,9 @@ end
|
|
1029
1047
|
# added to the FileUtils utility functions.
|
1030
1048
|
#
|
1031
1049
|
module FileUtils
|
1032
|
-
RUBY = File.join(
|
1050
|
+
RUBY = File.join(
|
1051
|
+
Config::CONFIG['bindir'],
|
1052
|
+
Config::CONFIG['ruby_install_name'] + Config::CONFIG['EXEEXT']).
|
1033
1053
|
sub(/.*\s.*/m, '"\&"')
|
1034
1054
|
|
1035
1055
|
OPT_TABLE['sh'] = %w(noop verbose)
|
@@ -1055,14 +1075,14 @@ module FileUtils
|
|
1055
1075
|
options = (Hash === cmd.last) ? cmd.pop : {}
|
1056
1076
|
unless block_given?
|
1057
1077
|
show_command = cmd.join(" ")
|
1058
|
-
show_command = show_command[0,42] + "..."
|
1078
|
+
show_command = show_command[0,42] + "..." unless $trace
|
1059
1079
|
# TODO code application logic heref show_command.length > 45
|
1060
1080
|
block = lambda { |ok, status|
|
1061
1081
|
ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
|
1062
1082
|
}
|
1063
1083
|
end
|
1064
1084
|
if RakeFileUtils.verbose_flag == :default
|
1065
|
-
options[:verbose] =
|
1085
|
+
options[:verbose] = true
|
1066
1086
|
else
|
1067
1087
|
options[:verbose] ||= RakeFileUtils.verbose_flag
|
1068
1088
|
end
|
@@ -1071,16 +1091,14 @@ module FileUtils
|
|
1071
1091
|
rake_output_message cmd.join(" ") if options[:verbose]
|
1072
1092
|
unless options[:noop]
|
1073
1093
|
res = rake_system(*cmd)
|
1074
|
-
|
1094
|
+
status = $?
|
1095
|
+
status = PseudoStatus.new(1) if !res && status.nil?
|
1096
|
+
block.call(res, status)
|
1075
1097
|
end
|
1076
1098
|
end
|
1077
1099
|
|
1078
1100
|
def rake_system(*cmd)
|
1079
|
-
|
1080
|
-
Rake::Win32.rake_system(*cmd)
|
1081
|
-
else
|
1082
|
-
system(*cmd)
|
1083
|
-
end
|
1101
|
+
Rake::AltSystem.system(*cmd)
|
1084
1102
|
end
|
1085
1103
|
private :rake_system
|
1086
1104
|
|
@@ -1553,8 +1571,8 @@ module Rake
|
|
1553
1571
|
collect { |fn| fn.pathmap(spec) }
|
1554
1572
|
end
|
1555
1573
|
|
1556
|
-
# Return a new
|
1557
|
-
# member of the array.
|
1574
|
+
# Return a new FileList with <tt>String#ext</tt> method applied
|
1575
|
+
# to each member of the array.
|
1558
1576
|
#
|
1559
1577
|
# This method is a shortcut for:
|
1560
1578
|
#
|
@@ -1571,9 +1589,9 @@ module Rake
|
|
1571
1589
|
# name, line number, and the matching line of text. If no block is given,
|
1572
1590
|
# a standard emac style file:linenumber:line message will be printed to
|
1573
1591
|
# standard out.
|
1574
|
-
def egrep(pattern)
|
1592
|
+
def egrep(pattern, *options)
|
1575
1593
|
each do |fn|
|
1576
|
-
open(fn) do |inf|
|
1594
|
+
open(fn, "rb", *options) do |inf|
|
1577
1595
|
count = 0
|
1578
1596
|
inf.each do |line|
|
1579
1597
|
count += 1
|
@@ -1740,9 +1758,9 @@ module Rake
|
|
1740
1758
|
@task_manager.lookup(name, @scope)
|
1741
1759
|
end
|
1742
1760
|
|
1743
|
-
# Return the list of tasks defined in this
|
1761
|
+
# Return the list of tasks defined in this and nested namespaces.
|
1744
1762
|
def tasks
|
1745
|
-
@task_manager.
|
1763
|
+
@task_manager.tasks_in_scope(@scope)
|
1746
1764
|
end
|
1747
1765
|
end # NameSpace
|
1748
1766
|
|
@@ -1897,6 +1915,15 @@ module Rake
|
|
1897
1915
|
@tasks.values.sort_by { |t| t.name }
|
1898
1916
|
end
|
1899
1917
|
|
1918
|
+
# List of all the tasks defined in the given scope (and its
|
1919
|
+
# sub-scopes).
|
1920
|
+
def tasks_in_scope(scope)
|
1921
|
+
prefix = scope.join(":")
|
1922
|
+
tasks.select { |t|
|
1923
|
+
/^#{prefix}:/ =~ t.name
|
1924
|
+
}
|
1925
|
+
end
|
1926
|
+
|
1900
1927
|
# Clear all tasks in this application.
|
1901
1928
|
def clear
|
1902
1929
|
@tasks.clear
|
@@ -2075,7 +2102,8 @@ module Rake
|
|
2075
2102
|
def init(app_name='rake')
|
2076
2103
|
standard_exception_handling do
|
2077
2104
|
@name = app_name
|
2078
|
-
|
2105
|
+
handle_options
|
2106
|
+
collect_tasks
|
2079
2107
|
end
|
2080
2108
|
end
|
2081
2109
|
|
@@ -2136,13 +2164,13 @@ module Rake
|
|
2136
2164
|
yield
|
2137
2165
|
rescue SystemExit => ex
|
2138
2166
|
# Exit silently with current status
|
2139
|
-
|
2140
|
-
rescue
|
2167
|
+
raise
|
2168
|
+
rescue OptionParser::InvalidOption => ex
|
2141
2169
|
# Exit silently
|
2142
|
-
exit(
|
2170
|
+
exit(false)
|
2143
2171
|
rescue Exception => ex
|
2144
2172
|
# Exit with error message
|
2145
|
-
$stderr.puts "
|
2173
|
+
$stderr.puts "#{name} aborted!"
|
2146
2174
|
$stderr.puts ex.message
|
2147
2175
|
if options.trace
|
2148
2176
|
$stderr.puts ex.backtrace.join("\n")
|
@@ -2150,7 +2178,7 @@ module Rake
|
|
2150
2178
|
$stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
|
2151
2179
|
$stderr.puts "(See full trace by running task with --trace)"
|
2152
2180
|
end
|
2153
|
-
exit(
|
2181
|
+
exit(false)
|
2154
2182
|
end
|
2155
2183
|
end
|
2156
2184
|
|
@@ -2158,7 +2186,10 @@ module Rake
|
|
2158
2186
|
# If a match is found, it is copied into @rakefile.
|
2159
2187
|
def have_rakefile
|
2160
2188
|
@rakefiles.each do |fn|
|
2161
|
-
if File.exist?(fn)
|
2189
|
+
if File.exist?(fn)
|
2190
|
+
others = Dir.glob(fn, File::FNM_CASEFOLD)
|
2191
|
+
return others.size == 1 ? others.first : fn
|
2192
|
+
elsif fn == ''
|
2162
2193
|
return fn
|
2163
2194
|
end
|
2164
2195
|
end
|
@@ -2181,14 +2212,14 @@ module Rake
|
|
2181
2212
|
tty_output? || ENV['RAKE_COLUMNS']
|
2182
2213
|
end
|
2183
2214
|
|
2184
|
-
# Display the tasks and
|
2215
|
+
# Display the tasks and comments.
|
2185
2216
|
def display_tasks_and_comments
|
2186
2217
|
displayable_tasks = tasks.select { |t|
|
2187
2218
|
t.comment && t.name =~ options.show_task_pattern
|
2188
2219
|
}
|
2189
2220
|
if options.full_description
|
2190
2221
|
displayable_tasks.each do |t|
|
2191
|
-
puts "
|
2222
|
+
puts "#{name} #{t.name_with_args}"
|
2192
2223
|
t.full_comment.split("\n").each do |line|
|
2193
2224
|
puts " #{line}"
|
2194
2225
|
end
|
@@ -2247,7 +2278,7 @@ module Rake
|
|
2247
2278
|
# Display the tasks and prerequisites
|
2248
2279
|
def display_prerequisites
|
2249
2280
|
tasks.each do |t|
|
2250
|
-
puts "
|
2281
|
+
puts "#{name} #{t.name}"
|
2251
2282
|
t.prerequisites.each { |pre| puts " #{pre}" }
|
2252
2283
|
end
|
2253
2284
|
end
|
@@ -2371,7 +2402,7 @@ module Rake
|
|
2371
2402
|
verbose(true)
|
2372
2403
|
}
|
2373
2404
|
],
|
2374
|
-
['--verbose', '-v', "Log message to standard output
|
2405
|
+
['--verbose', '-v', "Log message to standard output.",
|
2375
2406
|
lambda { |value| verbose(true) }
|
2376
2407
|
],
|
2377
2408
|
['--version', '-V', "Display the program version.",
|
@@ -2387,18 +2418,18 @@ module Rake
|
|
2387
2418
|
def handle_options
|
2388
2419
|
options.rakelib = ['rakelib']
|
2389
2420
|
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2421
|
+
OptionParser.new do |opts|
|
2422
|
+
opts.banner = "rake [-f rakefile] {options} targets..."
|
2423
|
+
opts.separator ""
|
2424
|
+
opts.separator "Options are ..."
|
2425
|
+
|
2426
|
+
opts.on_tail("-h", "--help", "-H", "Display this help message.") do
|
2427
|
+
puts opts
|
2428
|
+
exit
|
2429
|
+
end
|
2430
|
+
|
2431
|
+
standard_rake_options.each { |args| opts.on(*args) }
|
2432
|
+
end.parse!
|
2402
2433
|
|
2403
2434
|
# If class namespaces are requested, set the global options
|
2404
2435
|
# according to the values in the options structure.
|
@@ -2409,7 +2440,6 @@ module Rake
|
|
2409
2440
|
$dryrun = options.dryrun
|
2410
2441
|
$silent = options.silent
|
2411
2442
|
end
|
2412
|
-
parsed_argv
|
2413
2443
|
end
|
2414
2444
|
|
2415
2445
|
# Similar to the regular Ruby +require+ command, but will check
|
@@ -2479,8 +2509,6 @@ module Rake
|
|
2479
2509
|
begin
|
2480
2510
|
if ENV['RAKE_SYSTEM']
|
2481
2511
|
ENV['RAKE_SYSTEM']
|
2482
|
-
elsif Win32.windows?
|
2483
|
-
Win32.win32_system_dir
|
2484
2512
|
else
|
2485
2513
|
standard_system_dir
|
2486
2514
|
end
|
@@ -2488,17 +2516,23 @@ module Rake
|
|
2488
2516
|
end
|
2489
2517
|
|
2490
2518
|
# The standard directory containing system wide rake files.
|
2491
|
-
|
2492
|
-
|
2519
|
+
if Win32.windows?
|
2520
|
+
def standard_system_dir #:nodoc:
|
2521
|
+
Win32.win32_system_dir
|
2522
|
+
end
|
2523
|
+
else
|
2524
|
+
def standard_system_dir #:nodoc:
|
2525
|
+
File.join(File.expand_path('~'), '.rake')
|
2526
|
+
end
|
2493
2527
|
end
|
2494
2528
|
private :standard_system_dir
|
2495
2529
|
|
2496
2530
|
# Collect the list of tasks on the command line. If no tasks are
|
2497
2531
|
# given, return a list containing only the default task.
|
2498
2532
|
# Environmental assignments are processed at this time as well.
|
2499
|
-
def collect_tasks
|
2533
|
+
def collect_tasks
|
2500
2534
|
@top_level_tasks = []
|
2501
|
-
|
2535
|
+
ARGV.each do |arg|
|
2502
2536
|
if arg =~ /^(\w+)=(.*)$/
|
2503
2537
|
ENV[$1] = $2
|
2504
2538
|
else
|