rake 0.8.0 → 0.8.7

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.
Files changed (62) hide show
  1. data/CHANGES +113 -2
  2. data/README +86 -132
  3. data/Rakefile +41 -13
  4. data/bin/rake +0 -0
  5. data/doc/command_line_usage.rdoc +102 -0
  6. data/doc/rakefile.rdoc +126 -3
  7. data/doc/release_notes/rake-0.7.3.rdoc +0 -0
  8. data/doc/release_notes/rake-0.8.0.rdoc +114 -0
  9. data/doc/release_notes/rake-0.8.2.rdoc +165 -0
  10. data/doc/release_notes/rake-0.8.3.rdoc +112 -0
  11. data/doc/release_notes/rake-0.8.4.rdoc +147 -0
  12. data/doc/release_notes/rake-0.8.5.rdoc +53 -0
  13. data/doc/release_notes/rake-0.8.6.rdoc +55 -0
  14. data/doc/release_notes/rake-0.8.7.rdoc +55 -0
  15. data/lib/rake/alt_system.rb +108 -0
  16. data/lib/rake/contrib/ftptools.rb +24 -10
  17. data/lib/rake/contrib/publisher.rb +1 -1
  18. data/lib/rake/contrib/sys.rb +5 -2
  19. data/lib/rake/gempackagetask.rb +0 -6
  20. data/lib/rake/loaders/makefile.rb +17 -15
  21. data/lib/rake/rdoctask.rb +83 -21
  22. data/lib/rake/ruby182_test_unit_fix.rb +0 -0
  23. data/lib/rake/tasklib.rb +8 -3
  24. data/lib/rake/testtask.rb +1 -1
  25. data/lib/rake/win32.rb +55 -0
  26. data/lib/rake.rb +490 -225
  27. data/test/check_expansion.rb +5 -0
  28. data/test/check_no_expansion.rb +5 -0
  29. data/test/data/file_creation_task/Rakefile +4 -1
  30. data/test/data/sample.mf +6 -1
  31. data/test/filecreation.rb +0 -2
  32. data/test/functional.rb +1 -1
  33. data/test/in_environment.rb +30 -0
  34. data/test/rake_test_setup.rb +21 -2
  35. data/test/session_functional.rb +109 -33
  36. data/test/shellcommand.rb +0 -0
  37. data/test/test_application.rb +269 -96
  38. data/test/test_definitions.rb +4 -1
  39. data/test/test_earlytime.rb +2 -2
  40. data/test/test_file_task.rb +20 -16
  41. data/test/test_filelist.rb +48 -7
  42. data/test/test_fileutils.rb +59 -38
  43. data/test/test_ftp.rb +5 -1
  44. data/test/test_invocation_chain.rb +8 -2
  45. data/test/test_makefile_loader.rb +5 -2
  46. data/test/test_namespace.rb +30 -11
  47. data/test/test_package_task.rb +3 -1
  48. data/test/test_pathmap.rb +3 -2
  49. data/test/test_pseudo_status.rb +26 -0
  50. data/test/test_rake.rb +9 -2
  51. data/test/test_rdoc_task.rb +88 -0
  52. data/test/test_require.rb +3 -1
  53. data/test/test_rules.rb +25 -7
  54. data/test/test_task_arguments.rb +14 -1
  55. data/test/test_task_manager.rb +27 -2
  56. data/test/test_tasklib.rb +12 -0
  57. data/test/test_tasks.rb +72 -54
  58. data/test/test_test_task.rb +2 -0
  59. data/test/test_top_level_functions.rb +4 -2
  60. data/test/test_win32.rb +72 -0
  61. metadata +99 -75
  62. /data/test/contrib/{testsys.rb → test_sys.rb} +0 -0
data/lib/rake.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  #--
4
4
 
5
- # Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich
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,16 +29,19 @@
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.0'
32
+ RAKEVERSION = '0.8.7'
33
33
 
34
34
  require 'rbconfig'
35
- require 'ftools'
36
- require 'getoptlong'
37
35
  require 'fileutils'
38
36
  require 'singleton'
39
- require 'thread'
37
+ require 'monitor'
38
+ require 'optparse'
40
39
  require 'ostruct'
41
40
 
41
+ require 'rake/win32'
42
+
43
+ $trace = false
44
+
42
45
  ######################################################################
43
46
  # Rake extensions to Module.
44
47
  #
@@ -59,7 +62,7 @@ class Module
59
62
  # end
60
63
  #
61
64
  def rake_extension(method)
62
- if instance_methods.include?(method.to_s) || instance_methods.include?(method.to_sym)
65
+ if method_defined?(method)
63
66
  $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
64
67
  else
65
68
  yield
@@ -73,7 +76,7 @@ end # module Module
73
76
  #
74
77
  class String
75
78
  rake_extension("ext") do
76
- # Replace the file extension with +newext+. If there is no extenson on
79
+ # Replace the file extension with +newext+. If there is no extension on
77
80
  # the string, append the new extension to the end. If the new extension
78
81
  # is not given, or is the empty string, remove any existing extension.
79
82
  #
@@ -83,7 +86,7 @@ class String
83
86
  if newext != ''
84
87
  newext = (newext =~ /^\./) ? newext : ("." + newext)
85
88
  end
86
- dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || self + newext
89
+ self.chomp(File.extname(self)) << newext
87
90
  end
88
91
  end
89
92
 
@@ -160,7 +163,7 @@ class String
160
163
  # 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b'
161
164
  # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
162
165
  #
163
- # Also the %d, %p, $f, $n, %x, and %X operators can take a
166
+ # Also the %d, %p, %f, %n, %x, and %X operators can take a
164
167
  # pattern/replacement argument to perform simple string substititions on a
165
168
  # particular part of the path. The pattern and replacement are speparated
166
169
  # by a comma and are enclosed by curly braces. The replacement spec comes
@@ -206,13 +209,9 @@ class String
206
209
  when '%d'
207
210
  result << File.dirname(self)
208
211
  when '%x'
209
- result << $1 if self =~ /[^\/](\.[^.]+)$/
212
+ result << File.extname(self)
210
213
  when '%X'
211
- if self =~ /^(.*[^\/])(\.[^.]+)$/
212
- result << $1
213
- else
214
- result << self
215
- end
214
+ result << self.ext
216
215
  when '%p'
217
216
  result << self
218
217
  when '%s'
@@ -240,6 +239,28 @@ end # class String
240
239
  ##############################################################################
241
240
  module Rake
242
241
 
242
+ # Errors -----------------------------------------------------------
243
+
244
+ # Error indicating an ill-formed task declaration.
245
+ class TaskArgumentError < ArgumentError
246
+ end
247
+
248
+ # Error indicating a recursion overflow error in task selection.
249
+ class RuleRecursionOverflowError < StandardError
250
+ def initialize(*args)
251
+ super
252
+ @targets = []
253
+ end
254
+
255
+ def add_target(target)
256
+ @targets << target
257
+ end
258
+
259
+ def message
260
+ super + ": [" + @targets.reverse.join(' => ') + "]"
261
+ end
262
+ end
263
+
243
264
  # --------------------------------------------------------------------------
244
265
  # Rake module singleton methods.
245
266
  #
@@ -261,22 +282,49 @@ module Rake
261
282
 
262
283
  end
263
284
 
264
- # ##########################################################################
285
+ ####################################################################
265
286
  # Mixin for creating easily cloned objects.
266
287
  #
267
288
  module Cloneable
268
289
  # Clone an object by making a new object and setting all the instance
269
290
  # variables to the same values.
270
- def clone
291
+ def dup
271
292
  sibling = self.class.new
272
293
  instance_variables.each do |ivar|
273
294
  value = self.instance_variable_get(ivar)
274
295
  new_value = value.clone rescue value
275
296
  sibling.instance_variable_set(ivar, new_value)
276
297
  end
298
+ sibling.taint if tainted?
299
+ sibling
300
+ end
301
+
302
+ def clone
303
+ sibling = dup
304
+ sibling.freeze if frozen?
277
305
  sibling
278
306
  end
279
- alias dup clone
307
+ end
308
+
309
+ ####################################################################
310
+ # Exit status class for times the system just gives us a nil.
311
+ class PseudoStatus
312
+ attr_reader :exitstatus
313
+ def initialize(code=0)
314
+ @exitstatus = code
315
+ end
316
+ def to_i
317
+ @exitstatus << 8
318
+ end
319
+ def >>(n)
320
+ to_i >> n
321
+ end
322
+ def stopped?
323
+ false
324
+ end
325
+ def exited?
326
+ true
327
+ end
280
328
  end
281
329
 
282
330
  ####################################################################
@@ -287,12 +335,15 @@ module Rake
287
335
 
288
336
  attr_reader :names
289
337
 
338
+ # Create a TaskArgument object with a list of named arguments
339
+ # (given by :names) and a set of associated values (given by
340
+ # :values). :parent is the parent argument object.
290
341
  def initialize(names, values, parent=nil)
291
342
  @names = names
292
343
  @parent = parent
293
344
  @hash = {}
294
345
  names.each_with_index { |name, i|
295
- @hash[name.to_sym] = values[i]
346
+ @hash[name.to_sym] = values[i] unless values[i].nil?
296
347
  }
297
348
  end
298
349
 
@@ -308,6 +359,13 @@ module Rake
308
359
  lookup(index.to_sym)
309
360
  end
310
361
 
362
+ # Specify a hash of default values for task arguments. Use the
363
+ # defaults only if there is no specific value for the given
364
+ # argument.
365
+ def with_defaults(defaults)
366
+ @hash = defaults.merge(@hash)
367
+ end
368
+
311
369
  def each(&block)
312
370
  @hash.each(&block)
313
371
  end
@@ -343,6 +401,8 @@ module Rake
343
401
  end
344
402
  end
345
403
 
404
+ EMPTY_TASK_ARGS = TaskArguments.new([], [])
405
+
346
406
  ####################################################################
347
407
  # InvocationChain tracks the chain of task invocations to detect
348
408
  # circular dependencies.
@@ -397,7 +457,7 @@ end # module Rake
397
457
 
398
458
  module Rake
399
459
 
400
- # #########################################################################
460
+ ###########################################################################
401
461
  # A Task is the basic unit of work in a Rakefile. Tasks have associated
402
462
  # actions (possibly more than one) and a list of prerequisites. When
403
463
  # invoked, a task will first ensure that all of its prerequisites have an
@@ -410,6 +470,9 @@ module Rake
410
470
  # List of prerequisites for a task.
411
471
  attr_reader :prerequisites
412
472
 
473
+ # List of actions attached to a task.
474
+ attr_reader :actions
475
+
413
476
  # Application owning this task.
414
477
  attr_accessor :application
415
478
 
@@ -447,12 +510,12 @@ module Rake
447
510
  # +enhance+ to add actions and prerequisites.
448
511
  def initialize(task_name, app)
449
512
  @name = task_name.to_s
450
- @prerequisites = FileList[]
513
+ @prerequisites = []
451
514
  @actions = []
452
515
  @already_invoked = false
453
516
  @full_comment = nil
454
517
  @comment = nil
455
- @lock = Mutex.new
518
+ @lock = Monitor.new
456
519
  @application = app
457
520
  @scope = app.current_scope
458
521
  @arg_names = nil
@@ -489,6 +552,31 @@ module Rake
489
552
  @arg_names || []
490
553
  end
491
554
 
555
+ # Reenable the task, allowing its tasks to be executed if the task
556
+ # is invoked again.
557
+ def reenable
558
+ @already_invoked = false
559
+ end
560
+
561
+ # Clear the existing prerequisites and actions of a rake task.
562
+ def clear
563
+ clear_prerequisites
564
+ clear_actions
565
+ self
566
+ end
567
+
568
+ # Clear the existing prerequisites of a rake task.
569
+ def clear_prerequisites
570
+ prerequisites.clear
571
+ self
572
+ end
573
+
574
+ # Clear the existing actions on a rake task.
575
+ def clear_actions
576
+ actions.clear
577
+ self
578
+ end
579
+
492
580
  # Invoke the task if it is needed. Prerequites are invoked first.
493
581
  def invoke(*args)
494
582
  task_args = TaskArguments.new(arg_names, args)
@@ -497,7 +585,7 @@ module Rake
497
585
 
498
586
  # Same as invoke, but explicitly pass a call chain to detect
499
587
  # circular dependencies.
500
- def invoke_with_call_chain(task_args, invocation_chain)
588
+ def invoke_with_call_chain(task_args, invocation_chain) # :nodoc:
501
589
  new_chain = InvocationChain.append(self, invocation_chain)
502
590
  @lock.synchronize do
503
591
  if application.options.trace
@@ -512,7 +600,7 @@ module Rake
512
600
  protected :invoke_with_call_chain
513
601
 
514
602
  # Invoke all the prerequisites of a task.
515
- def invoke_prerequisites(task_args, invocation_chain)
603
+ def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
516
604
  @prerequisites.each { |n|
517
605
  prereq = application[n, @scope]
518
606
  prereq_args = task_args.new_scope(prereq.arg_names)
@@ -530,7 +618,8 @@ module Rake
530
618
  private :format_trace_flags
531
619
 
532
620
  # Execute the actions associated with this task.
533
- def execute(args)
621
+ def execute(args=nil)
622
+ args ||= EMPTY_TASK_ARGS
534
623
  if application.options.dryrun
535
624
  puts "** Execute (dry run) #{name}"
536
625
  return
@@ -668,7 +757,7 @@ module Rake
668
757
  end # class Rake::Task
669
758
 
670
759
 
671
- # #########################################################################
760
+ ###########################################################################
672
761
  # A FileTask is a task that includes time based dependencies. If any of a
673
762
  # FileTask's prerequisites have a timestamp that is later than the file
674
763
  # represented by this task, then the file must be rebuilt (using the
@@ -679,9 +768,7 @@ module Rake
679
768
  # Is this file task needed? Yes if it doesn't exist, or if its time stamp
680
769
  # is out of date.
681
770
  def needed?
682
- return true unless File.exist?(name)
683
- return true if out_of_date?(timestamp)
684
- false
771
+ ! File.exist?(name) || out_of_date?(timestamp)
685
772
  end
686
773
 
687
774
  # Time stamp for file task.
@@ -712,7 +799,7 @@ module Rake
712
799
  end
713
800
  end # class Rake::FileTask
714
801
 
715
- # #########################################################################
802
+ ###########################################################################
716
803
  # A FileCreationTask is a file task that when used as a dependency will be
717
804
  # needed if and only if the file has not been created. Once created, it is
718
805
  # not re-triggered if any of its dependencies are newer, nor does trigger
@@ -731,11 +818,12 @@ module Rake
731
818
  end
732
819
  end
733
820
 
734
- # #########################################################################
821
+ ###########################################################################
735
822
  # Same as a regular task, but the immediate prerequisites are done in
736
823
  # parallel using Ruby threads.
737
824
  #
738
825
  class MultiTask < Task
826
+ private
739
827
  def invoke_prerequisites(args, invocation_chain)
740
828
  threads = @prerequisites.collect { |p|
741
829
  Thread.new(p) { |r| application[r].invoke_with_call_chain(args, invocation_chain) }
@@ -745,7 +833,7 @@ module Rake
745
833
  end
746
834
  end # module Rake
747
835
 
748
- # ###########################################################################
836
+ ## ###########################################################################
749
837
  # Task Definition Functions ...
750
838
 
751
839
  # Declare a basic task.
@@ -773,8 +861,8 @@ end
773
861
  # end
774
862
  # end
775
863
  #
776
- def file(args, &block)
777
- Rake::FileTask.define_task(args, &block)
864
+ def file(*args, &block)
865
+ Rake::FileTask.define_task(*args, &block)
778
866
  end
779
867
 
780
868
  # Declare a file creation task.
@@ -864,12 +952,19 @@ def import(*fns)
864
952
  end
865
953
  end
866
954
 
867
- # ###########################################################################
955
+ #############################################################################
868
956
  # This a FileUtils extension that defines several additional commands to be
869
957
  # added to the FileUtils utility functions.
870
958
  #
871
959
  module FileUtils
872
- RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
960
+ RUBY_EXT = ((Config::CONFIG['ruby_install_name'] =~ /\.(com|cmd|exe|bat|rb|sh)$/) ?
961
+ "" :
962
+ Config::CONFIG['EXEEXT'])
963
+
964
+ RUBY = File.join(
965
+ Config::CONFIG['bindir'],
966
+ Config::CONFIG['ruby_install_name'] + RUBY_EXT).
967
+ sub(/.*\s.*/m, '"\&"')
873
968
 
874
969
  OPT_TABLE['sh'] = %w(noop verbose)
875
970
  OPT_TABLE['ruby'] = %w(noop verbose)
@@ -894,20 +989,33 @@ module FileUtils
894
989
  options = (Hash === cmd.last) ? cmd.pop : {}
895
990
  unless block_given?
896
991
  show_command = cmd.join(" ")
897
- show_command = show_command[0,42] + "..."
992
+ show_command = show_command[0,42] + "..." unless $trace
898
993
  # TODO code application logic heref show_command.length > 45
899
994
  block = lambda { |ok, status|
900
995
  ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
901
996
  }
902
997
  end
998
+ if RakeFileUtils.verbose_flag == :default
999
+ options[:verbose] = true
1000
+ else
1001
+ options[:verbose] ||= RakeFileUtils.verbose_flag
1002
+ end
1003
+ options[:noop] ||= RakeFileUtils.nowrite_flag
903
1004
  rake_check_options options, :noop, :verbose
904
1005
  rake_output_message cmd.join(" ") if options[:verbose]
905
1006
  unless options[:noop]
906
- res = system(*cmd)
907
- block.call(res, $?)
1007
+ res = rake_system(*cmd)
1008
+ status = $?
1009
+ status = PseudoStatus.new(1) if !res && status.nil?
1010
+ block.call(res, status)
908
1011
  end
909
1012
  end
910
1013
 
1014
+ def rake_system(*cmd)
1015
+ Rake::AltSystem.system(*cmd)
1016
+ end
1017
+ private :rake_system
1018
+
911
1019
  # Run a Ruby interpreter with the given arguments.
912
1020
  #
913
1021
  # Example:
@@ -952,7 +1060,7 @@ module FileUtils
952
1060
  end
953
1061
  end
954
1062
 
955
- # ###########################################################################
1063
+ #############################################################################
956
1064
  # RakeFileUtils provides a custom version of the FileUtils methods that
957
1065
  # respond to the <tt>verbose</tt> and <tt>nowrite</tt> commands.
958
1066
  #
@@ -962,7 +1070,7 @@ module RakeFileUtils
962
1070
  class << self
963
1071
  attr_accessor :verbose_flag, :nowrite_flag
964
1072
  end
965
- RakeFileUtils.verbose_flag = true
1073
+ RakeFileUtils.verbose_flag = :default
966
1074
  RakeFileUtils.nowrite_flag = false
967
1075
 
968
1076
  $fileutils_verbose = true
@@ -970,10 +1078,10 @@ module RakeFileUtils
970
1078
 
971
1079
  FileUtils::OPT_TABLE.each do |name, opts|
972
1080
  default_options = []
973
- if opts.include?('verbose')
1081
+ if opts.include?(:verbose) || opts.include?("verbose")
974
1082
  default_options << ':verbose => RakeFileUtils.verbose_flag'
975
1083
  end
976
- if opts.include?('noop')
1084
+ if opts.include?(:noop) || opts.include?("noop")
977
1085
  default_options << ':noop => RakeFileUtils.nowrite_flag'
978
1086
  end
979
1087
 
@@ -1083,7 +1191,7 @@ module RakeFileUtils
1083
1191
  extend self
1084
1192
  end
1085
1193
 
1086
- # ###########################################################################
1194
+ #############################################################################
1087
1195
  # Include the FileUtils file manipulation functions in the top level module,
1088
1196
  # but mark them private so that they don't unintentionally define methods on
1089
1197
  # other objects.
@@ -1095,22 +1203,7 @@ private(*RakeFileUtils.instance_methods(false))
1095
1203
  ######################################################################
1096
1204
  module Rake
1097
1205
 
1098
- class RuleRecursionOverflowError < StandardError
1099
- def initialize(*args)
1100
- super
1101
- @targets = []
1102
- end
1103
-
1104
- def add_target(target)
1105
- @targets << target
1106
- end
1107
-
1108
- def message
1109
- super + ": [" + @targets.reverse.join(' => ') + "]"
1110
- end
1111
- end
1112
-
1113
- # #########################################################################
1206
+ ###########################################################################
1114
1207
  # A FileList is essentially an array with a few helper methods defined to
1115
1208
  # make file manipulation a bit easier.
1116
1209
  #
@@ -1392,8 +1485,8 @@ module Rake
1392
1485
  collect { |fn| fn.pathmap(spec) }
1393
1486
  end
1394
1487
 
1395
- # Return a new array with <tt>String#ext</tt> method applied to each
1396
- # member of the array.
1488
+ # Return a new FileList with <tt>String#ext</tt> method applied
1489
+ # to each member of the array.
1397
1490
  #
1398
1491
  # This method is a shortcut for:
1399
1492
  #
@@ -1410,9 +1503,9 @@ module Rake
1410
1503
  # name, line number, and the matching line of text. If no block is given,
1411
1504
  # a standard emac style file:linenumber:line message will be printed to
1412
1505
  # standard out.
1413
- def egrep(pattern)
1506
+ def egrep(pattern, *options)
1414
1507
  each do |fn|
1415
- open(fn) do |inf|
1508
+ open(fn, "rb", *options) do |inf|
1416
1509
  count = 0
1417
1510
  inf.each do |line|
1418
1511
  count += 1
@@ -1504,7 +1597,7 @@ module Rake
1504
1597
  class << self
1505
1598
 
1506
1599
  # Yield each file or directory component.
1507
- def each_dir_parent(dir)
1600
+ def each_dir_parent(dir) # :nodoc:
1508
1601
  old_length = nil
1509
1602
  while dir != '.' && dir.length != old_length
1510
1603
  yield(dir)
@@ -1518,7 +1611,7 @@ end # module Rake
1518
1611
  # Alias FileList to be available at the top level.
1519
1612
  FileList = Rake::FileList
1520
1613
 
1521
- # ###########################################################################
1614
+ #############################################################################
1522
1615
  module Rake
1523
1616
 
1524
1617
  # Default Rakefile loader used by +import+.
@@ -1545,7 +1638,7 @@ module Rake
1545
1638
  EARLY = EarlyTime.instance
1546
1639
  end # module Rake
1547
1640
 
1548
- # ###########################################################################
1641
+ #############################################################################
1549
1642
  # Extensions to time to allow comparisons with an early time class.
1550
1643
  #
1551
1644
  class Time
@@ -1579,9 +1672,9 @@ module Rake
1579
1672
  @task_manager.lookup(name, @scope)
1580
1673
  end
1581
1674
 
1582
- # Return the list of tasks defined in this namespace.
1675
+ # Return the list of tasks defined in this and nested namespaces.
1583
1676
  def tasks
1584
- @task_manager.tasks
1677
+ @task_manager.tasks_in_scope(@scope)
1585
1678
  end
1586
1679
  end # NameSpace
1587
1680
 
@@ -1643,23 +1736,65 @@ module Rake
1643
1736
  # Resolve the arguments for a task/rule. Returns a triplet of
1644
1737
  # [task_name, arg_name_list, prerequisites].
1645
1738
  def resolve_args(args)
1739
+ if args.last.is_a?(Hash)
1740
+ deps = args.pop
1741
+ resolve_args_with_dependencies(args, deps)
1742
+ else
1743
+ resolve_args_without_dependencies(args)
1744
+ end
1745
+ end
1746
+
1747
+ # Resolve task arguments for a task or rule when there are no
1748
+ # dependencies declared.
1749
+ #
1750
+ # The patterns recognized by this argument resolving function are:
1751
+ #
1752
+ # task :t
1753
+ # task :t, [:a]
1754
+ # task :t, :a (deprecated)
1755
+ #
1756
+ def resolve_args_without_dependencies(args)
1646
1757
  task_name = args.shift
1647
- arg_names = args #.map { |a| a.to_sym }
1648
- needs = []
1649
- if task_name.is_a?(Hash)
1650
- hash = task_name
1651
- task_name = hash.keys[0]
1652
- needs = hash[task_name]
1758
+ if args.size == 1 && args.first.respond_to?(:to_ary)
1759
+ arg_names = args.first.to_ary
1760
+ else
1761
+ arg_names = args
1653
1762
  end
1654
- if arg_names.last.is_a?(Hash)
1655
- hash = arg_names.pop
1656
- needs = hash[:needs]
1657
- fail "Unrecognized keys in task hash: #{hash.keys.inspect}" if hash.size > 1
1763
+ [task_name, arg_names, []]
1764
+ end
1765
+ private :resolve_args_without_dependencies
1766
+
1767
+ # Resolve task arguments for a task or rule when there are
1768
+ # dependencies declared.
1769
+ #
1770
+ # The patterns recognized by this argument resolving function are:
1771
+ #
1772
+ # task :t => [:d]
1773
+ # task :t, [a] => [:d]
1774
+ # task :t, :needs => [:d] (deprecated)
1775
+ # task :t, :a, :needs => [:d] (deprecated)
1776
+ #
1777
+ def resolve_args_with_dependencies(args, hash) # :nodoc:
1778
+ fail "Task Argument Error" if hash.size != 1
1779
+ key, value = hash.map { |k, v| [k,v] }.first
1780
+ if args.empty?
1781
+ task_name = key
1782
+ arg_names = []
1783
+ deps = value
1784
+ elsif key == :needs
1785
+ task_name = args.shift
1786
+ arg_names = args
1787
+ deps = value
1788
+ else
1789
+ task_name = args.shift
1790
+ arg_names = key
1791
+ deps = value
1658
1792
  end
1659
- needs = [needs] unless needs.respond_to?(:to_ary)
1660
- [task_name, arg_names, needs]
1793
+ deps = [deps] unless deps.respond_to?(:to_ary)
1794
+ [task_name, arg_names, deps]
1661
1795
  end
1662
-
1796
+ private :resolve_args_with_dependencies
1797
+
1663
1798
  # If a rule can be found that matches the task name, enhance the
1664
1799
  # task with the prerequisites and actions from the rule. Set the
1665
1800
  # source attribute of the task appropriately for the rule. Return
@@ -1684,6 +1819,15 @@ module Rake
1684
1819
  @tasks.values.sort_by { |t| t.name }
1685
1820
  end
1686
1821
 
1822
+ # List of all the tasks defined in the given scope (and its
1823
+ # sub-scopes).
1824
+ def tasks_in_scope(scope)
1825
+ prefix = scope.join(":")
1826
+ tasks.select { |t|
1827
+ /^#{prefix}:/ =~ t.name
1828
+ }
1829
+ end
1830
+
1687
1831
  # Clear all tasks in this application.
1688
1832
  def clear
1689
1833
  @tasks.clear
@@ -1750,15 +1894,23 @@ module Rake
1750
1894
  "_anon_#{@seed}"
1751
1895
  end
1752
1896
 
1897
+ def trace_rule(level, message)
1898
+ puts "#{" "*level}#{message}" if Rake.application.options.trace_rules
1899
+ end
1900
+
1753
1901
  # Attempt to create a rule given the list of prerequisites.
1754
1902
  def attempt_rule(task_name, extensions, block, level)
1755
1903
  sources = make_sources(task_name, extensions)
1756
1904
  prereqs = sources.collect { |source|
1905
+ trace_rule level, "Attempting Rule #{task_name} => #{source}"
1757
1906
  if File.exist?(source) || Rake::Task.task_defined?(source)
1907
+ trace_rule level, "(#{task_name} => #{source} ... EXIST)"
1758
1908
  source
1759
- elsif parent = enhance_with_matching_rule(sources.first, level+1)
1909
+ elsif parent = enhance_with_matching_rule(source, level+1)
1910
+ trace_rule level, "(#{task_name} => #{source} ... ENHANCE)"
1760
1911
  parent.name
1761
1912
  else
1913
+ trace_rule level, "(#{task_name} => #{source} ... FAIL)"
1762
1914
  return nil
1763
1915
  end
1764
1916
  }
@@ -1815,41 +1967,6 @@ module Rake
1815
1967
 
1816
1968
  DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze
1817
1969
 
1818
- OPTIONS = [ # :nodoc:
1819
- ['--classic-namespace', '-C', GetoptLong::NO_ARGUMENT,
1820
- "Put Task and FileTask in the top level namespace"],
1821
- ['--describe', '-D', GetoptLong::OPTIONAL_ARGUMENT,
1822
- "Describe the tasks (matching optional PATTERN), then exit."],
1823
- ['--rakefile', '-f', GetoptLong::OPTIONAL_ARGUMENT,
1824
- "Use FILE as the rakefile."],
1825
- ['--help', '-h', '-H', GetoptLong::NO_ARGUMENT,
1826
- "Display this help message."],
1827
- ['--libdir', '-I', GetoptLong::REQUIRED_ARGUMENT,
1828
- "Include LIBDIR in the search path for required modules."],
1829
- ['--dry-run', '-n', GetoptLong::NO_ARGUMENT,
1830
- "Do a dry run without executing actions."],
1831
- ['--nosearch', '-N', GetoptLong::NO_ARGUMENT,
1832
- "Do not search parent directories for the Rakefile."],
1833
- ['--prereqs', '-P', GetoptLong::NO_ARGUMENT,
1834
- "Display the tasks and dependencies, then exit."],
1835
- ['--quiet', '-q', GetoptLong::NO_ARGUMENT,
1836
- "Do not log messages to standard output."],
1837
- ['--require', '-r', GetoptLong::REQUIRED_ARGUMENT,
1838
- "Require MODULE before executing rakefile."],
1839
- ['--rakelibdir', '-R', GetoptLong::REQUIRED_ARGUMENT,
1840
- "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')"],
1841
- ['--silent', '-s', GetoptLong::NO_ARGUMENT,
1842
- "Like --quiet, but also suppresses the 'in directory' announcement."],
1843
- ['--tasks', '-T', GetoptLong::OPTIONAL_ARGUMENT,
1844
- "Display the tasks (matching optional PATTERN) with descriptions, then exit."],
1845
- ['--trace', '-t', GetoptLong::NO_ARGUMENT,
1846
- "Turn on invoke/execute tracing, enable full backtrace."],
1847
- ['--verbose', '-v', GetoptLong::NO_ARGUMENT,
1848
- "Log message to standard output (default)."],
1849
- ['--version', '-V', GetoptLong::NO_ARGUMENT,
1850
- "Display the program version."],
1851
- ]
1852
-
1853
1970
  # Initialize a Rake::Application object.
1854
1971
  def initialize
1855
1972
  super
@@ -1862,8 +1979,10 @@ module Rake
1862
1979
  @default_loader = Rake::DefaultLoader.new
1863
1980
  @original_dir = Dir.pwd
1864
1981
  @top_level_tasks = []
1982
+ add_loader('rb', DefaultLoader.new)
1865
1983
  add_loader('rf', DefaultLoader.new)
1866
1984
  add_loader('rake', DefaultLoader.new)
1985
+ @tty_output = STDOUT.tty?
1867
1986
  end
1868
1987
 
1869
1988
  # Run the Rake application. The run method performs the following three steps:
@@ -1949,13 +2068,13 @@ module Rake
1949
2068
  yield
1950
2069
  rescue SystemExit => ex
1951
2070
  # Exit silently with current status
1952
- exit(ex.status)
1953
- rescue SystemExit, GetoptLong::InvalidOption => ex
2071
+ raise
2072
+ rescue OptionParser::InvalidOption => ex
1954
2073
  # Exit silently
1955
- exit(1)
2074
+ exit(false)
1956
2075
  rescue Exception => ex
1957
2076
  # Exit with error message
1958
- $stderr.puts "rake aborted!"
2077
+ $stderr.puts "#{name} aborted!"
1959
2078
  $stderr.puts ex.message
1960
2079
  if options.trace
1961
2080
  $stderr.puts ex.backtrace.join("\n")
@@ -1963,7 +2082,7 @@ module Rake
1963
2082
  $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
1964
2083
  $stderr.puts "(See full trace by running task with --trace)"
1965
2084
  end
1966
- exit(1)
2085
+ exit(false)
1967
2086
  end
1968
2087
  end
1969
2088
 
@@ -1971,39 +2090,40 @@ module Rake
1971
2090
  # If a match is found, it is copied into @rakefile.
1972
2091
  def have_rakefile
1973
2092
  @rakefiles.each do |fn|
1974
- if File.exist?(fn) || fn == ''
1975
- @rakefile = fn
1976
- return true
2093
+ if File.exist?(fn)
2094
+ others = Dir.glob(fn, File::FNM_CASEFOLD)
2095
+ return others.size == 1 ? others.first : fn
2096
+ elsif fn == ''
2097
+ return fn
1977
2098
  end
1978
2099
  end
1979
- return false
2100
+ return nil
1980
2101
  end
1981
2102
 
1982
- # Display the rake command line help.
1983
- def help
1984
- puts "rake [-f rakefile] {options} targets..."
1985
- puts
1986
- puts "Options are ..."
1987
- puts
1988
- OPTIONS.sort.each do |long, short, mode, desc|
1989
- if mode == GetoptLong::REQUIRED_ARGUMENT
1990
- if desc =~ /\b([A-Z]{2,})\b/
1991
- long = long + "=#{$1}"
1992
- end
1993
- end
1994
- printf " %-20s (%s)\n", long, short
1995
- printf " %s\n", desc
1996
- end
2103
+ # True if we are outputting to TTY, false otherwise
2104
+ def tty_output?
2105
+ @tty_output
2106
+ end
2107
+
2108
+ # Override the detected TTY output state (mostly for testing)
2109
+ def tty_output=( tty_output_state )
2110
+ @tty_output = tty_output_state
2111
+ end
2112
+
2113
+ # We will truncate output if we are outputting to a TTY or if we've been
2114
+ # given an explicit column width to honor
2115
+ def truncate_output?
2116
+ tty_output? || ENV['RAKE_COLUMNS']
1997
2117
  end
1998
2118
 
1999
- # Display the tasks and dependencies.
2119
+ # Display the tasks and comments.
2000
2120
  def display_tasks_and_comments
2001
2121
  displayable_tasks = tasks.select { |t|
2002
2122
  t.comment && t.name =~ options.show_task_pattern
2003
2123
  }
2004
2124
  if options.full_description
2005
2125
  displayable_tasks.each do |t|
2006
- puts "rake #{t.name_with_args}"
2126
+ puts "#{name} #{t.name_with_args}"
2007
2127
  t.full_comment.split("\n").each do |line|
2008
2128
  puts " #{line}"
2009
2129
  end
@@ -2011,101 +2131,197 @@ module Rake
2011
2131
  end
2012
2132
  else
2013
2133
  width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
2014
- max_column = 80 - name.size - width - 7
2134
+ max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
2015
2135
  displayable_tasks.each do |t|
2016
2136
  printf "#{name} %-#{width}s # %s\n",
2017
- t.name_with_args, truncate(t.comment, max_column)
2137
+ t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
2018
2138
  end
2019
2139
  end
2020
2140
  end
2021
2141
 
2142
+ def terminal_width
2143
+ if ENV['RAKE_COLUMNS']
2144
+ result = ENV['RAKE_COLUMNS'].to_i
2145
+ else
2146
+ result = unix? ? dynamic_width : 80
2147
+ end
2148
+ (result < 10) ? 80 : result
2149
+ rescue
2150
+ 80
2151
+ end
2152
+
2153
+ # Calculate the dynamic width of the
2154
+ def dynamic_width
2155
+ @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
2156
+ end
2157
+
2158
+ def dynamic_width_stty
2159
+ %x{stty size 2>/dev/null}.split[1].to_i
2160
+ end
2161
+
2162
+ def dynamic_width_tput
2163
+ %x{tput cols 2>/dev/null}.to_i
2164
+ end
2165
+
2166
+ def unix?
2167
+ RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
2168
+ end
2169
+
2170
+ def windows?
2171
+ Win32.windows?
2172
+ end
2173
+
2022
2174
  def truncate(string, width)
2023
2175
  if string.length <= width
2024
2176
  string
2025
2177
  else
2026
- string[0, width-3] + "..."
2178
+ ( string[0, width-3] || "" ) + "..."
2027
2179
  end
2028
2180
  end
2029
2181
 
2030
2182
  # Display the tasks and prerequisites
2031
2183
  def display_prerequisites
2032
2184
  tasks.each do |t|
2033
- puts "rake #{t.name}"
2185
+ puts "#{name} #{t.name}"
2034
2186
  t.prerequisites.each { |pre| puts " #{pre}" }
2035
2187
  end
2036
2188
  end
2037
2189
 
2038
- # Return a list of the command line options supported by the
2039
- # program.
2040
- def command_line_options
2041
- OPTIONS.collect { |lst| lst[0..-2] }
2042
- end
2043
-
2044
- # Do the option defined by +opt+ and +value+.
2045
- def do_option(opt, value)
2046
- case opt
2047
- when '--describe'
2048
- options.show_tasks = true
2049
- options.show_task_pattern = Regexp.new(value || '.')
2050
- options.full_description = true
2051
- when '--dry-run'
2052
- verbose(true)
2053
- nowrite(true)
2054
- options.dryrun = true
2055
- options.trace = true
2056
- when '--help'
2057
- help
2058
- exit
2059
- when '--libdir'
2060
- $:.push(value)
2061
- when '--nosearch'
2062
- options.nosearch = true
2063
- when '--prereqs'
2064
- options.show_prereqs = true
2065
- when '--quiet'
2066
- verbose(false)
2067
- when '--rakefile'
2068
- @rakefiles.clear
2069
- @rakefiles << value
2070
- when '--rakelibdir'
2071
- options.rakelib = value.split(':')
2072
- when '--require'
2073
- begin
2074
- require value
2075
- rescue LoadError => ex
2076
- begin
2077
- rake_require value
2078
- rescue LoadError => ex2
2079
- raise ex
2080
- end
2081
- end
2082
- when '--silent'
2083
- verbose(false)
2084
- options.silent = true
2085
- when '--tasks'
2086
- options.show_tasks = true
2087
- options.show_task_pattern = Regexp.new(value || '.')
2088
- options.full_description = false
2089
- when '--trace'
2090
- options.trace = true
2091
- verbose(true)
2092
- when '--verbose'
2093
- verbose(true)
2094
- when '--version'
2095
- puts "rake, version #{RAKEVERSION}"
2096
- exit
2097
- when '--classic-namespace'
2098
- require 'rake/classic_namespace'
2099
- options.classic_namespace = true
2100
- end
2190
+ # A list of all the standard options used in rake, suitable for
2191
+ # passing to OptionParser.
2192
+ def standard_rake_options
2193
+ [
2194
+ ['--classic-namespace', '-C', "Put Task and FileTask in the top level namespace",
2195
+ lambda { |value|
2196
+ require 'rake/classic_namespace'
2197
+ options.classic_namespace = true
2198
+ }
2199
+ ],
2200
+ ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
2201
+ lambda { |value|
2202
+ options.show_tasks = true
2203
+ options.full_description = true
2204
+ options.show_task_pattern = Regexp.new(value || '')
2205
+ }
2206
+ ],
2207
+ ['--dry-run', '-n', "Do a dry run without executing actions.",
2208
+ lambda { |value|
2209
+ verbose(true)
2210
+ nowrite(true)
2211
+ options.dryrun = true
2212
+ options.trace = true
2213
+ }
2214
+ ],
2215
+ ['--execute', '-e CODE', "Execute some Ruby code and exit.",
2216
+ lambda { |value|
2217
+ eval(value)
2218
+ exit
2219
+ }
2220
+ ],
2221
+ ['--execute-print', '-p CODE', "Execute some Ruby code, print the result, then exit.",
2222
+ lambda { |value|
2223
+ puts eval(value)
2224
+ exit
2225
+ }
2226
+ ],
2227
+ ['--execute-continue', '-E CODE',
2228
+ "Execute some Ruby code, then continue with normal task processing.",
2229
+ lambda { |value| eval(value) }
2230
+ ],
2231
+ ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
2232
+ lambda { |value| $:.push(value) }
2233
+ ],
2234
+ ['--prereqs', '-P', "Display the tasks and dependencies, then exit.",
2235
+ lambda { |value| options.show_prereqs = true }
2236
+ ],
2237
+ ['--quiet', '-q', "Do not log messages to standard output.",
2238
+ lambda { |value| verbose(false) }
2239
+ ],
2240
+ ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.",
2241
+ lambda { |value|
2242
+ value ||= ''
2243
+ @rakefiles.clear
2244
+ @rakefiles << value
2245
+ }
2246
+ ],
2247
+ ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
2248
+ "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
2249
+ lambda { |value| options.rakelib = value.split(':') }
2250
+ ],
2251
+ ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
2252
+ lambda { |value|
2253
+ begin
2254
+ require value
2255
+ rescue LoadError => ex
2256
+ begin
2257
+ rake_require value
2258
+ rescue LoadError => ex2
2259
+ raise ex
2260
+ end
2261
+ end
2262
+ }
2263
+ ],
2264
+ ['--rules', "Trace the rules resolution.",
2265
+ lambda { |value| options.trace_rules = true }
2266
+ ],
2267
+ ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
2268
+ lambda { |value| options.nosearch = true }
2269
+ ],
2270
+ ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
2271
+ lambda { |value|
2272
+ verbose(false)
2273
+ options.silent = true
2274
+ }
2275
+ ],
2276
+ ['--system', '-g',
2277
+ "Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
2278
+ lambda { |value| options.load_system = true }
2279
+ ],
2280
+ ['--no-system', '--nosystem', '-G',
2281
+ "Use standard project Rakefile search paths, ignore system wide rakefiles.",
2282
+ lambda { |value| options.ignore_system = true }
2283
+ ],
2284
+ ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
2285
+ lambda { |value|
2286
+ options.show_tasks = true
2287
+ options.show_task_pattern = Regexp.new(value || '')
2288
+ options.full_description = false
2289
+ }
2290
+ ],
2291
+ ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.",
2292
+ lambda { |value|
2293
+ options.trace = true
2294
+ verbose(true)
2295
+ }
2296
+ ],
2297
+ ['--verbose', '-v', "Log message to standard output.",
2298
+ lambda { |value| verbose(true) }
2299
+ ],
2300
+ ['--version', '-V', "Display the program version.",
2301
+ lambda { |value|
2302
+ puts "rake, version #{RAKEVERSION}"
2303
+ exit
2304
+ }
2305
+ ]
2306
+ ]
2101
2307
  end
2102
2308
 
2103
2309
  # Read and handle the command line options.
2104
2310
  def handle_options
2105
2311
  options.rakelib = ['rakelib']
2106
2312
 
2107
- opts = GetoptLong.new(*command_line_options)
2108
- opts.each { |opt, value| do_option(opt, value) }
2313
+ OptionParser.new do |opts|
2314
+ opts.banner = "rake [-f rakefile] {options} targets..."
2315
+ opts.separator ""
2316
+ opts.separator "Options are ..."
2317
+
2318
+ opts.on_tail("-h", "--help", "-H", "Display this help message.") do
2319
+ puts opts
2320
+ exit
2321
+ end
2322
+
2323
+ standard_rake_options.each { |args| opts.on(*args) }
2324
+ end.parse!
2109
2325
 
2110
2326
  # If class namespaces are requested, set the global options
2111
2327
  # according to the values in the options structure.
@@ -2116,12 +2332,10 @@ module Rake
2116
2332
  $dryrun = options.dryrun
2117
2333
  $silent = options.silent
2118
2334
  end
2119
- rescue NoMethodError => ex
2120
- raise GetoptLong::InvalidOption, "While parsing options, error = #{ex.class}:#{ex.message}"
2121
2335
  end
2122
2336
 
2123
2337
  # Similar to the regular Ruby +require+ command, but will check
2124
- # for .rake files in addition to .rb files.
2338
+ # for *.rake files in addition to *.rb files.
2125
2339
  def rake_require(file_name, paths=$LOAD_PATH, loaded=$")
2126
2340
  return false if loaded.include?(file_name)
2127
2341
  paths.each do |path|
@@ -2136,24 +2350,75 @@ module Rake
2136
2350
  fail LoadError, "Can't find #{file_name}"
2137
2351
  end
2138
2352
 
2139
- def raw_load_rakefile # :nodoc:
2353
+ def find_rakefile_location
2140
2354
  here = Dir.pwd
2141
- while ! have_rakefile
2355
+ while ! (fn = have_rakefile)
2142
2356
  Dir.chdir("..")
2143
2357
  if Dir.pwd == here || options.nosearch
2144
- fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})"
2358
+ return nil
2145
2359
  end
2146
2360
  here = Dir.pwd
2147
2361
  end
2148
- puts "(in #{Dir.pwd})" unless options.silent
2149
- $rakefile = @rakefile
2150
- load File.expand_path(@rakefile) if @rakefile != ''
2151
- options.rakelib.each do |rlib|
2152
- Dir["#{rlib}/*.rake"].each do |name| add_import name end
2362
+ [fn, here]
2363
+ ensure
2364
+ Dir.chdir(Rake.original_dir)
2365
+ end
2366
+
2367
+ def raw_load_rakefile # :nodoc:
2368
+ rakefile, location = find_rakefile_location
2369
+ if (! options.ignore_system) &&
2370
+ (options.load_system || rakefile.nil?) &&
2371
+ system_dir && File.directory?(system_dir)
2372
+ puts "(in #{Dir.pwd})" unless options.silent
2373
+ glob("#{system_dir}/*.rake") do |name|
2374
+ add_import name
2375
+ end
2376
+ else
2377
+ fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})" if
2378
+ rakefile.nil?
2379
+ @rakefile = rakefile
2380
+ Dir.chdir(location)
2381
+ puts "(in #{Dir.pwd})" unless options.silent
2382
+ $rakefile = @rakefile if options.classic_namespace
2383
+ load File.expand_path(@rakefile) if @rakefile && @rakefile != ''
2384
+ options.rakelib.each do |rlib|
2385
+ glob("#{rlib}/*.rake") do |name|
2386
+ add_import name
2387
+ end
2388
+ end
2153
2389
  end
2154
2390
  load_imports
2155
2391
  end
2156
2392
 
2393
+ def glob(path, &block)
2394
+ Dir[path.gsub("\\", '/')].each(&block)
2395
+ end
2396
+ private :glob
2397
+
2398
+ # The directory path containing the system wide rakefiles.
2399
+ def system_dir
2400
+ @system_dir ||=
2401
+ begin
2402
+ if ENV['RAKE_SYSTEM']
2403
+ ENV['RAKE_SYSTEM']
2404
+ else
2405
+ standard_system_dir
2406
+ end
2407
+ end
2408
+ end
2409
+
2410
+ # The standard directory containing system wide rake files.
2411
+ if Win32.windows?
2412
+ def standard_system_dir #:nodoc:
2413
+ Win32.win32_system_dir
2414
+ end
2415
+ else
2416
+ def standard_system_dir #:nodoc:
2417
+ File.join(File.expand_path('~'), '.rake')
2418
+ end
2419
+ end
2420
+ private :standard_system_dir
2421
+
2157
2422
  # Collect the list of tasks on the command line. If no tasks are
2158
2423
  # given, return a list containing only the default task.
2159
2424
  # Environmental assignments are processed at this time as well.
@@ -2163,7 +2428,7 @@ module Rake
2163
2428
  if arg =~ /^(\w+)=(.*)$/
2164
2429
  ENV[$1] = $2
2165
2430
  else
2166
- @top_level_tasks << arg
2431
+ @top_level_tasks << arg unless arg =~ /^-/
2167
2432
  end
2168
2433
  end
2169
2434
  @top_level_tasks.push("default") if @top_level_tasks.size == 0