rake 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/macos.yml +22 -0
  3. data/.github/workflows/ubuntu-rvm.yml +28 -0
  4. data/.github/workflows/ubuntu.yml +20 -0
  5. data/.github/workflows/windows.yml +20 -0
  6. data/CONTRIBUTING.rdoc +43 -0
  7. data/Gemfile +10 -0
  8. data/History.rdoc +2359 -0
  9. data/MIT-LICENSE +21 -0
  10. data/README.rdoc +155 -0
  11. data/Rakefile +41 -0
  12. data/bin/bundle +105 -0
  13. data/bin/console +7 -0
  14. data/bin/rake +29 -0
  15. data/bin/rdoc +29 -0
  16. data/bin/rubocop +29 -0
  17. data/bin/setup +6 -0
  18. data/doc/command_line_usage.rdoc +158 -0
  19. data/doc/example/Rakefile1 +38 -0
  20. data/doc/example/Rakefile2 +35 -0
  21. data/doc/example/a.c +6 -0
  22. data/doc/example/b.c +6 -0
  23. data/doc/example/main.c +11 -0
  24. data/doc/glossary.rdoc +42 -0
  25. data/doc/jamis.rb +592 -0
  26. data/doc/proto_rake.rdoc +127 -0
  27. data/doc/rake.1 +156 -0
  28. data/doc/rakefile.rdoc +622 -0
  29. data/doc/rational.rdoc +151 -0
  30. data/exe/rake +27 -0
  31. data/lib/rake.rb +71 -0
  32. data/lib/rake/application.rb +824 -0
  33. data/lib/rake/backtrace.rb +24 -0
  34. data/lib/rake/clean.rb +78 -0
  35. data/lib/rake/cloneable.rb +17 -0
  36. data/lib/rake/cpu_counter.rb +107 -0
  37. data/lib/rake/default_loader.rb +15 -0
  38. data/lib/rake/dsl_definition.rb +195 -0
  39. data/lib/rake/early_time.rb +22 -0
  40. data/lib/rake/ext/core.rb +26 -0
  41. data/lib/rake/ext/string.rb +176 -0
  42. data/lib/rake/file_creation_task.rb +25 -0
  43. data/lib/rake/file_list.rb +435 -0
  44. data/lib/rake/file_task.rb +54 -0
  45. data/lib/rake/file_utils.rb +134 -0
  46. data/lib/rake/file_utils_ext.rb +134 -0
  47. data/lib/rake/invocation_chain.rb +57 -0
  48. data/lib/rake/invocation_exception_mixin.rb +17 -0
  49. data/lib/rake/late_time.rb +18 -0
  50. data/lib/rake/linked_list.rb +112 -0
  51. data/lib/rake/loaders/makefile.rb +54 -0
  52. data/lib/rake/multi_task.rb +14 -0
  53. data/lib/rake/name_space.rb +38 -0
  54. data/lib/rake/packagetask.rb +222 -0
  55. data/lib/rake/phony.rb +16 -0
  56. data/lib/rake/private_reader.rb +21 -0
  57. data/lib/rake/promise.rb +100 -0
  58. data/lib/rake/pseudo_status.rb +30 -0
  59. data/lib/rake/rake_module.rb +67 -0
  60. data/lib/rake/rake_test_loader.rb +27 -0
  61. data/lib/rake/rule_recursion_overflow_error.rb +20 -0
  62. data/lib/rake/scope.rb +43 -0
  63. data/lib/rake/task.rb +433 -0
  64. data/lib/rake/task_argument_error.rb +8 -0
  65. data/lib/rake/task_arguments.rb +109 -0
  66. data/lib/rake/task_manager.rb +328 -0
  67. data/lib/rake/tasklib.rb +12 -0
  68. data/lib/rake/testtask.rb +224 -0
  69. data/lib/rake/thread_history_display.rb +49 -0
  70. data/lib/rake/thread_pool.rb +163 -0
  71. data/lib/rake/trace_output.rb +23 -0
  72. data/lib/rake/version.rb +10 -0
  73. data/lib/rake/win32.rb +51 -0
  74. data/rake.gemspec +36 -0
  75. metadata +132 -0
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+ require "rake/task"
3
+ require "rake/early_time"
4
+
5
+ module Rake
6
+
7
+ # A FileTask is a task that includes time based dependencies. If any of a
8
+ # FileTask's prerequisites have a timestamp that is later than the file
9
+ # represented by this task, then the file must be rebuilt (using the
10
+ # supplied actions).
11
+ #
12
+ class FileTask < Task
13
+
14
+ # Is this file task needed? Yes if it doesn't exist, or if its time stamp
15
+ # is out of date.
16
+ def needed?
17
+ !File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all
18
+ end
19
+
20
+ # Time stamp for file task.
21
+ def timestamp
22
+ if File.exist?(name)
23
+ File.mtime(name.to_s)
24
+ else
25
+ Rake::LATE
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ # Are there any prerequisites with a later time than the given time stamp?
32
+ def out_of_date?(stamp)
33
+ all_prerequisite_tasks.any? { |prereq|
34
+ prereq_task = application[prereq, @scope]
35
+ if prereq_task.instance_of?(Rake::FileTask)
36
+ prereq_task.timestamp > stamp || @application.options.build_all
37
+ else
38
+ prereq_task.timestamp > stamp
39
+ end
40
+ }
41
+ end
42
+
43
+ # ----------------------------------------------------------------
44
+ # Task class methods.
45
+ #
46
+ class << self
47
+ # Apply the scope to the task name according to the rules for this kind
48
+ # of task. File based tasks ignore the scope when creating the name.
49
+ def scope_name(scope, task_name)
50
+ Rake.from_pathname(task_name)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,134 @@
1
+ # frozen_string_literal: true
2
+ require "rbconfig"
3
+ require "fileutils"
4
+
5
+ #--
6
+ # This a FileUtils extension that defines several additional commands to be
7
+ # added to the FileUtils utility functions.
8
+ module FileUtils
9
+ # Path to the currently running Ruby program
10
+ RUBY = ENV["RUBY"] || File.join(
11
+ RbConfig::CONFIG["bindir"],
12
+ RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]).
13
+ sub(/.*\s.*/m, '"\&"')
14
+
15
+ # Run the system command +cmd+. If multiple arguments are given the command
16
+ # is run directly (without the shell, same semantics as Kernel::exec and
17
+ # Kernel::system).
18
+ #
19
+ # It is recommended you use the multiple argument form over interpolating
20
+ # user input for both usability and security reasons. With the multiple
21
+ # argument form you can easily process files with spaces or other shell
22
+ # reserved characters in them. With the multiple argument form your rake
23
+ # tasks are not vulnerable to users providing an argument like
24
+ # <code>; rm # -rf /</code>.
25
+ #
26
+ # If a block is given, upon command completion the block is called with an
27
+ # OK flag (true on a zero exit status) and a Process::Status object.
28
+ # Without a block a RuntimeError is raised when the command exits non-zero.
29
+ #
30
+ # Examples:
31
+ #
32
+ # sh 'ls -ltr'
33
+ #
34
+ # sh 'ls', 'file with spaces'
35
+ #
36
+ # # check exit status after command runs
37
+ # sh %{grep pattern file} do |ok, res|
38
+ # if !ok
39
+ # puts "pattern not found (status = #{res.exitstatus})"
40
+ # end
41
+ # end
42
+ #
43
+ def sh(*cmd, &block)
44
+ options = (Hash === cmd.last) ? cmd.pop : {}
45
+ shell_runner = block_given? ? block : create_shell_runner(cmd)
46
+
47
+ set_verbose_option(options)
48
+ verbose = options.delete :verbose
49
+ noop = options.delete(:noop) || Rake::FileUtilsExt.nowrite_flag
50
+
51
+ Rake.rake_output_message sh_show_command cmd if verbose
52
+
53
+ unless noop
54
+ res = (Hash === cmd.last) ? system(*cmd) : system(*cmd, options)
55
+ status = $?
56
+ status = Rake::PseudoStatus.new(1) if !res && status.nil?
57
+ shell_runner.call(res, status)
58
+ end
59
+ end
60
+
61
+ def create_shell_runner(cmd) # :nodoc:
62
+ show_command = sh_show_command cmd
63
+ show_command = show_command[0, 42] + "..." unless $trace
64
+
65
+ lambda do |ok, status|
66
+ ok or
67
+ fail "Command failed with status (#{status.exitstatus}): " +
68
+ "[#{show_command}]"
69
+ end
70
+ end
71
+ private :create_shell_runner
72
+
73
+ def sh_show_command(cmd) # :nodoc:
74
+ cmd = cmd.dup
75
+
76
+ if Hash === cmd.first
77
+ env = cmd.first
78
+ env = env.map { |name, value| "#{name}=#{value}" }.join " "
79
+ cmd[0] = env
80
+ end
81
+
82
+ cmd.join " "
83
+ end
84
+ private :sh_show_command
85
+
86
+ def set_verbose_option(options) # :nodoc:
87
+ unless options.key? :verbose
88
+ options[:verbose] =
89
+ (Rake::FileUtilsExt.verbose_flag == Rake::FileUtilsExt::DEFAULT) ||
90
+ Rake::FileUtilsExt.verbose_flag
91
+ end
92
+ end
93
+ private :set_verbose_option
94
+
95
+ # Run a Ruby interpreter with the given arguments.
96
+ #
97
+ # Example:
98
+ # ruby %{-pe '$_.upcase!' <README}
99
+ #
100
+ def ruby(*args, **options, &block)
101
+ if args.length > 1
102
+ sh(RUBY, *args, **options, &block)
103
+ else
104
+ sh("#{RUBY} #{args.first}", **options, &block)
105
+ end
106
+ end
107
+
108
+ LN_SUPPORTED = [true]
109
+
110
+ # Attempt to do a normal file link, but fall back to a copy if the link
111
+ # fails.
112
+ def safe_ln(*args, **options)
113
+ if LN_SUPPORTED[0]
114
+ begin
115
+ return options.empty? ? ln(*args) : ln(*args, **options)
116
+ rescue StandardError, NotImplementedError
117
+ LN_SUPPORTED[0] = false
118
+ end
119
+ end
120
+ options.empty? ? cp(*args) : cp(*args, **options)
121
+ end
122
+
123
+ # Split a file path into individual directory names.
124
+ #
125
+ # Example:
126
+ # split_all("a/b/c") => ['a', 'b', 'c']
127
+ #
128
+ def split_all(path)
129
+ head, tail = File.split(path)
130
+ return [tail] if head == "." || tail == "/"
131
+ return [head, tail] if head == "/"
132
+ return split_all(head) + [tail]
133
+ end
134
+ end
@@ -0,0 +1,134 @@
1
+ # frozen_string_literal: true
2
+ require "rake/file_utils"
3
+
4
+ module Rake
5
+ #
6
+ # FileUtilsExt provides a custom version of the FileUtils methods
7
+ # that respond to the <tt>verbose</tt> and <tt>nowrite</tt>
8
+ # commands.
9
+ #
10
+ module FileUtilsExt
11
+ include FileUtils
12
+
13
+ class << self
14
+ attr_accessor :verbose_flag, :nowrite_flag
15
+ end
16
+
17
+ DEFAULT = Object.new
18
+
19
+ FileUtilsExt.verbose_flag = DEFAULT
20
+ FileUtilsExt.nowrite_flag = false
21
+
22
+ FileUtils.commands.each do |name|
23
+ opts = FileUtils.options_of name
24
+ default_options = []
25
+ if opts.include?("verbose")
26
+ default_options << "verbose: FileUtilsExt.verbose_flag"
27
+ end
28
+ if opts.include?("noop")
29
+ default_options << "noop: FileUtilsExt.nowrite_flag"
30
+ end
31
+
32
+ next if default_options.empty?
33
+ module_eval(<<-EOS, __FILE__, __LINE__ + 1)
34
+ def #{name}(*args, **options, &block)
35
+ super(*args,
36
+ #{default_options.join(', ')},
37
+ **options, &block)
38
+ end
39
+ EOS
40
+ end
41
+
42
+ # Get/set the verbose flag controlling output from the FileUtils
43
+ # utilities. If verbose is true, then the utility method is
44
+ # echoed to standard output.
45
+ #
46
+ # Examples:
47
+ # verbose # return the current value of the
48
+ # # verbose flag
49
+ # verbose(v) # set the verbose flag to _v_.
50
+ # verbose(v) { code } # Execute code with the verbose flag set
51
+ # # temporarily to _v_. Return to the
52
+ # # original value when code is done.
53
+ def verbose(value=nil)
54
+ oldvalue = FileUtilsExt.verbose_flag
55
+ FileUtilsExt.verbose_flag = value unless value.nil?
56
+ if block_given?
57
+ begin
58
+ yield
59
+ ensure
60
+ FileUtilsExt.verbose_flag = oldvalue
61
+ end
62
+ end
63
+ FileUtilsExt.verbose_flag
64
+ end
65
+
66
+ # Get/set the nowrite flag controlling output from the FileUtils
67
+ # utilities. If verbose is true, then the utility method is
68
+ # echoed to standard output.
69
+ #
70
+ # Examples:
71
+ # nowrite # return the current value of the
72
+ # # nowrite flag
73
+ # nowrite(v) # set the nowrite flag to _v_.
74
+ # nowrite(v) { code } # Execute code with the nowrite flag set
75
+ # # temporarily to _v_. Return to the
76
+ # # original value when code is done.
77
+ def nowrite(value=nil)
78
+ oldvalue = FileUtilsExt.nowrite_flag
79
+ FileUtilsExt.nowrite_flag = value unless value.nil?
80
+ if block_given?
81
+ begin
82
+ yield
83
+ ensure
84
+ FileUtilsExt.nowrite_flag = oldvalue
85
+ end
86
+ end
87
+ oldvalue
88
+ end
89
+
90
+ # Use this function to prevent potentially destructive ruby code
91
+ # from running when the :nowrite flag is set.
92
+ #
93
+ # Example:
94
+ #
95
+ # when_writing("Building Project") do
96
+ # project.build
97
+ # end
98
+ #
99
+ # The following code will build the project under normal
100
+ # conditions. If the nowrite(true) flag is set, then the example
101
+ # will print:
102
+ #
103
+ # DRYRUN: Building Project
104
+ #
105
+ # instead of actually building the project.
106
+ #
107
+ def when_writing(msg=nil)
108
+ if FileUtilsExt.nowrite_flag
109
+ $stderr.puts "DRYRUN: #{msg}" if msg
110
+ else
111
+ yield
112
+ end
113
+ end
114
+
115
+ # Send the message to the default rake output (which is $stderr).
116
+ def rake_output_message(message)
117
+ $stderr.puts(message)
118
+ end
119
+
120
+ # Check that the options do not contain options not listed in
121
+ # +optdecl+. An ArgumentError exception is thrown if non-declared
122
+ # options are found.
123
+ def rake_check_options(options, *optdecl)
124
+ h = options.dup
125
+ optdecl.each do |name|
126
+ h.delete name
127
+ end
128
+ raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless
129
+ h.empty?
130
+ end
131
+
132
+ extend self
133
+ end
134
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+
4
+ # InvocationChain tracks the chain of task invocations to detect
5
+ # circular dependencies.
6
+ class InvocationChain < LinkedList
7
+
8
+ # Is the invocation already in the chain?
9
+ def member?(invocation)
10
+ head == invocation || tail.member?(invocation)
11
+ end
12
+
13
+ # Append an invocation to the chain of invocations. It is an error
14
+ # if the invocation already listed.
15
+ def append(invocation)
16
+ if member?(invocation)
17
+ fail RuntimeError, "Circular dependency detected: #{to_s} => #{invocation}"
18
+ end
19
+ conj(invocation)
20
+ end
21
+
22
+ # Convert to string, ie: TOP => invocation => invocation
23
+ def to_s
24
+ "#{prefix}#{head}"
25
+ end
26
+
27
+ # Class level append.
28
+ def self.append(invocation, chain)
29
+ chain.append(invocation)
30
+ end
31
+
32
+ private
33
+
34
+ def prefix
35
+ "#{tail} => "
36
+ end
37
+
38
+ # Null object for an empty chain.
39
+ class EmptyInvocationChain < LinkedList::EmptyLinkedList
40
+ @parent = InvocationChain
41
+
42
+ def member?(obj)
43
+ false
44
+ end
45
+
46
+ def append(invocation)
47
+ conj(invocation)
48
+ end
49
+
50
+ def to_s
51
+ "TOP"
52
+ end
53
+ end
54
+
55
+ EMPTY = EmptyInvocationChain.new
56
+ end
57
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+ module InvocationExceptionMixin
4
+ # Return the invocation chain (list of Rake tasks) that were in
5
+ # effect when this exception was detected by rake. May be null if
6
+ # no tasks were active.
7
+ def chain
8
+ @rake_invocation_chain ||= nil
9
+ end
10
+
11
+ # Set the invocation chain in effect when this exception was
12
+ # detected.
13
+ def chain=(value)
14
+ @rake_invocation_chain = value
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+ # LateTime is a fake timestamp that occurs _after_ any other time value.
4
+ class LateTime
5
+ include Comparable
6
+ include Singleton
7
+
8
+ def <=>(other)
9
+ 1
10
+ end
11
+
12
+ def to_s
13
+ "<LATE TIME>"
14
+ end
15
+ end
16
+
17
+ LATE = LateTime.instance
18
+ end
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+
4
+ # Polylithic linked list structure used to implement several data
5
+ # structures in Rake.
6
+ class LinkedList
7
+ include Enumerable
8
+ attr_reader :head, :tail
9
+
10
+ # Polymorphically add a new element to the head of a list. The
11
+ # type of head node will be the same list type as the tail.
12
+ def conj(item)
13
+ self.class.cons(item, self)
14
+ end
15
+
16
+ # Is the list empty?
17
+ # .make guards against a list being empty making any instantiated LinkedList
18
+ # object not empty by default
19
+ # You should consider overriding this method if you implement your own .make method
20
+ def empty?
21
+ false
22
+ end
23
+
24
+ # Lists are structurally equivalent.
25
+ def ==(other)
26
+ current = self
27
+ while !current.empty? && !other.empty?
28
+ return false if current.head != other.head
29
+ current = current.tail
30
+ other = other.tail
31
+ end
32
+ current.empty? && other.empty?
33
+ end
34
+
35
+ # Convert to string: LL(item, item...)
36
+ def to_s
37
+ items = map(&:to_s).join(", ")
38
+ "LL(#{items})"
39
+ end
40
+
41
+ # Same as +to_s+, but with inspected items.
42
+ def inspect
43
+ items = map(&:inspect).join(", ")
44
+ "LL(#{items})"
45
+ end
46
+
47
+ # For each item in the list.
48
+ def each
49
+ current = self
50
+ while !current.empty?
51
+ yield(current.head)
52
+ current = current.tail
53
+ end
54
+ self
55
+ end
56
+
57
+ # Make a list out of the given arguments. This method is
58
+ # polymorphic
59
+ def self.make(*args)
60
+ # return an EmptyLinkedList if there are no arguments
61
+ return empty if !args || args.empty?
62
+
63
+ # build a LinkedList by starting at the tail and iterating
64
+ # through each argument
65
+ # inject takes an EmptyLinkedList to start
66
+ args.reverse.inject(empty) do |list, item|
67
+ list = cons(item, list)
68
+ list # return the newly created list for each item in the block
69
+ end
70
+ end
71
+
72
+ # Cons a new head onto the tail list.
73
+ def self.cons(head, tail)
74
+ new(head, tail)
75
+ end
76
+
77
+ # The standard empty list class for the given LinkedList class.
78
+ def self.empty
79
+ self::EMPTY
80
+ end
81
+
82
+ protected
83
+
84
+ def initialize(head, tail=EMPTY)
85
+ @head = head
86
+ @tail = tail
87
+ end
88
+
89
+ # Represent an empty list, using the Null Object Pattern.
90
+ #
91
+ # When inheriting from the LinkedList class, you should implement
92
+ # a type specific Empty class as well. Make sure you set the class
93
+ # instance variable @parent to the associated list class (this
94
+ # allows conj, cons and make to work polymorphically).
95
+ class EmptyLinkedList < LinkedList
96
+ @parent = LinkedList
97
+
98
+ def initialize
99
+ end
100
+
101
+ def empty?
102
+ true
103
+ end
104
+
105
+ def self.cons(head, tail)
106
+ @parent.cons(head, tail)
107
+ end
108
+ end
109
+
110
+ EMPTY = EmptyLinkedList.new
111
+ end
112
+ end