rake 0.9.2.2 → 13.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.rdoc +2403 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +64 -106
- data/doc/command_line_usage.rdoc +65 -21
- data/doc/glossary.rdoc +40 -49
- data/doc/jamis.rb +1 -0
- data/doc/rake.1 +156 -0
- data/doc/rakefile.rdoc +127 -62
- data/{bin → exe}/rake +1 -7
- data/lib/rake/application.rb +507 -271
- data/lib/rake/backtrace.rb +24 -0
- data/lib/rake/clean.rb +54 -8
- data/lib/rake/cloneable.rb +11 -19
- data/lib/rake/cpu_counter.rb +107 -0
- data/lib/rake/default_loader.rb +5 -0
- data/lib/rake/dsl_definition.rb +67 -48
- data/lib/rake/early_time.rb +5 -1
- data/lib/rake/ext/core.rb +5 -6
- data/lib/rake/ext/string.rb +61 -52
- data/lib/rake/file_creation_task.rb +4 -3
- data/lib/rake/file_list.rb +81 -49
- data/lib/rake/file_task.rb +15 -8
- data/lib/rake/file_utils.rb +63 -43
- data/lib/rake/file_utils_ext.rb +14 -25
- data/lib/rake/invocation_chain.rb +25 -19
- data/lib/rake/invocation_exception_mixin.rb +1 -0
- data/lib/rake/late_time.rb +18 -0
- data/lib/rake/linked_list.rb +112 -0
- data/lib/rake/loaders/makefile.rb +23 -9
- data/lib/rake/multi_task.rb +4 -6
- data/lib/rake/name_space.rb +36 -23
- data/lib/rake/packagetask.rb +71 -34
- data/lib/rake/phony.rb +16 -0
- data/lib/rake/private_reader.rb +21 -0
- data/lib/rake/promise.rb +100 -0
- data/lib/rake/pseudo_status.rb +8 -2
- data/lib/rake/rake_module.rb +41 -3
- data/lib/rake/rake_test_loader.rb +9 -4
- data/lib/rake/rule_recursion_overflow_error.rb +2 -2
- data/lib/rake/scope.rb +43 -0
- data/lib/rake/task.rb +186 -79
- data/lib/rake/task_argument_error.rb +1 -0
- data/lib/rake/task_arguments.rb +46 -15
- data/lib/rake/task_manager.rb +91 -67
- data/lib/rake/tasklib.rb +2 -12
- data/lib/rake/testtask.rb +61 -63
- data/lib/rake/thread_history_display.rb +49 -0
- data/lib/rake/thread_pool.rb +163 -0
- data/lib/rake/trace_output.rb +23 -0
- data/lib/rake/version.rb +5 -3
- data/lib/rake/win32.rb +14 -18
- data/lib/rake.rb +35 -33
- data/rake.gemspec +100 -0
- metadata +74 -176
- data/.gemtest +0 -0
- data/CHANGES +0 -522
- data/Rakefile +0 -369
- data/TODO +0 -20
- data/doc/rake.1.gz +0 -0
- data/doc/release_notes/rake-0.4.14.rdoc +0 -23
- data/doc/release_notes/rake-0.4.15.rdoc +0 -35
- data/doc/release_notes/rake-0.5.0.rdoc +0 -53
- data/doc/release_notes/rake-0.5.3.rdoc +0 -78
- data/doc/release_notes/rake-0.5.4.rdoc +0 -46
- data/doc/release_notes/rake-0.6.0.rdoc +0 -141
- data/doc/release_notes/rake-0.7.0.rdoc +0 -119
- data/doc/release_notes/rake-0.7.1.rdoc +0 -59
- data/doc/release_notes/rake-0.7.2.rdoc +0 -121
- data/doc/release_notes/rake-0.7.3.rdoc +0 -47
- data/doc/release_notes/rake-0.8.0.rdoc +0 -114
- data/doc/release_notes/rake-0.8.2.rdoc +0 -165
- data/doc/release_notes/rake-0.8.3.rdoc +0 -112
- data/doc/release_notes/rake-0.8.4.rdoc +0 -147
- data/doc/release_notes/rake-0.8.5.rdoc +0 -53
- data/doc/release_notes/rake-0.8.6.rdoc +0 -55
- data/doc/release_notes/rake-0.8.7.rdoc +0 -55
- data/doc/release_notes/rake-0.9.0.rdoc +0 -112
- data/doc/release_notes/rake-0.9.1.rdoc +0 -52
- data/doc/release_notes/rake-0.9.2.rdoc +0 -49
- data/install.rb +0 -90
- data/lib/rake/alt_system.rb +0 -109
- data/lib/rake/classic_namespace.rb +0 -11
- data/lib/rake/contrib/compositepublisher.rb +0 -21
- data/lib/rake/contrib/ftptools.rb +0 -150
- data/lib/rake/contrib/publisher.rb +0 -73
- data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
- data/lib/rake/contrib/sshpublisher.rb +0 -50
- data/lib/rake/contrib/sys.rb +0 -191
- data/lib/rake/ext/module.rb +0 -39
- data/lib/rake/ext/time.rb +0 -14
- data/lib/rake/gempackagetask.rb +0 -15
- data/lib/rake/pathmap.rb +0 -1
- data/lib/rake/rdoctask.rb +0 -234
- data/lib/rake/ruby182_test_unit_fix.rb +0 -25
- data/lib/rake/runtest.rb +0 -21
- data/test/file_creation.rb +0 -34
- data/test/helper.rb +0 -492
- data/test/test_rake.rb +0 -40
- data/test/test_rake_application.rb +0 -489
- data/test/test_rake_application_options.rb +0 -335
- data/test/test_rake_clean.rb +0 -14
- data/test/test_rake_definitions.rb +0 -80
- data/test/test_rake_directory_task.rb +0 -46
- data/test/test_rake_dsl.rb +0 -77
- data/test/test_rake_early_time.rb +0 -31
- data/test/test_rake_extension.rb +0 -59
- data/test/test_rake_file_creation_task.rb +0 -56
- data/test/test_rake_file_list.rb +0 -628
- data/test/test_rake_file_list_path_map.rb +0 -8
- data/test/test_rake_file_task.rb +0 -102
- data/test/test_rake_file_utils.rb +0 -305
- data/test/test_rake_ftp_file.rb +0 -59
- data/test/test_rake_functional.rb +0 -450
- data/test/test_rake_invocation_chain.rb +0 -52
- data/test/test_rake_makefile_loader.rb +0 -44
- data/test/test_rake_multi_task.rb +0 -51
- data/test/test_rake_name_space.rb +0 -43
- data/test/test_rake_package_task.rb +0 -79
- data/test/test_rake_path_map.rb +0 -157
- data/test/test_rake_path_map_explode.rb +0 -34
- data/test/test_rake_path_map_partial.rb +0 -18
- data/test/test_rake_pseudo_status.rb +0 -21
- data/test/test_rake_rake_test_loader.rb +0 -21
- data/test/test_rake_rdoc_task.rb +0 -83
- data/test/test_rake_require.rb +0 -40
- data/test/test_rake_rules.rb +0 -327
- data/test/test_rake_task.rb +0 -267
- data/test/test_rake_task_argument_parsing.rb +0 -103
- data/test/test_rake_task_arguments.rb +0 -88
- data/test/test_rake_task_lib.rb +0 -9
- data/test/test_rake_task_manager.rb +0 -157
- data/test/test_rake_task_manager_argument_resolution.rb +0 -36
- data/test/test_rake_task_with_arguments.rb +0 -173
- data/test/test_rake_test_task.rb +0 -120
- data/test/test_rake_top_level_functions.rb +0 -111
- data/test/test_rake_win32.rb +0 -72
- data/test/test_sys.rb +0 -20
data/lib/rake/file_utils.rb
CHANGED
@@ -1,31 +1,41 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "rbconfig"
|
3
|
+
require "fileutils"
|
3
4
|
|
4
5
|
#--
|
5
6
|
# This a FileUtils extension that defines several additional commands to be
|
6
7
|
# added to the FileUtils utility functions.
|
7
8
|
module FileUtils
|
8
9
|
# Path to the currently running Ruby program
|
9
|
-
RUBY = File.join(
|
10
|
-
RbConfig::CONFIG[
|
11
|
-
RbConfig::CONFIG[
|
10
|
+
RUBY = ENV["RUBY"] || File.join(
|
11
|
+
RbConfig::CONFIG["bindir"],
|
12
|
+
RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]).
|
12
13
|
sub(/.*\s.*/m, '"\&"')
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# Run the system command +cmd+. If multiple arguments are given the command
|
18
|
-
# is not run with the shell (same semantics as Kernel::exec and
|
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
|
19
17
|
# Kernel::system).
|
20
18
|
#
|
21
|
-
#
|
22
|
-
#
|
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'
|
23
33
|
#
|
24
34
|
# sh 'ls', 'file with spaces'
|
25
35
|
#
|
26
36
|
# # check exit status after command runs
|
27
37
|
# sh %{grep pattern file} do |ok, res|
|
28
|
-
# if !
|
38
|
+
# if !ok
|
29
39
|
# puts "pattern not found (status = #{res.exitstatus})"
|
30
40
|
# end
|
31
41
|
# end
|
@@ -33,53 +43,65 @@ module FileUtils
|
|
33
43
|
def sh(*cmd, &block)
|
34
44
|
options = (Hash === cmd.last) ? cmd.pop : {}
|
35
45
|
shell_runner = block_given? ? block : create_shell_runner(cmd)
|
46
|
+
|
36
47
|
set_verbose_option(options)
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
40
52
|
|
41
|
-
unless
|
42
|
-
res =
|
53
|
+
unless noop
|
54
|
+
res = (Hash === cmd.last) ? system(*cmd) : system(*cmd, options)
|
43
55
|
status = $?
|
44
|
-
status = PseudoStatus.new(1) if !res && status.nil?
|
56
|
+
status = Rake::PseudoStatus.new(1) if !res && status.nil?
|
45
57
|
shell_runner.call(res, status)
|
46
58
|
end
|
47
59
|
end
|
48
60
|
|
49
61
|
def create_shell_runner(cmd) # :nodoc:
|
50
|
-
show_command = cmd
|
51
|
-
show_command = show_command[0,42] + "..." unless $trace
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
55
70
|
end
|
56
71
|
private :create_shell_runner
|
57
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
|
+
|
58
86
|
def set_verbose_option(options) # :nodoc:
|
59
87
|
unless options.key? :verbose
|
60
88
|
options[:verbose] =
|
61
|
-
Rake::FileUtilsExt.verbose_flag == Rake::FileUtilsExt::DEFAULT ||
|
89
|
+
(Rake::FileUtilsExt.verbose_flag == Rake::FileUtilsExt::DEFAULT) ||
|
62
90
|
Rake::FileUtilsExt.verbose_flag
|
63
91
|
end
|
64
92
|
end
|
65
93
|
private :set_verbose_option
|
66
94
|
|
67
|
-
def rake_system(*cmd) # :nodoc:
|
68
|
-
Rake::AltSystem.system(*cmd)
|
69
|
-
end
|
70
|
-
private :rake_system
|
71
|
-
|
72
95
|
# Run a Ruby interpreter with the given arguments.
|
73
96
|
#
|
74
97
|
# Example:
|
75
98
|
# ruby %{-pe '$_.upcase!' <README}
|
76
99
|
#
|
77
|
-
def ruby(*args
|
78
|
-
|
79
|
-
|
80
|
-
sh(*([RUBY] + args + [options]), &block)
|
100
|
+
def ruby(*args, **options, &block)
|
101
|
+
if args.length > 1
|
102
|
+
sh(RUBY, *args, **options, &block)
|
81
103
|
else
|
82
|
-
sh("#{RUBY} #{args.first}", options, &block)
|
104
|
+
sh("#{RUBY} #{args.first}", **options, &block)
|
83
105
|
end
|
84
106
|
end
|
85
107
|
|
@@ -87,17 +109,15 @@ module FileUtils
|
|
87
109
|
|
88
110
|
# Attempt to do a normal file link, but fall back to a copy if the link
|
89
111
|
# fails.
|
90
|
-
def safe_ln(*args)
|
91
|
-
|
92
|
-
cp(*args)
|
93
|
-
else
|
112
|
+
def safe_ln(*args, **options)
|
113
|
+
if LN_SUPPORTED[0]
|
94
114
|
begin
|
95
|
-
ln(*args)
|
115
|
+
return options.empty? ? ln(*args) : ln(*args, **options)
|
96
116
|
rescue StandardError, NotImplementedError
|
97
117
|
LN_SUPPORTED[0] = false
|
98
|
-
cp(*args)
|
99
118
|
end
|
100
119
|
end
|
120
|
+
options.empty? ? cp(*args) : cp(*args, **options)
|
101
121
|
end
|
102
122
|
|
103
123
|
# Split a file path into individual directory names.
|
@@ -107,8 +127,8 @@ module FileUtils
|
|
107
127
|
#
|
108
128
|
def split_all(path)
|
109
129
|
head, tail = File.split(path)
|
110
|
-
return [tail] if head ==
|
111
|
-
return [head, tail] if head ==
|
130
|
+
return [tail] if head == "." || tail == "/"
|
131
|
+
return [head, tail] if head == "/"
|
112
132
|
return split_all(head) + [tail]
|
113
133
|
end
|
114
134
|
end
|
data/lib/rake/file_utils_ext.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "rake/file_utils"
|
2
3
|
|
3
4
|
module Rake
|
4
5
|
#
|
@@ -18,25 +19,22 @@ module Rake
|
|
18
19
|
FileUtilsExt.verbose_flag = DEFAULT
|
19
20
|
FileUtilsExt.nowrite_flag = false
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
FileUtils::OPT_TABLE.each do |name, opts|
|
22
|
+
FileUtils.commands.each do |name|
|
23
|
+
opts = FileUtils.options_of name
|
25
24
|
default_options = []
|
26
|
-
if opts.include?(
|
27
|
-
default_options <<
|
25
|
+
if opts.include?("verbose")
|
26
|
+
default_options << "verbose: FileUtilsExt.verbose_flag"
|
28
27
|
end
|
29
|
-
if opts.include?(
|
30
|
-
default_options <<
|
28
|
+
if opts.include?("noop")
|
29
|
+
default_options << "noop: FileUtilsExt.nowrite_flag"
|
31
30
|
end
|
32
31
|
|
33
32
|
next if default_options.empty?
|
34
33
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
35
|
-
def #{name}(
|
36
|
-
super(
|
37
|
-
|
38
|
-
|
39
|
-
), &block)
|
34
|
+
def #{name}(*args, **options, &block)
|
35
|
+
super(*args,
|
36
|
+
#{default_options.join(', ')},
|
37
|
+
**options, &block)
|
40
38
|
end
|
41
39
|
EOS
|
42
40
|
end
|
@@ -114,16 +112,6 @@ module Rake
|
|
114
112
|
end
|
115
113
|
end
|
116
114
|
|
117
|
-
# Merge the given options with the default values.
|
118
|
-
def rake_merge_option(args, defaults)
|
119
|
-
if Hash === args.last
|
120
|
-
defaults.update(args.last)
|
121
|
-
args.pop
|
122
|
-
end
|
123
|
-
args.push defaults
|
124
|
-
args
|
125
|
-
end
|
126
|
-
|
127
115
|
# Send the message to the default rake output (which is $stderr).
|
128
116
|
def rake_output_message(message)
|
129
117
|
$stderr.puts(message)
|
@@ -137,7 +125,8 @@ module Rake
|
|
137
125
|
optdecl.each do |name|
|
138
126
|
h.delete name
|
139
127
|
end
|
140
|
-
raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless
|
128
|
+
raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless
|
129
|
+
h.empty?
|
141
130
|
end
|
142
131
|
|
143
132
|
extend self
|
@@ -1,46 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Rake
|
2
3
|
|
3
|
-
####################################################################
|
4
4
|
# InvocationChain tracks the chain of task invocations to detect
|
5
5
|
# circular dependencies.
|
6
|
-
class InvocationChain
|
7
|
-
def initialize(value, tail)
|
8
|
-
@value = value
|
9
|
-
@tail = tail
|
10
|
-
end
|
6
|
+
class InvocationChain < LinkedList
|
11
7
|
|
12
|
-
|
13
|
-
|
8
|
+
# Is the invocation already in the chain?
|
9
|
+
def member?(invocation)
|
10
|
+
head == invocation || tail.member?(invocation)
|
14
11
|
end
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
|
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}"
|
19
18
|
end
|
20
|
-
|
19
|
+
conj(invocation)
|
21
20
|
end
|
22
21
|
|
22
|
+
# Convert to string, ie: TOP => invocation => invocation
|
23
23
|
def to_s
|
24
|
-
"#{prefix}#{
|
24
|
+
"#{prefix}#{head}"
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
# Class level append.
|
28
|
+
def self.append(invocation, chain)
|
29
|
+
chain.append(invocation)
|
29
30
|
end
|
30
31
|
|
31
32
|
private
|
32
33
|
|
33
34
|
def prefix
|
34
|
-
"#{
|
35
|
+
"#{tail} => "
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
|
+
# Null object for an empty chain.
|
39
|
+
class EmptyInvocationChain < LinkedList::EmptyLinkedList
|
40
|
+
@parent = InvocationChain
|
41
|
+
|
38
42
|
def member?(obj)
|
39
43
|
false
|
40
44
|
end
|
41
|
-
|
42
|
-
|
45
|
+
|
46
|
+
def append(invocation)
|
47
|
+
conj(invocation)
|
43
48
|
end
|
49
|
+
|
44
50
|
def to_s
|
45
51
|
"TOP"
|
46
52
|
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
|
@@ -1,17 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Rake
|
2
3
|
|
3
|
-
# Makefile loader to be used with the import file loader.
|
4
|
+
# Makefile loader to be used with the import file loader. Use this to
|
5
|
+
# import dependencies from make dependency tools:
|
6
|
+
#
|
7
|
+
# require 'rake/loaders/makefile'
|
8
|
+
#
|
9
|
+
# file ".depends.mf" => [SRC_LIST] do |t|
|
10
|
+
# sh "makedepend -f- -- #{CFLAGS} -- #{t.prerequisites} > #{t.name}"
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# import ".depends.mf"
|
14
|
+
#
|
15
|
+
# See {Importing Dependencies}[link:doc/rakefile_rdoc.html#label-Importing+Dependencies]
|
16
|
+
# for further details.
|
17
|
+
|
4
18
|
class MakefileLoader
|
5
19
|
include Rake::DSL
|
6
20
|
|
7
|
-
SPACE_MARK = "\0"
|
21
|
+
SPACE_MARK = "\0" # :nodoc:
|
8
22
|
|
9
23
|
# Load the makefile dependencies in +fn+.
|
10
|
-
def load(fn)
|
24
|
+
def load(fn) # :nodoc:
|
11
25
|
lines = File.read fn
|
12
26
|
lines.gsub!(/\\ /, SPACE_MARK)
|
13
27
|
lines.gsub!(/#[^\n]*\n/m, "")
|
14
|
-
lines.gsub!(/\\\n/,
|
28
|
+
lines.gsub!(/\\\n/, " ")
|
15
29
|
lines.each_line do |line|
|
16
30
|
process_line(line)
|
17
31
|
end
|
@@ -20,8 +34,8 @@ module Rake
|
|
20
34
|
private
|
21
35
|
|
22
36
|
# Process one logical line of makefile data.
|
23
|
-
def process_line(line)
|
24
|
-
file_tasks, args = line.split(
|
37
|
+
def process_line(line) # :nodoc:
|
38
|
+
file_tasks, args = line.split(":", 2)
|
25
39
|
return if args.nil?
|
26
40
|
dependents = args.split.map { |d| respace(d) }
|
27
41
|
file_tasks.scan(/\S+/) do |file_task|
|
@@ -30,11 +44,11 @@ module Rake
|
|
30
44
|
end
|
31
45
|
end
|
32
46
|
|
33
|
-
def respace(str)
|
34
|
-
str.tr SPACE_MARK,
|
47
|
+
def respace(str) # :nodoc:
|
48
|
+
str.tr SPACE_MARK, " "
|
35
49
|
end
|
36
50
|
end
|
37
51
|
|
38
52
|
# Install the handler
|
39
|
-
Rake.application.add_loader(
|
53
|
+
Rake.application.add_loader("mf", MakefileLoader.new)
|
40
54
|
end
|
data/lib/rake/multi_task.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Rake
|
2
3
|
|
3
4
|
# Same as a regular task, but the immediate prerequisites are done in
|
@@ -5,12 +6,9 @@ module Rake
|
|
5
6
|
#
|
6
7
|
class MultiTask < Task
|
7
8
|
private
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
threads.each { |t| t.join }
|
9
|
+
|
10
|
+
def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
|
11
|
+
invoke_prerequisites_concurrently(task_args, invocation_chain)
|
13
12
|
end
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
data/lib/rake/name_space.rb
CHANGED
@@ -1,25 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# Lookup a task named +name+ in the namespace.
|
16
|
-
def [](name)
|
17
|
-
@task_manager.lookup(name, @scope)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Return the list of tasks defined in this and nested namespaces.
|
21
|
-
def tasks
|
22
|
-
@task_manager.tasks_in_scope(@scope)
|
23
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# The NameSpace class will lookup task names in the scope defined by a
|
4
|
+
# +namespace+ command.
|
5
|
+
|
6
|
+
class Rake::NameSpace
|
7
|
+
|
8
|
+
##
|
9
|
+
# Create a namespace lookup object using the given task manager
|
10
|
+
# and the list of scopes.
|
11
|
+
|
12
|
+
def initialize(task_manager, scope_list)
|
13
|
+
@task_manager = task_manager
|
14
|
+
@scope = scope_list.dup
|
24
15
|
end
|
16
|
+
|
17
|
+
##
|
18
|
+
# Lookup a task named +name+ in the namespace.
|
19
|
+
|
20
|
+
def [](name)
|
21
|
+
@task_manager.lookup(name, @scope)
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# The scope of the namespace (a LinkedList)
|
26
|
+
|
27
|
+
def scope
|
28
|
+
@scope.dup
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Return the list of tasks defined in this and nested namespaces.
|
33
|
+
|
34
|
+
def tasks
|
35
|
+
@task_manager.tasks_in_scope(@scope)
|
36
|
+
end
|
37
|
+
|
25
38
|
end
|