rake 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rake might be problematic. Click here for more details.
- data/CHANGES +35 -0
- data/Rakefile +27 -11
- data/doc/jamis.rb +1 -1
- data/doc/rakefile.rdoc +18 -0
- data/doc/release_notes/rake-0.7.2.rdoc +121 -0
- data/lib/rake.rb +308 -279
- data/lib/rake/clean.rb +3 -1
- data/lib/rake/contrib/ftptools.rb +21 -21
- data/lib/rake/contrib/rubyforgepublisher.rb +3 -3
- data/lib/rake/contrib/sshpublisher.rb +1 -1
- data/lib/rake/contrib/sys.rb +20 -21
- data/lib/rake/gempackagetask.rb +9 -8
- data/lib/rake/loaders/makefile.rb +11 -12
- data/lib/rake/packagetask.rb +38 -32
- data/lib/rake/rdoctask.rb +14 -14
- data/lib/rake/ruby182_test_unit_fix.rb +4 -4
- data/lib/rake/runtest.rb +4 -4
- data/lib/rake/testtask.rb +26 -27
- data/test/capture_stdout.rb +26 -0
- data/test/data/unittest/Rakefile +1 -0
- data/test/filecreation.rb +2 -3
- data/test/functional.rb +1 -1
- data/test/reqfile.rb +3 -0
- data/test/reqfile2.rb +3 -0
- data/test/session_functional.rb +2 -2
- data/test/test_application.rb +406 -0
- data/test/test_earlytime.rb +4 -0
- data/test/test_file_creation_task.rb +6 -0
- data/test/test_file_task.rb +1 -2
- data/test/test_filelist.rb +55 -8
- data/test/test_fileutils.rb +107 -9
- data/test/test_namespace.rb +18 -10
- data/test/test_package_task.rb +26 -26
- data/test/test_pathmap.rb +42 -36
- data/test/test_rake.rb +13 -0
- data/test/test_rules.rb +92 -15
- data/test/test_task_manager.rb +13 -13
- data/test/test_tasks.rb +42 -2
- data/test/test_top_level_functions.rb +79 -0
- metadata +54 -44
data/CHANGES
CHANGED
@@ -1,5 +1,40 @@
|
|
1
1
|
= Rake Changelog
|
2
2
|
|
3
|
+
== Pre-Version 0.7.2
|
4
|
+
|
5
|
+
* Error messages are now send to stderr rather than stdout (from
|
6
|
+
Payton Quackenbush).
|
7
|
+
* Better error handling on invalid command line arguments (from Payton
|
8
|
+
Quackenbush).
|
9
|
+
* Added rcov task and updated unit testing for better code coverage.
|
10
|
+
* Fixed some bugs where the application object was going to the global
|
11
|
+
appliation instead of using its own data.
|
12
|
+
* Added square and curly bracket patterns to FileList#include (Tilman
|
13
|
+
Sauerbeck).
|
14
|
+
* Added plain filename support to rule dependents (suggested by Nobu
|
15
|
+
Nakada).
|
16
|
+
* Added pathmap support to rule dependents.
|
17
|
+
* Added a 'tasks' method to a namespace to get a list of tasks
|
18
|
+
associated with the namespace.
|
19
|
+
* Fixed the method name leak from FileUtils (bug found by Glenn
|
20
|
+
Vanderburg).
|
21
|
+
* Added rake_extension to handle detection of extension collisions.
|
22
|
+
* Added test for noop, bad_option and verbose flags to sh command.
|
23
|
+
* Removed dependency on internal fu_xxx functions from FileUtils.
|
24
|
+
* Added a 'shame' task to the Rakefile.
|
25
|
+
* Added tar_command and zip_command options to the Package task.
|
26
|
+
* Added a description to the gem task in GemPackageTask.
|
27
|
+
* Fixed a bug when rules have multiple prerequisites (patch by Joel
|
28
|
+
VanderWerf)
|
29
|
+
* Added a protected 'require "rubygems"' to test/test_application to
|
30
|
+
unbreak cruisecontrol.rb.
|
31
|
+
* Added the handful of RakeFileUtils to the private method as well.
|
32
|
+
* Added block based exclusion.
|
33
|
+
* The clean task will no longer delete 'core' if it is a directory.
|
34
|
+
* Removed rake_dup. Now we just simply rescue a bad dup.
|
35
|
+
* Refactored the FileList reject logic to remove duplication.
|
36
|
+
* Removed if __FILE__ at the end of the rake.rb file.
|
37
|
+
|
3
38
|
== Version 0.7.1
|
4
39
|
|
5
40
|
* Added optional filter parameter to the --tasks command line option.
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright 2003, 2004, 2005 by Jim Weirich (jim@weirichhouse.org)
|
4
4
|
# All rights reserved.
|
5
5
|
|
6
|
-
# This file
|
6
|
+
# This file may be distributed under an MIT style license. See
|
7
7
|
# MIT-LICENSE for details.
|
8
8
|
|
9
9
|
begin
|
@@ -16,13 +16,14 @@ require 'rake/clean'
|
|
16
16
|
require 'rake/testtask'
|
17
17
|
require 'rake/rdoctask'
|
18
18
|
|
19
|
-
CLEAN.include('**/*.o')
|
19
|
+
CLEAN.include('**/*.o', '*.dot')
|
20
20
|
CLOBBER.include('doc/example/main', 'testdata')
|
21
21
|
CLOBBER.include('test/data/**/temp_*')
|
22
22
|
CLOBBER.include('test/data/chains/play.*')
|
23
23
|
CLOBBER.include('test/data/file_creation_task/build')
|
24
24
|
CLOBBER.include('test/data/file_creation_task/src')
|
25
25
|
CLOBBER.include('TAGS')
|
26
|
+
CLOBBER.include('coverage')
|
26
27
|
|
27
28
|
def announce(msg='')
|
28
29
|
STDERR.puts msg
|
@@ -87,6 +88,18 @@ Rake::TestTask.new(:test_contribs) do |t|
|
|
87
88
|
t.warning = true
|
88
89
|
end
|
89
90
|
|
91
|
+
require 'rcov/rcovtask'
|
92
|
+
|
93
|
+
Rcov::RcovTask.new do |t|
|
94
|
+
t.libs << "test"
|
95
|
+
t.rcov_opts = ['-xRakefile', '-xrakefile', '-xpublish.rf', '--text-report']
|
96
|
+
t.test_files = FileList[
|
97
|
+
'test/test*.rb',
|
98
|
+
'test/contrib/test*.rb'
|
99
|
+
]
|
100
|
+
t.verbose = true
|
101
|
+
end
|
102
|
+
|
90
103
|
directory 'testdata'
|
91
104
|
[:test_all, :test_units, :test_contribs, :test_functional].each do |t|
|
92
105
|
task t => ['testdata']
|
@@ -107,9 +120,11 @@ rd = Rake::RDocTask.new("rdoc") { |rdoc|
|
|
107
120
|
rdoc.rdoc_dir = 'html'
|
108
121
|
# rdoc.template = 'kilmer'
|
109
122
|
# rdoc.template = 'css2'
|
110
|
-
rdoc.template = '
|
123
|
+
rdoc.template = 'doc/jamis.rb'
|
111
124
|
rdoc.title = "Rake -- Ruby Make"
|
112
|
-
rdoc.options << '--line-numbers' << '--inline-source' <<
|
125
|
+
rdoc.options << '--line-numbers' << '--inline-source' <<
|
126
|
+
'--main' << 'README' <<
|
127
|
+
'--title' << 'Rake -- Ruby Make'
|
113
128
|
rdoc.rdoc_files.include('README', 'MIT-LICENSE', 'TODO', 'CHANGES')
|
114
129
|
rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
|
115
130
|
rdoc.rdoc_files.exclude(/\bcontrib\b/)
|
@@ -173,10 +188,7 @@ else
|
|
173
188
|
|
174
189
|
s.has_rdoc = true
|
175
190
|
s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
|
176
|
-
s.rdoc_options
|
177
|
-
'--title' << 'Rake -- Ruby Make' <<
|
178
|
-
'--main' << 'README' <<
|
179
|
-
'--line-numbers'
|
191
|
+
s.rdoc_options = rd.options
|
180
192
|
|
181
193
|
#### Author and project details.
|
182
194
|
|
@@ -245,12 +257,12 @@ load "publish.rf" if File.exist? "publish.rf"
|
|
245
257
|
|
246
258
|
desc "Look for TODO and FIXME tags in the code"
|
247
259
|
task :todo do
|
248
|
-
FileList['**/*.rb'].exclude('pkg').egrep
|
260
|
+
FileList['**/*.rb'].exclude('pkg').egrep(/#.*(FIXME|TODO|TBD)/)
|
249
261
|
end
|
250
262
|
|
251
263
|
desc "Look for Debugging print lines"
|
252
264
|
task :dbg do
|
253
|
-
FileList['**/*.rb'].egrep
|
265
|
+
FileList['**/*.rb'].egrep(/\bDBG|\bbreakpoint\b/)
|
254
266
|
end
|
255
267
|
|
256
268
|
desc "List all ruby files"
|
@@ -333,7 +345,7 @@ task :update_version => [:prerelease] do
|
|
333
345
|
if ENV['RELTEST']
|
334
346
|
announce "Release Task Testing, skipping commiting of new version"
|
335
347
|
else
|
336
|
-
sh %{cvs commit -m "Updated to version #{PKG_VERSION}" lib/rake.rb}
|
348
|
+
sh %{cvs commit -m "Updated to version #{PKG_VERSION}" lib/rake.rb} # "
|
337
349
|
end
|
338
350
|
end
|
339
351
|
end
|
@@ -361,3 +373,7 @@ end
|
|
361
373
|
# Require experimental XForge/Metaproject support.
|
362
374
|
|
363
375
|
load 'xforge.rf' if File.exist?('xforge.rf')
|
376
|
+
|
377
|
+
task :where_am_i do
|
378
|
+
puts Rake.original_dir
|
379
|
+
end
|
data/doc/jamis.rb
CHANGED
data/doc/rakefile.rdoc
CHANGED
@@ -356,6 +356,24 @@ resolve in different locations.
|
|
356
356
|
# "one:run" => "one:run"
|
357
357
|
# "one:two:run" => "one:two:run"
|
358
358
|
|
359
|
+
== FileLists
|
360
|
+
|
361
|
+
FileLists are the way Rake manages lists of files. You can treat a
|
362
|
+
FileList as an array of strings for the most part, but FileLists
|
363
|
+
support some additional operations.
|
364
|
+
|
365
|
+
=== Creating a FileList
|
366
|
+
|
367
|
+
Creating a file list is easy. Just give it the list of file names:
|
368
|
+
|
369
|
+
fl = FileList['file1.rb', file2.rb']
|
370
|
+
|
371
|
+
Or give it a glob pattern:
|
372
|
+
|
373
|
+
fl = FileList['*.rb']
|
374
|
+
|
375
|
+
|
376
|
+
|
359
377
|
== Odds and Ends
|
360
378
|
|
361
379
|
=== do/end verses { }
|
@@ -0,0 +1,121 @@
|
|
1
|
+
= Rake 0.7.2 Released
|
2
|
+
|
3
|
+
Version 0.7.2 supplies a bug fix and a few minor enhancements. In
|
4
|
+
particular, the new version fixes an incompatibility with the soon to
|
5
|
+
be released Ruby 1.8.6. We strongly recommend upgrading to Rake 0.7.2
|
6
|
+
in order to be compatible with the new version of Ruby.
|
7
|
+
|
8
|
+
== Changes
|
9
|
+
|
10
|
+
=== Bug Fixes in 0.7.2
|
11
|
+
|
12
|
+
There are quite a number of bug fixes in the new 0.7.2 version of
|
13
|
+
Rake:
|
14
|
+
|
15
|
+
* Removed dependency on internal fu_xxx functions from FileUtils.
|
16
|
+
|
17
|
+
* Error messages are now send to stderr rather than stdout (from
|
18
|
+
Payton Quackenbush).
|
19
|
+
|
20
|
+
* Better error handling on invalid command line arguments (from Payton
|
21
|
+
Quackenbush).
|
22
|
+
|
23
|
+
* Fixed some bugs where the application object was going to the global
|
24
|
+
appliation instead of using its own data.
|
25
|
+
|
26
|
+
* Fixed the method name leak from FileUtils (bug found by Glenn
|
27
|
+
Vanderburg).
|
28
|
+
|
29
|
+
* Added test for noop, bad_option and verbose flags to sh command.
|
30
|
+
|
31
|
+
* Added a description to the gem task in GemPackageTask.
|
32
|
+
|
33
|
+
* Fixed a bug when rules have multiple prerequisites (patch by Joel
|
34
|
+
VanderWerf)
|
35
|
+
|
36
|
+
* Added the handful of RakeFileUtils to the private method as well.
|
37
|
+
|
38
|
+
=== New Features in 0.7.2
|
39
|
+
|
40
|
+
The following new features are available in Rake version 0.7.2:
|
41
|
+
|
42
|
+
* Added square and curly bracket patterns to FileList#include (Tilman
|
43
|
+
Sauerbeck).
|
44
|
+
|
45
|
+
* FileLists can now pass a block to FileList#exclude to exclude files
|
46
|
+
based on calculated values.
|
47
|
+
|
48
|
+
* Added plain filename support to rule dependents (suggested by Nobu
|
49
|
+
Nakada).
|
50
|
+
|
51
|
+
* Added pathmap support to rule dependents. In other words, if a
|
52
|
+
pathmap format (beginning with a '%') is given as a Rake rule
|
53
|
+
dependent, then the name of the depend will be the name of the
|
54
|
+
target with the pathmap format applied.
|
55
|
+
|
56
|
+
* Added a 'tasks' method to a namespace to get a list of tasks
|
57
|
+
associated with the namespace.
|
58
|
+
|
59
|
+
* Added tar_command and zip_command options to the Package task.
|
60
|
+
|
61
|
+
* The clean task will no longer delete 'core' if it is a directory.
|
62
|
+
|
63
|
+
=== Internal Rake Improvements
|
64
|
+
|
65
|
+
The following changes will are mainly internal improvements and
|
66
|
+
refactorings and have little effect on the end user. But they may be
|
67
|
+
of interest to the general public.
|
68
|
+
|
69
|
+
* Added rcov task and updated unit testing for better code coverage.
|
70
|
+
|
71
|
+
* Added a 'shame' task to the Rakefile.
|
72
|
+
|
73
|
+
* Added rake_extension to handle detection of extension collisions.
|
74
|
+
|
75
|
+
* Added a protected 'require "rubygems"' to test/test_application to
|
76
|
+
unbreak cruisecontrol.rb.
|
77
|
+
|
78
|
+
* Removed rake_dup. Now we just simply rescue a bad dup.
|
79
|
+
|
80
|
+
* Refactored the FileList reject logic to remove duplication.
|
81
|
+
|
82
|
+
* Removed if __FILE__ at the end of the rake.rb file.
|
83
|
+
|
84
|
+
== What is Rake
|
85
|
+
|
86
|
+
Rake is a build tool similar to the make program in many ways. But
|
87
|
+
instead of cryptic make recipes, Rake uses standard Ruby code to
|
88
|
+
declare tasks and dependencies. You have the full power of a modern
|
89
|
+
scripting language built right into your build tool.
|
90
|
+
|
91
|
+
== Availability
|
92
|
+
|
93
|
+
The easiest way to get and install rake is via RubyGems ...
|
94
|
+
|
95
|
+
gem install rake (you may need root/admin privileges)
|
96
|
+
|
97
|
+
Otherwise, you can get it from the more traditional places:
|
98
|
+
|
99
|
+
Home Page:: http://rake.rubyforge.org/
|
100
|
+
Download:: http://rubyforge.org/project/showfiles.php?group_id=50
|
101
|
+
|
102
|
+
== Thanks
|
103
|
+
|
104
|
+
As usual, it was input from users that drove a alot of these changes.
|
105
|
+
The following people either contributed patches, made suggestions or
|
106
|
+
made otherwise helpful comments. Thanks to ...
|
107
|
+
|
108
|
+
* Payton Quackenbush -- For several error handling improvements.
|
109
|
+
|
110
|
+
* Glenn Vanderburg -- For finding and fixing the method name leak from
|
111
|
+
FileUtils.
|
112
|
+
|
113
|
+
* Joel VanderWerf -- for finding and fixing a bug in the handling of
|
114
|
+
multiple prerequisites.
|
115
|
+
|
116
|
+
* Tilman Sauerbeck -- For some enhancing FileList to support more
|
117
|
+
advanced file globbing.
|
118
|
+
|
119
|
+
* Nobu Nakada -- For suggesting plain file name support to rule dependents.
|
120
|
+
|
121
|
+
-- Jim Weirich
|
data/lib/rake.rb
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
# referenced as a library via a require statement, but it can be
|
30
30
|
# distributed independently as an application.
|
31
31
|
|
32
|
-
RAKEVERSION = '0.7.
|
32
|
+
RAKEVERSION = '0.7.2'
|
33
33
|
|
34
34
|
require 'rbconfig'
|
35
35
|
require 'ftools'
|
@@ -39,31 +39,41 @@ require 'singleton'
|
|
39
39
|
require 'thread'
|
40
40
|
require 'ostruct'
|
41
41
|
|
42
|
-
|
43
|
-
#
|
44
|
-
#
|
42
|
+
######################################################################
|
43
|
+
# Rake extensions to Module.
|
44
|
+
#
|
45
|
+
class Module
|
45
46
|
|
46
|
-
|
47
|
-
#
|
48
|
-
#
|
49
|
-
|
50
|
-
|
47
|
+
# Check for an existing method in the current class before
|
48
|
+
# extending. IF the method already exists, then a warning is
|
49
|
+
# printed and the extension is not added. Otherwise the block is
|
50
|
+
# yielded and any definitions in the block will take effect.
|
51
|
+
#
|
52
|
+
# Usage:
|
53
|
+
#
|
54
|
+
# class String
|
55
|
+
# rake_extension("xyz") do
|
56
|
+
# def xyz
|
57
|
+
# ...
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
def rake_extension(method)
|
63
|
+
if instance_methods.include?(method)
|
64
|
+
$stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
|
65
|
+
else
|
66
|
+
yield
|
67
|
+
end
|
51
68
|
end
|
52
69
|
end
|
53
70
|
|
54
|
-
[NilClass, FalseClass, TrueClass, Fixnum, Symbol].each do |clazz|
|
55
|
-
clazz.class_eval {
|
56
|
-
# Duplicate an object if it can be duplicated. If it can not be
|
57
|
-
# cloned or duplicated, then just return the original object.
|
58
|
-
def rake_dup() self end
|
59
|
-
}
|
60
|
-
end
|
61
71
|
|
62
72
|
######################################################################
|
63
73
|
# User defined methods to be added to String.
|
64
74
|
#
|
65
75
|
class String
|
66
|
-
|
76
|
+
rake_extension("ext") do
|
67
77
|
# Replace the file extension with +newext+. If there is no
|
68
78
|
# extenson on the string, append the new extension to the end. If
|
69
79
|
# the new extension is not given, or is the empty string, remove
|
@@ -73,14 +83,13 @@ class String
|
|
73
83
|
def ext(newext='')
|
74
84
|
return self.dup if ['.', '..'].include? self
|
75
85
|
if newext != ''
|
76
|
-
|
86
|
+
newext = (newext =~ /^\./) ? newext : ("." + newext)
|
77
87
|
end
|
78
88
|
dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || self + newext
|
79
89
|
end
|
80
90
|
end
|
81
91
|
|
82
|
-
|
83
|
-
unless instance_methods.include? "pathmap"
|
92
|
+
rake_extension("pathmap") do
|
84
93
|
# Explode a path into individual components. Used by +pathmap+.
|
85
94
|
def pathmap_explode
|
86
95
|
head, tail = File.split(self)
|
@@ -147,7 +156,7 @@ class String
|
|
147
156
|
# * <b>%X</b> -- Everything *but* the file extension.
|
148
157
|
# * <b>%s</b> -- The alternate file separater if defined,
|
149
158
|
# otherwise use the standard file separator.
|
150
|
-
#
|
159
|
+
# * <b>%%</b> -- A percent sign.
|
151
160
|
#
|
152
161
|
# The %d specifier can also have a numeric prefix (e.g. '%2d').
|
153
162
|
# If the number is positive, only return (up to) +n+ directories
|
@@ -218,6 +227,8 @@ class String
|
|
218
227
|
result << self
|
219
228
|
when '%s'
|
220
229
|
result << (File::ALT_SEPARATOR || File::SEPARATOR)
|
230
|
+
when '%-'
|
231
|
+
# do nothing
|
221
232
|
when '%%'
|
222
233
|
result << "%"
|
223
234
|
when /%(-?\d+)d/
|
@@ -271,7 +282,8 @@ module Rake
|
|
271
282
|
sibling = self.class.new
|
272
283
|
instance_variables.each do |ivar|
|
273
284
|
value = self.instance_variable_get(ivar)
|
274
|
-
|
285
|
+
new_value = value.clone rescue value
|
286
|
+
sibling.instance_variable_set(ivar, new_value)
|
275
287
|
end
|
276
288
|
sibling
|
277
289
|
end
|
@@ -348,20 +360,20 @@ module Rake
|
|
348
360
|
# Invoke the task if it is needed. Prerequites are invoked first.
|
349
361
|
def invoke
|
350
362
|
@lock.synchronize do
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
363
|
+
if application.options.trace
|
364
|
+
puts "** Invoke #{name} #{format_trace_flags}"
|
365
|
+
end
|
366
|
+
return if @already_invoked
|
367
|
+
@already_invoked = true
|
368
|
+
invoke_prerequisites
|
369
|
+
execute if needed?
|
358
370
|
end
|
359
371
|
end
|
360
372
|
|
361
373
|
# Invoke all the prerequisites of a task.
|
362
374
|
def invoke_prerequisites
|
363
375
|
@prerequisites.each { |n|
|
364
|
-
|
376
|
+
application[n, @scope].invoke
|
365
377
|
}
|
366
378
|
end
|
367
379
|
|
@@ -377,11 +389,11 @@ module Rake
|
|
377
389
|
# Execute the actions associated with this task.
|
378
390
|
def execute
|
379
391
|
if application.options.dryrun
|
380
|
-
|
381
|
-
|
392
|
+
puts "** Execute (dry run) #{name}"
|
393
|
+
return
|
382
394
|
end
|
383
395
|
if application.options.trace
|
384
|
-
|
396
|
+
puts "** Execute #{name}"
|
385
397
|
end
|
386
398
|
application.enhance_with_matching_rule(name) if @actions.empty?
|
387
399
|
@actions.each { |act| result = act.call(self) }
|
@@ -395,7 +407,7 @@ module Rake
|
|
395
407
|
# Timestamp for this task. Basic tasks return the current time for
|
396
408
|
# their time stamp. Other tasks can be more sophisticated.
|
397
409
|
def timestamp
|
398
|
-
@prerequisites.collect { |p|
|
410
|
+
@prerequisites.collect { |p| application[p].timestamp }.max || Time.now
|
399
411
|
end
|
400
412
|
|
401
413
|
# Add a comment to the task. If a comment alread exists, separate
|
@@ -403,9 +415,9 @@ module Rake
|
|
403
415
|
def add_comment(comment)
|
404
416
|
return if ! comment
|
405
417
|
if @comment
|
406
|
-
|
418
|
+
@comment << " / "
|
407
419
|
else
|
408
|
-
|
420
|
+
@comment = ''
|
409
421
|
end
|
410
422
|
@comment << comment
|
411
423
|
end
|
@@ -419,12 +431,12 @@ module Rake
|
|
419
431
|
result << "task needed: #{needed?}\n"
|
420
432
|
result << "timestamp: #{timestamp}\n"
|
421
433
|
result << "pre-requisites: \n"
|
422
|
-
prereqs = @prerequisites.collect {|name|
|
434
|
+
prereqs = @prerequisites.collect {|name| application[name]}
|
423
435
|
prereqs.sort! {|a,b| a.timestamp <=> b.timestamp}
|
424
436
|
prereqs.each do |p|
|
425
|
-
|
437
|
+
result << "--#{p.name} (#{p.timestamp})\n"
|
426
438
|
end
|
427
|
-
latest_prereq = @prerequisites.collect{|n|
|
439
|
+
latest_prereq = @prerequisites.collect{|n| application[n].timestamp}.max
|
428
440
|
result << "latest-prerequisite time: #{latest_prereq}\n"
|
429
441
|
result << "................................\n\n"
|
430
442
|
return result
|
@@ -439,12 +451,12 @@ module Rake
|
|
439
451
|
# the tasks that have been assigned. (Normally used in the unit
|
440
452
|
# tests.)
|
441
453
|
def clear
|
442
|
-
|
454
|
+
Rake.application.clear
|
443
455
|
end
|
444
456
|
|
445
457
|
# List of all defined tasks.
|
446
458
|
def tasks
|
447
|
-
|
459
|
+
Rake.application.tasks
|
448
460
|
end
|
449
461
|
|
450
462
|
# Return a task with the given name. If the task is not currently
|
@@ -452,31 +464,31 @@ module Rake
|
|
452
464
|
# rules are found, but an existing file matches the task name,
|
453
465
|
# assume it is a file task with no dependencies or actions.
|
454
466
|
def [](task_name)
|
455
|
-
|
467
|
+
Rake.application[task_name]
|
456
468
|
end
|
457
469
|
|
458
470
|
# TRUE if the task name is already defined.
|
459
471
|
def task_defined?(task_name)
|
460
|
-
|
472
|
+
Rake.application.lookup(task_name) != nil
|
461
473
|
end
|
462
474
|
|
463
475
|
# Define a task given +args+ and an option block. If a rule with
|
464
476
|
# the given name already exists, the prerequisites and actions are
|
465
477
|
# added to the existing task. Returns the defined task.
|
466
478
|
def define_task(args, &block)
|
467
|
-
|
479
|
+
Rake.application.define_task(self, args, &block)
|
468
480
|
end
|
469
481
|
|
470
482
|
# Define a rule for synthesizing tasks.
|
471
483
|
def create_rule(args, &block)
|
472
|
-
|
484
|
+
Rake.application.create_rule(args, &block)
|
473
485
|
end
|
474
486
|
|
475
487
|
# Apply the scope to the task name according to the rules for
|
476
488
|
# this kind of task. Generic tasks will accept the scope as
|
477
489
|
# part of the name.
|
478
490
|
def scope_name(scope, task_name)
|
479
|
-
|
491
|
+
(scope + [task_name]).join(':')
|
480
492
|
end
|
481
493
|
|
482
494
|
end
|
@@ -502,9 +514,9 @@ module Rake
|
|
502
514
|
# Time stamp for file task.
|
503
515
|
def timestamp
|
504
516
|
if File.exist?(name)
|
505
|
-
|
517
|
+
File.mtime(name.to_s)
|
506
518
|
else
|
507
|
-
|
519
|
+
Rake::EARLY
|
508
520
|
end
|
509
521
|
end
|
510
522
|
|
@@ -513,7 +525,7 @@ module Rake
|
|
513
525
|
# Are there any prerequisites with a later time than the given
|
514
526
|
# time stamp?
|
515
527
|
def out_of_date?(stamp)
|
516
|
-
@prerequisites.any? { |n|
|
528
|
+
@prerequisites.any? { |n| application[n].timestamp > stamp}
|
517
529
|
end
|
518
530
|
|
519
531
|
# ----------------------------------------------------------------
|
@@ -524,7 +536,7 @@ module Rake
|
|
524
536
|
# this kind of task. File based tasks ignore the scope when
|
525
537
|
# creating the name.
|
526
538
|
def scope_name(scope, task_name)
|
527
|
-
|
539
|
+
task_name
|
528
540
|
end
|
529
541
|
end
|
530
542
|
end
|
@@ -555,7 +567,7 @@ module Rake
|
|
555
567
|
class MultiTask < Task
|
556
568
|
def invoke_prerequisites
|
557
569
|
threads = @prerequisites.collect { |p|
|
558
|
-
|
570
|
+
Thread.new(p) { |r| application[r].invoke }
|
559
571
|
}
|
560
572
|
threads.each { |t| t.join }
|
561
573
|
end
|
@@ -710,11 +722,7 @@ module FileUtils
|
|
710
722
|
# end
|
711
723
|
#
|
712
724
|
def sh(*cmd, &block)
|
713
|
-
|
714
|
-
options = cmd.pop
|
715
|
-
else
|
716
|
-
options = {}
|
717
|
-
end
|
725
|
+
options = (Hash === cmd.last) ? cmd.pop : {}
|
718
726
|
unless block_given?
|
719
727
|
show_command = cmd.join(" ")
|
720
728
|
show_command = show_command[0,42] + "..." if show_command.length > 45
|
@@ -722,10 +730,10 @@ module FileUtils
|
|
722
730
|
ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
|
723
731
|
}
|
724
732
|
end
|
725
|
-
|
726
|
-
|
733
|
+
rake_check_options options, :noop, :verbose
|
734
|
+
rake_output_message cmd.join(" ") if options[:verbose]
|
727
735
|
unless options[:noop]
|
728
|
-
res = system(*cmd)
|
736
|
+
res = system(*cmd)
|
729
737
|
block.call(res, $?)
|
730
738
|
end
|
731
739
|
end
|
@@ -736,11 +744,7 @@ module FileUtils
|
|
736
744
|
# ruby %{-pe '$_.upcase!' <README}
|
737
745
|
#
|
738
746
|
def ruby(*args,&block)
|
739
|
-
|
740
|
-
options = args.pop
|
741
|
-
else
|
742
|
-
options = {}
|
743
|
-
end
|
747
|
+
options = (Hash === args.last) ? args.pop : {}
|
744
748
|
if args.length > 1 then
|
745
749
|
sh(*([RUBY] + args + [options]), &block)
|
746
750
|
else
|
@@ -758,7 +762,7 @@ module FileUtils
|
|
758
762
|
else
|
759
763
|
begin
|
760
764
|
ln(*args)
|
761
|
-
rescue StandardError, NotImplementedError
|
765
|
+
rescue StandardError, NotImplementedError => ex
|
762
766
|
LN_SUPPORTED[0] = false
|
763
767
|
cp(*args)
|
764
768
|
end
|
@@ -807,9 +811,9 @@ module RakeFileUtils
|
|
807
811
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
808
812
|
def #{name}( *args, &block )
|
809
813
|
super(
|
810
|
-
|
811
|
-
|
812
|
-
|
814
|
+
*rake_merge_option(args,
|
815
|
+
#{default_options.join(', ')}
|
816
|
+
), &block)
|
813
817
|
end
|
814
818
|
EOS
|
815
819
|
end
|
@@ -852,7 +856,7 @@ module RakeFileUtils
|
|
852
856
|
begin
|
853
857
|
yield
|
854
858
|
ensure
|
855
|
-
|
859
|
+
RakeFileUtils.nowrite_flag = oldvalue
|
856
860
|
end
|
857
861
|
end
|
858
862
|
oldvalue
|
@@ -881,7 +885,7 @@ module RakeFileUtils
|
|
881
885
|
end
|
882
886
|
|
883
887
|
# Merge the given options with the default values.
|
884
|
-
def
|
888
|
+
def rake_merge_option(args, defaults)
|
885
889
|
if Hash === args.last
|
886
890
|
defaults.update(args.last)
|
887
891
|
args.pop
|
@@ -889,10 +893,27 @@ module RakeFileUtils
|
|
889
893
|
args.push defaults
|
890
894
|
args
|
891
895
|
end
|
892
|
-
private :
|
896
|
+
private :rake_merge_option
|
897
|
+
|
898
|
+
# Send the message to the default rake output (which is $stderr).
|
899
|
+
def rake_output_message(message)
|
900
|
+
$stderr.puts(message)
|
901
|
+
end
|
902
|
+
private :rake_output_message
|
903
|
+
|
904
|
+
# Check that the options do not contain options not listed in
|
905
|
+
# +optdecl+. An ArgumentError exception is thrown if non-declared
|
906
|
+
# options are found.
|
907
|
+
def rake_check_options(options, *optdecl)
|
908
|
+
h = options.dup
|
909
|
+
optdecl.each do |name|
|
910
|
+
h.delete name
|
911
|
+
end
|
912
|
+
raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty?
|
913
|
+
end
|
914
|
+
private :rake_check_options
|
893
915
|
|
894
916
|
extend self
|
895
|
-
|
896
917
|
end
|
897
918
|
|
898
919
|
######################################################################
|
@@ -902,6 +923,7 @@ end
|
|
902
923
|
|
903
924
|
include RakeFileUtils
|
904
925
|
private(*FileUtils.instance_methods(false))
|
926
|
+
private(*RakeFileUtils.instance_methods(false))
|
905
927
|
|
906
928
|
######################################################################
|
907
929
|
module Rake
|
@@ -1018,6 +1040,7 @@ module Rake
|
|
1018
1040
|
@pending_add = []
|
1019
1041
|
@pending = false
|
1020
1042
|
@exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup
|
1043
|
+
@exclude_procs = DEFAULT_IGNORE_PROCS.dup
|
1021
1044
|
@exclude_re = nil
|
1022
1045
|
@items = []
|
1023
1046
|
patterns.each { |pattern| include(pattern) }
|
@@ -1034,11 +1057,11 @@ module Rake
|
|
1034
1057
|
def include(*filenames)
|
1035
1058
|
# TODO: check for pending
|
1036
1059
|
filenames.each do |fn|
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1060
|
+
if fn.respond_to? :to_ary
|
1061
|
+
include(*fn.to_ary)
|
1062
|
+
else
|
1063
|
+
@pending_add << fn
|
1064
|
+
end
|
1042
1065
|
end
|
1043
1066
|
@pending = true
|
1044
1067
|
self
|
@@ -1047,7 +1070,9 @@ module Rake
|
|
1047
1070
|
|
1048
1071
|
# Register a list of file name patterns that should be excluded
|
1049
1072
|
# from the list. Patterns may be regular expressions, glob
|
1050
|
-
# patterns or regular strings.
|
1073
|
+
# patterns or regular strings. In addition, a block given to
|
1074
|
+
# exclude will remove entries that return true when given to the
|
1075
|
+
# block.
|
1051
1076
|
#
|
1052
1077
|
# Note that glob patterns are expanded against the file system.
|
1053
1078
|
# If a file is explicitly added to a file list, but does not exist
|
@@ -1064,12 +1089,14 @@ module Rake
|
|
1064
1089
|
# If "a.c" is not a file, then ...
|
1065
1090
|
# FileList['a.c', 'b.c'].exclude("a.*") => ['a.c', 'b.c']
|
1066
1091
|
#
|
1067
|
-
def exclude(*patterns)
|
1068
|
-
patterns.each do |pat|
|
1069
|
-
|
1070
|
-
calculate_exclude_regexp
|
1071
|
-
reject! { |fn| fn =~ @exclude_re }
|
1092
|
+
def exclude(*patterns, &block)
|
1093
|
+
patterns.each do |pat|
|
1094
|
+
@exclude_patterns << pat
|
1072
1095
|
end
|
1096
|
+
if block_given?
|
1097
|
+
@exclude_procs << block
|
1098
|
+
end
|
1099
|
+
resolve_exclude if ! @pending
|
1073
1100
|
self
|
1074
1101
|
end
|
1075
1102
|
|
@@ -1077,7 +1104,9 @@ module Rake
|
|
1077
1104
|
# Clear all the exclude patterns so that we exclude nothing.
|
1078
1105
|
def clear_exclude
|
1079
1106
|
@exclude_patterns = []
|
1107
|
+
@exclude_procs = []
|
1080
1108
|
calculate_exclude_regexp if ! @pending
|
1109
|
+
self
|
1081
1110
|
end
|
1082
1111
|
|
1083
1112
|
# Define equality.
|
@@ -1102,9 +1131,9 @@ module Rake
|
|
1102
1131
|
result = @items * other
|
1103
1132
|
case result
|
1104
1133
|
when Array
|
1105
|
-
|
1134
|
+
FileList.new.import(result)
|
1106
1135
|
else
|
1107
|
-
|
1136
|
+
result
|
1108
1137
|
end
|
1109
1138
|
end
|
1110
1139
|
|
@@ -1125,7 +1154,7 @@ module Rake
|
|
1125
1154
|
case pat
|
1126
1155
|
when Regexp
|
1127
1156
|
ignores << pat
|
1128
|
-
when /[
|
1157
|
+
when /[*?]/
|
1129
1158
|
Dir[pat].each do |p| ignores << p end
|
1130
1159
|
else
|
1131
1160
|
ignores << Regexp.quote(pat)
|
@@ -1141,9 +1170,7 @@ module Rake
|
|
1141
1170
|
|
1142
1171
|
def resolve_add(fn)
|
1143
1172
|
case fn
|
1144
|
-
when
|
1145
|
-
fn.each { |f| self.resolve_add(f) }
|
1146
|
-
when %r{[*?]}
|
1173
|
+
when %r{[*?\[\{]}
|
1147
1174
|
add_matching(fn)
|
1148
1175
|
else
|
1149
1176
|
self << fn
|
@@ -1152,17 +1179,8 @@ module Rake
|
|
1152
1179
|
private :resolve_add
|
1153
1180
|
|
1154
1181
|
def resolve_exclude
|
1155
|
-
|
1156
|
-
|
1157
|
-
when Regexp
|
1158
|
-
reject! { |fn| fn =~ pat }
|
1159
|
-
when /[*.]/
|
1160
|
-
reject_list = Dir[pat]
|
1161
|
-
reject! { |fn| reject_list.include?(fn) }
|
1162
|
-
else
|
1163
|
-
reject! { |fn| fn == pat }
|
1164
|
-
end
|
1165
|
-
end
|
1182
|
+
calculate_exclude_regexp
|
1183
|
+
reject! { |fn| exclude?(fn) }
|
1166
1184
|
self
|
1167
1185
|
end
|
1168
1186
|
private :resolve_exclude
|
@@ -1227,25 +1245,25 @@ module Rake
|
|
1227
1245
|
# file:linenumber:line message will be printed to standard out.
|
1228
1246
|
def egrep(pattern)
|
1229
1247
|
each do |fn|
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1248
|
+
open(fn) do |inf|
|
1249
|
+
count = 0
|
1250
|
+
inf.each do |line|
|
1251
|
+
count += 1
|
1252
|
+
if pattern.match(line)
|
1253
|
+
if block_given?
|
1254
|
+
yield fn, count, line
|
1255
|
+
else
|
1256
|
+
puts "#{fn}:#{count}:#{line}"
|
1257
|
+
end
|
1258
|
+
end
|
1259
|
+
end
|
1260
|
+
end
|
1243
1261
|
end
|
1244
1262
|
end
|
1245
1263
|
|
1246
1264
|
# FileList version of partition. Needed because the nested arrays
|
1247
1265
|
# should be FileLists in this version.
|
1248
|
-
def partition(&block)
|
1266
|
+
def partition(&block) # :nodoc:
|
1249
1267
|
resolve
|
1250
1268
|
result = @items.partition(&block)
|
1251
1269
|
[
|
@@ -1271,15 +1289,17 @@ module Rake
|
|
1271
1289
|
# Should the given file name be excluded?
|
1272
1290
|
def exclude?(fn)
|
1273
1291
|
calculate_exclude_regexp unless @exclude_re
|
1274
|
-
fn =~ @exclude_re
|
1292
|
+
fn =~ @exclude_re || @exclude_procs.any? { |p| p.call(fn) }
|
1275
1293
|
end
|
1276
1294
|
|
1277
1295
|
DEFAULT_IGNORE_PATTERNS = [
|
1278
1296
|
/(^|[\/\\])CVS([\/\\]|$)/,
|
1279
1297
|
/(^|[\/\\])\.svn([\/\\]|$)/,
|
1280
1298
|
/\.bak$/,
|
1281
|
-
|
1282
|
-
|
1299
|
+
/~$/
|
1300
|
+
]
|
1301
|
+
DEFAULT_IGNORE_PROCS = [
|
1302
|
+
proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) }
|
1283
1303
|
]
|
1284
1304
|
@exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup
|
1285
1305
|
|
@@ -1326,9 +1346,9 @@ module Rake
|
|
1326
1346
|
def each_dir_parent(dir)
|
1327
1347
|
old_length = nil
|
1328
1348
|
while dir != '.' && dir.length != old_length
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1349
|
+
yield(dir)
|
1350
|
+
old_length = dir.length
|
1351
|
+
dir = File.dirname(dir)
|
1332
1352
|
end
|
1333
1353
|
end
|
1334
1354
|
end
|
@@ -1398,6 +1418,11 @@ module Rake
|
|
1398
1418
|
def [](name)
|
1399
1419
|
@task_manager.lookup(name, @scope)
|
1400
1420
|
end
|
1421
|
+
|
1422
|
+
# Return the list of tasks defined in this namespace.
|
1423
|
+
def tasks
|
1424
|
+
@task_manager.tasks
|
1425
|
+
end
|
1401
1426
|
end
|
1402
1427
|
|
1403
1428
|
|
@@ -1427,7 +1452,6 @@ module Rake
|
|
1427
1452
|
deps = [deps] unless deps.respond_to?(:to_ary)
|
1428
1453
|
deps = deps.collect {|d| d.to_s }
|
1429
1454
|
task = intern(task_class, task_name)
|
1430
|
-
task.application = self
|
1431
1455
|
task.add_comment(@last_comment)
|
1432
1456
|
@last_comment = nil
|
1433
1457
|
task.enhance(deps, &block)
|
@@ -1444,9 +1468,9 @@ module Rake
|
|
1444
1468
|
def [](task_name, scopes=nil)
|
1445
1469
|
task_name = task_name.to_s
|
1446
1470
|
self.lookup(task_name, scopes) or
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1471
|
+
enhance_with_matching_rule(task_name) or
|
1472
|
+
synthesize_file_task(task_name) or
|
1473
|
+
fail "Don't know how to build task '#{task_name}'"
|
1450
1474
|
end
|
1451
1475
|
|
1452
1476
|
def synthesize_file_task(task_name)
|
@@ -1458,14 +1482,14 @@ module Rake
|
|
1458
1482
|
def resolve_args(args)
|
1459
1483
|
case args
|
1460
1484
|
when Hash
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1485
|
+
fail "Too Many Task Names: #{args.keys.join(' ')}" if args.size > 1
|
1486
|
+
fail "No Task Name Given" if args.size < 1
|
1487
|
+
task_name = args.keys[0]
|
1488
|
+
deps = args[task_name]
|
1489
|
+
deps = [deps] if (String===deps) || (Regexp===deps) || (Proc===deps)
|
1466
1490
|
else
|
1467
|
-
|
1468
|
-
|
1491
|
+
task_name = args
|
1492
|
+
deps = []
|
1469
1493
|
end
|
1470
1494
|
[task_name, deps]
|
1471
1495
|
end
|
@@ -1476,12 +1500,12 @@ module Rake
|
|
1476
1500
|
# the enhanced task or nil of no rule was found.
|
1477
1501
|
def enhance_with_matching_rule(task_name, level=0)
|
1478
1502
|
fail Rake::RuleRecursionOverflowError,
|
1479
|
-
|
1503
|
+
"Rule Recursion Too Deep" if level >= 16
|
1480
1504
|
@rules.each do |pattern, extensions, block|
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1505
|
+
if md = pattern.match(task_name)
|
1506
|
+
task = attempt_rule(task_name, extensions, block, level)
|
1507
|
+
return task if task
|
1508
|
+
end
|
1485
1509
|
end
|
1486
1510
|
nil
|
1487
1511
|
rescue Rake::RuleRecursionOverflowError => ex
|
@@ -1509,13 +1533,13 @@ module Rake
|
|
1509
1533
|
initial_scope ||= @scope
|
1510
1534
|
task_name = task_name.to_s
|
1511
1535
|
if task_name =~ /^rake:/
|
1512
|
-
|
1513
|
-
|
1536
|
+
scopes = []
|
1537
|
+
task_name = task_name.sub(/^rake:/, '')
|
1514
1538
|
elsif task_name =~ /^(\^+)/
|
1515
|
-
|
1516
|
-
|
1539
|
+
scopes = initial_scope[0, initial_scope.size - $1.size]
|
1540
|
+
task_name = task_name.sub(/^(\^+)/, '')
|
1517
1541
|
else
|
1518
|
-
|
1542
|
+
scopes = initial_scope
|
1519
1543
|
end
|
1520
1544
|
lookup_in_scope(task_name, scopes)
|
1521
1545
|
end
|
@@ -1524,10 +1548,10 @@ module Rake
|
|
1524
1548
|
def lookup_in_scope(name, scope)
|
1525
1549
|
n = scope.size
|
1526
1550
|
while n >= 0
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1551
|
+
tn = (scope[0,n] + [name]).join(':')
|
1552
|
+
task = @tasks[tn]
|
1553
|
+
return task if task
|
1554
|
+
n -= 1
|
1531
1555
|
end
|
1532
1556
|
nil
|
1533
1557
|
end
|
@@ -1564,13 +1588,13 @@ module Rake
|
|
1564
1588
|
def attempt_rule(task_name, extensions, block, level)
|
1565
1589
|
sources = make_sources(task_name, extensions)
|
1566
1590
|
prereqs = sources.collect { |source|
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1591
|
+
if File.exist?(source) || Rake::Task.task_defined?(source)
|
1592
|
+
source
|
1593
|
+
elsif parent = enhance_with_matching_rule(sources.first, level+1)
|
1594
|
+
parent.name
|
1595
|
+
else
|
1596
|
+
return nil
|
1597
|
+
end
|
1574
1598
|
}
|
1575
1599
|
task = FileTask.define_task({task_name => prereqs}, &block)
|
1576
1600
|
task.sources = prereqs
|
@@ -1581,14 +1605,20 @@ module Rake
|
|
1581
1605
|
# translation procs.
|
1582
1606
|
def make_sources(task_name, extensions)
|
1583
1607
|
extensions.collect { |ext|
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1608
|
+
case ext
|
1609
|
+
when /^%/
|
1610
|
+
task_name.pathmap(ext)
|
1611
|
+
when %r{/}
|
1612
|
+
ext
|
1613
|
+
when /^\./
|
1614
|
+
task_name.ext(ext)
|
1615
|
+
when String
|
1616
|
+
ext
|
1617
|
+
when Proc
|
1618
|
+
ext.call(task_name)
|
1619
|
+
else
|
1620
|
+
fail "Don't know how to handle rule dependent: #{ext.inspect}"
|
1621
|
+
end
|
1592
1622
|
}.flatten
|
1593
1623
|
end
|
1594
1624
|
|
@@ -1602,48 +1632,49 @@ module Rake
|
|
1602
1632
|
include TaskManager
|
1603
1633
|
|
1604
1634
|
# The original directory where rake was invoked.
|
1605
|
-
attr_reader :original_dir
|
1635
|
+
attr_reader :original_dir, :rakefile
|
1606
1636
|
|
1607
|
-
|
1637
|
+
DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze
|
1608
1638
|
|
1609
1639
|
OPTIONS = [
|
1610
1640
|
['--dry-run', '-n', GetoptLong::NO_ARGUMENT,
|
1611
|
-
|
1641
|
+
"Do a dry run without executing actions."],
|
1612
1642
|
['--help', '-H', GetoptLong::NO_ARGUMENT,
|
1613
|
-
|
1643
|
+
"Display this help message."],
|
1614
1644
|
['--libdir', '-I', GetoptLong::REQUIRED_ARGUMENT,
|
1615
|
-
|
1645
|
+
"Include LIBDIR in the search path for required modules."],
|
1616
1646
|
['--rakelibdir', '-R', GetoptLong::REQUIRED_ARGUMENT,
|
1617
|
-
|
1647
|
+
"Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')"],
|
1618
1648
|
['--nosearch', '-N', GetoptLong::NO_ARGUMENT,
|
1619
|
-
|
1649
|
+
"Do not search parent directories for the Rakefile."],
|
1620
1650
|
['--prereqs', '-P', GetoptLong::NO_ARGUMENT,
|
1621
|
-
|
1651
|
+
"Display the tasks and dependencies, then exit."],
|
1622
1652
|
['--quiet', '-q', GetoptLong::NO_ARGUMENT,
|
1623
|
-
|
1653
|
+
"Do not log messages to standard output."],
|
1624
1654
|
['--rakefile', '-f', GetoptLong::OPTIONAL_ARGUMENT,
|
1625
|
-
|
1655
|
+
"Use FILE as the rakefile."],
|
1626
1656
|
['--require', '-r', GetoptLong::REQUIRED_ARGUMENT,
|
1627
|
-
|
1657
|
+
"Require MODULE before executing rakefile."],
|
1628
1658
|
['--silent', '-s', GetoptLong::NO_ARGUMENT,
|
1629
|
-
|
1659
|
+
"Like --quiet, but also suppresses the 'in directory' announcement."],
|
1630
1660
|
['--tasks', '-T', GetoptLong::OPTIONAL_ARGUMENT,
|
1631
|
-
|
1661
|
+
"Display the tasks (matching optional PATTERN) with descriptions, then exit."],
|
1632
1662
|
['--trace', '-t', GetoptLong::NO_ARGUMENT,
|
1633
|
-
|
1663
|
+
"Turn on invoke/execute tracing, enable full backtrace."],
|
1634
1664
|
['--usage', '-h', GetoptLong::NO_ARGUMENT,
|
1635
|
-
|
1665
|
+
"Display usage."],
|
1636
1666
|
['--verbose', '-v', GetoptLong::NO_ARGUMENT,
|
1637
|
-
|
1667
|
+
"Log message to standard output (default)."],
|
1638
1668
|
['--version', '-V', GetoptLong::NO_ARGUMENT,
|
1639
|
-
|
1669
|
+
"Display the program version."],
|
1640
1670
|
['--classic-namespace', '-C', GetoptLong::NO_ARGUMENT,
|
1641
|
-
|
1671
|
+
"Put Task and FileTask in the top level namespace"],
|
1642
1672
|
]
|
1643
1673
|
|
1644
1674
|
# Create a Rake::Application object.
|
1645
1675
|
def initialize
|
1646
1676
|
super
|
1677
|
+
@rakefiles = DEFAULT_RAKEFILES.dup
|
1647
1678
|
@rakefile = nil
|
1648
1679
|
@pending_imports = []
|
1649
1680
|
@imported = []
|
@@ -1662,11 +1693,11 @@ module Rake
|
|
1662
1693
|
# True if one of the files in RAKEFILES is in the current directory.
|
1663
1694
|
# If a match is found, it is copied into @rakefile.
|
1664
1695
|
def have_rakefile
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1696
|
+
@rakefiles.each do |fn|
|
1697
|
+
if File.exist?(fn) || fn == ''
|
1698
|
+
@rakefile = fn
|
1699
|
+
return true
|
1700
|
+
end
|
1670
1701
|
end
|
1671
1702
|
return false
|
1672
1703
|
end
|
@@ -1683,34 +1714,32 @@ module Rake
|
|
1683
1714
|
puts "Options are ..."
|
1684
1715
|
puts
|
1685
1716
|
OPTIONS.sort.each do |long, short, mode, desc|
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1717
|
+
if mode == GetoptLong::REQUIRED_ARGUMENT
|
1718
|
+
if desc =~ /\b([A-Z]{2,})\b/
|
1719
|
+
long = long + "=#{$1}"
|
1720
|
+
end
|
1721
|
+
end
|
1722
|
+
printf " %-20s (%s)\n", long, short
|
1723
|
+
printf " %s\n", desc
|
1693
1724
|
end
|
1694
1725
|
end
|
1695
1726
|
|
1696
1727
|
# Display the tasks and dependencies.
|
1697
1728
|
def display_tasks_and_comments
|
1698
|
-
displayable_tasks =
|
1699
|
-
|
1729
|
+
displayable_tasks = tasks.select { |t|
|
1730
|
+
t.comment && t.name =~ options.show_task_pattern
|
1700
1731
|
}
|
1701
|
-
width = displayable_tasks.collect { |t|
|
1702
|
-
t.name.length
|
1703
|
-
}.max
|
1732
|
+
width = displayable_tasks.collect { |t| t.name.length }.max
|
1704
1733
|
displayable_tasks.each do |t|
|
1705
|
-
|
1734
|
+
printf "rake %-#{width}s # %s\n", t.name, t.comment
|
1706
1735
|
end
|
1707
1736
|
end
|
1708
1737
|
|
1709
1738
|
# Display the tasks and prerequisites
|
1710
1739
|
def display_prerequisites
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1740
|
+
tasks.each do |t|
|
1741
|
+
puts "rake #{t.name}"
|
1742
|
+
t.prerequisites.each { |pre| puts " #{pre}" }
|
1714
1743
|
end
|
1715
1744
|
end
|
1716
1745
|
|
@@ -1724,26 +1753,26 @@ module Rake
|
|
1724
1753
|
def do_option(opt, value)
|
1725
1754
|
case opt
|
1726
1755
|
when '--dry-run'
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1756
|
+
verbose(true)
|
1757
|
+
nowrite(true)
|
1758
|
+
options.dryrun = true
|
1759
|
+
options.trace = true
|
1731
1760
|
when '--help'
|
1732
|
-
|
1733
|
-
|
1761
|
+
help
|
1762
|
+
exit
|
1734
1763
|
when '--libdir'
|
1735
|
-
|
1764
|
+
$:.push(value)
|
1736
1765
|
when '--nosearch'
|
1737
|
-
|
1766
|
+
options.nosearch = true
|
1738
1767
|
when '--prereqs'
|
1739
|
-
|
1768
|
+
options.show_prereqs = true
|
1740
1769
|
when '--quiet'
|
1741
|
-
|
1770
|
+
verbose(false)
|
1742
1771
|
when '--rakefile'
|
1743
|
-
|
1744
|
-
|
1772
|
+
@rakefiles.clear
|
1773
|
+
@rakefiles << value
|
1745
1774
|
when '--rakelibdir'
|
1746
|
-
|
1775
|
+
options.rakelib = value.split(':')
|
1747
1776
|
when '--require'
|
1748
1777
|
begin
|
1749
1778
|
require value
|
@@ -1755,27 +1784,25 @@ module Rake
|
|
1755
1784
|
end
|
1756
1785
|
end
|
1757
1786
|
when '--silent'
|
1758
|
-
|
1759
|
-
|
1787
|
+
verbose(false)
|
1788
|
+
options.silent = true
|
1760
1789
|
when '--tasks'
|
1761
|
-
|
1762
|
-
|
1790
|
+
options.show_tasks = true
|
1791
|
+
options.show_task_pattern = Regexp.new(value || '.')
|
1763
1792
|
when '--trace'
|
1764
|
-
|
1765
|
-
|
1793
|
+
options.trace = true
|
1794
|
+
verbose(true)
|
1766
1795
|
when '--usage'
|
1767
|
-
|
1768
|
-
|
1796
|
+
usage
|
1797
|
+
exit
|
1769
1798
|
when '--verbose'
|
1770
|
-
|
1799
|
+
verbose(true)
|
1771
1800
|
when '--version'
|
1772
|
-
|
1773
|
-
|
1801
|
+
puts "rake, version #{RAKEVERSION}"
|
1802
|
+
exit
|
1774
1803
|
when '--classic-namespace'
|
1775
|
-
|
1776
|
-
|
1777
|
-
else
|
1778
|
-
fail "Unknown option: #{opt}"
|
1804
|
+
require 'rake/classic_namespace'
|
1805
|
+
options.classic_namespace = true
|
1779
1806
|
end
|
1780
1807
|
end
|
1781
1808
|
|
@@ -1789,11 +1816,11 @@ module Rake
|
|
1789
1816
|
# If class namespaces are requested, set the global options
|
1790
1817
|
# according to the values in the options structure.
|
1791
1818
|
if options.classic_namespace
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1819
|
+
$show_tasks = options.show_tasks
|
1820
|
+
$show_prereqs = options.show_prereqs
|
1821
|
+
$trace = options.trace
|
1822
|
+
$dryrun = options.dryrun
|
1823
|
+
$silent = options.silent
|
1797
1824
|
end
|
1798
1825
|
end
|
1799
1826
|
|
@@ -1817,32 +1844,32 @@ module Rake
|
|
1817
1844
|
def load_rakefile
|
1818
1845
|
here = Dir.pwd
|
1819
1846
|
while ! have_rakefile
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1847
|
+
Dir.chdir("..")
|
1848
|
+
if Dir.pwd == here || options.nosearch
|
1849
|
+
fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})"
|
1850
|
+
end
|
1851
|
+
here = Dir.pwd
|
1825
1852
|
end
|
1826
1853
|
puts "(in #{Dir.pwd})" unless options.silent
|
1827
1854
|
$rakefile = @rakefile
|
1828
1855
|
load File.expand_path(@rakefile) if @rakefile != ''
|
1829
1856
|
options.rakelib.each do |rlib|
|
1830
|
-
|
1857
|
+
Dir["#{rlib}/*.rake"].each do |name| add_import name end
|
1831
1858
|
end
|
1832
1859
|
load_imports
|
1833
1860
|
end
|
1834
1861
|
|
1835
1862
|
# Collect the list of tasks on the command line. If no tasks are
|
1836
|
-
#
|
1863
|
+
# given, return a list containing only the default task.
|
1837
1864
|
# Environmental assignments are processed at this time as well.
|
1838
1865
|
def collect_tasks
|
1839
1866
|
tasks = []
|
1840
1867
|
ARGV.each do |arg|
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1868
|
+
if arg =~ /^(\w+)=(.*)$/
|
1869
|
+
ENV[$1] = $2
|
1870
|
+
else
|
1871
|
+
tasks << arg
|
1872
|
+
end
|
1846
1873
|
end
|
1847
1874
|
tasks.push("default") if tasks.size == 0
|
1848
1875
|
tasks
|
@@ -1856,12 +1883,14 @@ module Rake
|
|
1856
1883
|
# Load the pending list of imported files.
|
1857
1884
|
def load_imports
|
1858
1885
|
while fn = @pending_imports.shift
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1886
|
+
next if @imported.member?(fn)
|
1887
|
+
if fn_task = lookup(fn)
|
1888
|
+
fn_task.invoke
|
1889
|
+
end
|
1890
|
+
ext = File.extname(fn)
|
1891
|
+
loader = @loaders[ext] || @default_loader
|
1892
|
+
loader.load(fn)
|
1893
|
+
@imported << fn
|
1865
1894
|
end
|
1866
1895
|
end
|
1867
1896
|
|
@@ -1876,45 +1905,49 @@ module Rake
|
|
1876
1905
|
def const_warning(const_name)
|
1877
1906
|
@const_warning ||= false
|
1878
1907
|
if ! @const_warning
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1908
|
+
$stderr.puts %{WARNING: Deprecated reference to top-level constant '#{const_name}'} +
|
1909
|
+
%{found at: #{rakefile_location}} # '
|
1910
|
+
$stderr.puts %{ Use --classic-namespace on rake command}
|
1911
|
+
$stderr.puts %{ or 'require "rake/classic_namespace"' in Rakefile}
|
1883
1912
|
end
|
1884
1913
|
@const_warning = true
|
1885
1914
|
end
|
1886
1915
|
|
1887
1916
|
def rakefile_location
|
1888
1917
|
begin
|
1889
|
-
|
1918
|
+
fail
|
1890
1919
|
rescue RuntimeError => ex
|
1891
|
-
|
1920
|
+
ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
|
1892
1921
|
end
|
1893
1922
|
end
|
1894
1923
|
|
1895
1924
|
# Run the +rake+ application.
|
1896
1925
|
def run
|
1897
|
-
handle_options
|
1898
1926
|
begin
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1927
|
+
handle_options
|
1928
|
+
tasks = collect_tasks
|
1929
|
+
load_rakefile
|
1930
|
+
if options.show_tasks
|
1931
|
+
display_tasks_and_comments
|
1932
|
+
elsif options.show_prereqs
|
1933
|
+
display_prerequisites
|
1934
|
+
else
|
1935
|
+
tasks.each { |task_name| self[task_name].invoke }
|
1936
|
+
end
|
1937
|
+
rescue SystemExit, GetoptLong::InvalidOption => ex
|
1938
|
+
# Exit silently
|
1939
|
+
exit(1)
|
1908
1940
|
rescue Exception => ex
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1941
|
+
# Exit with error message
|
1942
|
+
$stderr.puts "rake aborted!"
|
1943
|
+
$stderr.puts ex.message
|
1944
|
+
if options.trace
|
1945
|
+
$stderr.puts ex.backtrace.join("\n")
|
1946
|
+
else
|
1947
|
+
$stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
|
1948
|
+
$stderr.puts "(See full trace by running task with --trace)"
|
1949
|
+
end
|
1950
|
+
exit(1)
|
1918
1951
|
end
|
1919
1952
|
end
|
1920
1953
|
end
|
@@ -1949,7 +1982,3 @@ class Module
|
|
1949
1982
|
end
|
1950
1983
|
end
|
1951
1984
|
end
|
1952
|
-
|
1953
|
-
if __FILE__ == $0 then
|
1954
|
-
Rake::Application.new.run
|
1955
|
-
end
|