rake 13.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/macos.yml +22 -0
- data/.github/workflows/ubuntu-rvm.yml +28 -0
- data/.github/workflows/ubuntu.yml +20 -0
- data/.github/workflows/windows.yml +20 -0
- data/CONTRIBUTING.rdoc +43 -0
- data/Gemfile +10 -0
- data/History.rdoc +2359 -0
- data/MIT-LICENSE +21 -0
- data/README.rdoc +155 -0
- data/Rakefile +41 -0
- data/bin/bundle +105 -0
- data/bin/console +7 -0
- data/bin/rake +29 -0
- data/bin/rdoc +29 -0
- data/bin/rubocop +29 -0
- data/bin/setup +6 -0
- data/doc/command_line_usage.rdoc +158 -0
- data/doc/example/Rakefile1 +38 -0
- data/doc/example/Rakefile2 +35 -0
- data/doc/example/a.c +6 -0
- data/doc/example/b.c +6 -0
- data/doc/example/main.c +11 -0
- data/doc/glossary.rdoc +42 -0
- data/doc/jamis.rb +592 -0
- data/doc/proto_rake.rdoc +127 -0
- data/doc/rake.1 +156 -0
- data/doc/rakefile.rdoc +622 -0
- data/doc/rational.rdoc +151 -0
- data/exe/rake +27 -0
- data/lib/rake.rb +71 -0
- data/lib/rake/application.rb +824 -0
- data/lib/rake/backtrace.rb +24 -0
- data/lib/rake/clean.rb +78 -0
- data/lib/rake/cloneable.rb +17 -0
- data/lib/rake/cpu_counter.rb +107 -0
- data/lib/rake/default_loader.rb +15 -0
- data/lib/rake/dsl_definition.rb +195 -0
- data/lib/rake/early_time.rb +22 -0
- data/lib/rake/ext/core.rb +26 -0
- data/lib/rake/ext/string.rb +176 -0
- data/lib/rake/file_creation_task.rb +25 -0
- data/lib/rake/file_list.rb +435 -0
- data/lib/rake/file_task.rb +54 -0
- data/lib/rake/file_utils.rb +134 -0
- data/lib/rake/file_utils_ext.rb +134 -0
- data/lib/rake/invocation_chain.rb +57 -0
- data/lib/rake/invocation_exception_mixin.rb +17 -0
- data/lib/rake/late_time.rb +18 -0
- data/lib/rake/linked_list.rb +112 -0
- data/lib/rake/loaders/makefile.rb +54 -0
- data/lib/rake/multi_task.rb +14 -0
- data/lib/rake/name_space.rb +38 -0
- data/lib/rake/packagetask.rb +222 -0
- 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 +30 -0
- data/lib/rake/rake_module.rb +67 -0
- data/lib/rake/rake_test_loader.rb +27 -0
- data/lib/rake/rule_recursion_overflow_error.rb +20 -0
- data/lib/rake/scope.rb +43 -0
- data/lib/rake/task.rb +433 -0
- data/lib/rake/task_argument_error.rb +8 -0
- data/lib/rake/task_arguments.rb +109 -0
- data/lib/rake/task_manager.rb +328 -0
- data/lib/rake/tasklib.rb +12 -0
- data/lib/rake/testtask.rb +224 -0
- 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 +10 -0
- data/lib/rake/win32.rb +51 -0
- data/rake.gemspec +36 -0
- metadata +132 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Rake
|
3
|
+
|
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
|
+
|
18
|
+
class MakefileLoader
|
19
|
+
include Rake::DSL
|
20
|
+
|
21
|
+
SPACE_MARK = "\0" # :nodoc:
|
22
|
+
|
23
|
+
# Load the makefile dependencies in +fn+.
|
24
|
+
def load(fn) # :nodoc:
|
25
|
+
lines = File.read fn
|
26
|
+
lines.gsub!(/\\ /, SPACE_MARK)
|
27
|
+
lines.gsub!(/#[^\n]*\n/m, "")
|
28
|
+
lines.gsub!(/\\\n/, " ")
|
29
|
+
lines.each_line do |line|
|
30
|
+
process_line(line)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Process one logical line of makefile data.
|
37
|
+
def process_line(line) # :nodoc:
|
38
|
+
file_tasks, args = line.split(":", 2)
|
39
|
+
return if args.nil?
|
40
|
+
dependents = args.split.map { |d| respace(d) }
|
41
|
+
file_tasks.scan(/\S+/) do |file_task|
|
42
|
+
file_task = respace(file_task)
|
43
|
+
file file_task => dependents
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def respace(str) # :nodoc:
|
48
|
+
str.tr SPACE_MARK, " "
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Install the handler
|
53
|
+
Rake.application.add_loader("mf", MakefileLoader.new)
|
54
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Rake
|
3
|
+
|
4
|
+
# Same as a regular task, but the immediate prerequisites are done in
|
5
|
+
# parallel using Ruby threads.
|
6
|
+
#
|
7
|
+
class MultiTask < Task
|
8
|
+
private
|
9
|
+
|
10
|
+
def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
|
11
|
+
invoke_prerequisites_concurrently(task_args, invocation_chain)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,38 @@
|
|
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
|
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
|
+
|
38
|
+
end
|
@@ -0,0 +1,222 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Define a package task library to aid in the definition of
|
3
|
+
# redistributable package files.
|
4
|
+
|
5
|
+
require "rake"
|
6
|
+
require "rake/tasklib"
|
7
|
+
|
8
|
+
module Rake
|
9
|
+
|
10
|
+
# Create a packaging task that will package the project into
|
11
|
+
# distributable files (e.g zip archive or tar files).
|
12
|
+
#
|
13
|
+
# The PackageTask will create the following targets:
|
14
|
+
#
|
15
|
+
# +:package+ ::
|
16
|
+
# Create all the requested package files.
|
17
|
+
#
|
18
|
+
# +:clobber_package+ ::
|
19
|
+
# Delete all the package files. This target is automatically
|
20
|
+
# added to the main clobber target.
|
21
|
+
#
|
22
|
+
# +:repackage+ ::
|
23
|
+
# Rebuild the package files from scratch, even if they are not out
|
24
|
+
# of date.
|
25
|
+
#
|
26
|
+
# <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tgz"</tt> ::
|
27
|
+
# Create a gzipped tar package (if <em>need_tar</em> is true).
|
28
|
+
#
|
29
|
+
# <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.gz"</tt> ::
|
30
|
+
# Create a gzipped tar package (if <em>need_tar_gz</em> is true).
|
31
|
+
#
|
32
|
+
# <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.bz2"</tt> ::
|
33
|
+
# Create a bzip2'd tar package (if <em>need_tar_bz2</em> is true).
|
34
|
+
#
|
35
|
+
# <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.zip"</tt> ::
|
36
|
+
# Create a zip package archive (if <em>need_zip</em> is true).
|
37
|
+
#
|
38
|
+
# Example:
|
39
|
+
#
|
40
|
+
# Rake::PackageTask.new("rake", "1.2.3") do |p|
|
41
|
+
# p.need_tar = true
|
42
|
+
# p.package_files.include("lib/**/*.rb")
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
class PackageTask < TaskLib
|
46
|
+
# Name of the package (from the GEM Spec).
|
47
|
+
attr_accessor :name
|
48
|
+
|
49
|
+
# Version of the package (e.g. '1.3.2').
|
50
|
+
attr_accessor :version
|
51
|
+
|
52
|
+
# Directory used to store the package files (default is 'pkg').
|
53
|
+
attr_accessor :package_dir
|
54
|
+
|
55
|
+
# True if a gzipped tar file (tgz) should be produced (default is
|
56
|
+
# false).
|
57
|
+
attr_accessor :need_tar
|
58
|
+
|
59
|
+
# True if a gzipped tar file (tar.gz) should be produced (default
|
60
|
+
# is false).
|
61
|
+
attr_accessor :need_tar_gz
|
62
|
+
|
63
|
+
# True if a bzip2'd tar file (tar.bz2) should be produced (default
|
64
|
+
# is false).
|
65
|
+
attr_accessor :need_tar_bz2
|
66
|
+
|
67
|
+
# True if a xz'd tar file (tar.xz) should be produced (default is false)
|
68
|
+
attr_accessor :need_tar_xz
|
69
|
+
|
70
|
+
# True if a zip file should be produced (default is false)
|
71
|
+
attr_accessor :need_zip
|
72
|
+
|
73
|
+
# List of files to be included in the package.
|
74
|
+
attr_accessor :package_files
|
75
|
+
|
76
|
+
# Tar command for gzipped or bzip2ed archives. The default is 'tar'.
|
77
|
+
attr_accessor :tar_command
|
78
|
+
|
79
|
+
# Zip command for zipped archives. The default is 'zip'.
|
80
|
+
attr_accessor :zip_command
|
81
|
+
|
82
|
+
# True if parent directory should be omited (default is false)
|
83
|
+
attr_accessor :without_parent_dir
|
84
|
+
|
85
|
+
# Create a Package Task with the given name and version. Use +:noversion+
|
86
|
+
# as the version to build a package without a version or to provide a
|
87
|
+
# fully-versioned package name.
|
88
|
+
|
89
|
+
def initialize(name=nil, version=nil)
|
90
|
+
init(name, version)
|
91
|
+
yield self if block_given?
|
92
|
+
define unless name.nil?
|
93
|
+
end
|
94
|
+
|
95
|
+
# Initialization that bypasses the "yield self" and "define" step.
|
96
|
+
def init(name, version)
|
97
|
+
@name = name
|
98
|
+
@version = version
|
99
|
+
@package_files = Rake::FileList.new
|
100
|
+
@package_dir = "pkg"
|
101
|
+
@need_tar = false
|
102
|
+
@need_tar_gz = false
|
103
|
+
@need_tar_bz2 = false
|
104
|
+
@need_tar_xz = false
|
105
|
+
@need_zip = false
|
106
|
+
@tar_command = "tar"
|
107
|
+
@zip_command = "zip"
|
108
|
+
@without_parent_dir = false
|
109
|
+
end
|
110
|
+
|
111
|
+
# Create the tasks defined by this task library.
|
112
|
+
def define
|
113
|
+
fail "Version required (or :noversion)" if @version.nil?
|
114
|
+
@version = nil if :noversion == @version
|
115
|
+
|
116
|
+
desc "Build all the packages"
|
117
|
+
task :package
|
118
|
+
|
119
|
+
desc "Force a rebuild of the package files"
|
120
|
+
task repackage: [:clobber_package, :package]
|
121
|
+
|
122
|
+
desc "Remove package products"
|
123
|
+
task :clobber_package do
|
124
|
+
rm_r package_dir rescue nil
|
125
|
+
end
|
126
|
+
|
127
|
+
task clobber: [:clobber_package]
|
128
|
+
|
129
|
+
[
|
130
|
+
[need_tar, tgz_file, "z"],
|
131
|
+
[need_tar_gz, tar_gz_file, "z"],
|
132
|
+
[need_tar_bz2, tar_bz2_file, "j"],
|
133
|
+
[need_tar_xz, tar_xz_file, "J"]
|
134
|
+
].each do |need, file, flag|
|
135
|
+
if need
|
136
|
+
task package: ["#{package_dir}/#{file}"]
|
137
|
+
file "#{package_dir}/#{file}" =>
|
138
|
+
[package_dir_path] + package_files do
|
139
|
+
chdir(working_dir) { sh @tar_command, "#{flag}cvf", file, target_dir }
|
140
|
+
mv "#{package_dir_path}/#{target_dir}", package_dir if without_parent_dir
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
if need_zip
|
146
|
+
task package: ["#{package_dir}/#{zip_file}"]
|
147
|
+
file "#{package_dir}/#{zip_file}" =>
|
148
|
+
[package_dir_path] + package_files do
|
149
|
+
chdir(working_dir) { sh @zip_command, "-r", zip_file, target_dir }
|
150
|
+
mv "#{package_dir_path}/#{zip_file}", package_dir if without_parent_dir
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
directory package_dir_path => @package_files do
|
155
|
+
@package_files.each do |fn|
|
156
|
+
f = File.join(package_dir_path, fn)
|
157
|
+
fdir = File.dirname(f)
|
158
|
+
mkdir_p(fdir) unless File.exist?(fdir)
|
159
|
+
if File.directory?(fn)
|
160
|
+
mkdir_p(f)
|
161
|
+
else
|
162
|
+
rm_f f
|
163
|
+
safe_ln(fn, f)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
self
|
168
|
+
end
|
169
|
+
|
170
|
+
# The name of this package
|
171
|
+
|
172
|
+
def package_name
|
173
|
+
@version ? "#{@name}-#{@version}" : @name
|
174
|
+
end
|
175
|
+
|
176
|
+
# The directory this package will be built in
|
177
|
+
|
178
|
+
def package_dir_path
|
179
|
+
"#{package_dir}/#{package_name}"
|
180
|
+
end
|
181
|
+
|
182
|
+
# The package name with .tgz added
|
183
|
+
|
184
|
+
def tgz_file
|
185
|
+
"#{package_name}.tgz"
|
186
|
+
end
|
187
|
+
|
188
|
+
# The package name with .tar.gz added
|
189
|
+
|
190
|
+
def tar_gz_file
|
191
|
+
"#{package_name}.tar.gz"
|
192
|
+
end
|
193
|
+
|
194
|
+
# The package name with .tar.bz2 added
|
195
|
+
|
196
|
+
def tar_bz2_file
|
197
|
+
"#{package_name}.tar.bz2"
|
198
|
+
end
|
199
|
+
|
200
|
+
# The package name with .tar.xz added
|
201
|
+
|
202
|
+
def tar_xz_file
|
203
|
+
"#{package_name}.tar.xz"
|
204
|
+
end
|
205
|
+
|
206
|
+
# The package name with .zip added
|
207
|
+
|
208
|
+
def zip_file
|
209
|
+
"#{package_name}.zip"
|
210
|
+
end
|
211
|
+
|
212
|
+
def working_dir
|
213
|
+
without_parent_dir ? package_dir_path : package_dir
|
214
|
+
end
|
215
|
+
|
216
|
+
# target directory relative to working_dir
|
217
|
+
def target_dir
|
218
|
+
without_parent_dir ? "." : package_name
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
end
|
data/lib/rake/phony.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Defines a :phony task that you can use as a dependency. This allows
|
3
|
+
# file-based tasks to use non-file-based tasks as prerequisites
|
4
|
+
# without forcing them to rebuild.
|
5
|
+
#
|
6
|
+
# See FileTask#out_of_date? and Task#timestamp for more info.
|
7
|
+
|
8
|
+
require "rake"
|
9
|
+
|
10
|
+
task :phony
|
11
|
+
|
12
|
+
Rake::Task[:phony].tap do |task|
|
13
|
+
def task.timestamp # :nodoc:
|
14
|
+
Time.at 0
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Rake
|
3
|
+
|
4
|
+
# Include PrivateReader to use +private_reader+.
|
5
|
+
module PrivateReader # :nodoc: all
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
|
13
|
+
# Declare a list of private accessors
|
14
|
+
def private_reader(*names)
|
15
|
+
attr_reader(*names)
|
16
|
+
private(*names)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/rake/promise.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Rake
|
3
|
+
|
4
|
+
# A Promise object represents a promise to do work (a chore) in the
|
5
|
+
# future. The promise is created with a block and a list of
|
6
|
+
# arguments for the block. Calling value will return the value of
|
7
|
+
# the promised chore.
|
8
|
+
#
|
9
|
+
# Used by ThreadPool.
|
10
|
+
#
|
11
|
+
class Promise # :nodoc: all
|
12
|
+
NOT_SET = Object.new.freeze # :nodoc:
|
13
|
+
|
14
|
+
attr_accessor :recorder
|
15
|
+
|
16
|
+
# Create a promise to do the chore specified by the block.
|
17
|
+
def initialize(args, &block)
|
18
|
+
@mutex = Mutex.new
|
19
|
+
@result = NOT_SET
|
20
|
+
@error = NOT_SET
|
21
|
+
@args = args
|
22
|
+
@block = block
|
23
|
+
end
|
24
|
+
|
25
|
+
# Return the value of this promise.
|
26
|
+
#
|
27
|
+
# If the promised chore is not yet complete, then do the work
|
28
|
+
# synchronously. We will wait.
|
29
|
+
def value
|
30
|
+
unless complete?
|
31
|
+
stat :sleeping_on, item_id: object_id
|
32
|
+
@mutex.synchronize do
|
33
|
+
stat :has_lock_on, item_id: object_id
|
34
|
+
chore
|
35
|
+
stat :releasing_lock_on, item_id: object_id
|
36
|
+
end
|
37
|
+
end
|
38
|
+
error? ? raise(@error) : @result
|
39
|
+
end
|
40
|
+
|
41
|
+
# If no one else is working this promise, go ahead and do the chore.
|
42
|
+
def work
|
43
|
+
stat :attempting_lock_on, item_id: object_id
|
44
|
+
if @mutex.try_lock
|
45
|
+
stat :has_lock_on, item_id: object_id
|
46
|
+
chore
|
47
|
+
stat :releasing_lock_on, item_id: object_id
|
48
|
+
@mutex.unlock
|
49
|
+
else
|
50
|
+
stat :bailed_on, item_id: object_id
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
# Perform the chore promised
|
57
|
+
def chore
|
58
|
+
if complete?
|
59
|
+
stat :found_completed, item_id: object_id
|
60
|
+
return
|
61
|
+
end
|
62
|
+
stat :will_execute, item_id: object_id
|
63
|
+
begin
|
64
|
+
@result = @block.call(*@args)
|
65
|
+
rescue Exception => e
|
66
|
+
@error = e
|
67
|
+
end
|
68
|
+
stat :did_execute, item_id: object_id
|
69
|
+
discard
|
70
|
+
end
|
71
|
+
|
72
|
+
# Do we have a result for the promise
|
73
|
+
def result?
|
74
|
+
!@result.equal?(NOT_SET)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Did the promise throw an error
|
78
|
+
def error?
|
79
|
+
!@error.equal?(NOT_SET)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Are we done with the promise
|
83
|
+
def complete?
|
84
|
+
result? || error?
|
85
|
+
end
|
86
|
+
|
87
|
+
# free up these items for the GC
|
88
|
+
def discard
|
89
|
+
@args = nil
|
90
|
+
@block = nil
|
91
|
+
end
|
92
|
+
|
93
|
+
# Record execution statistics if there is a recorder
|
94
|
+
def stat(*args)
|
95
|
+
@recorder.call(*args) if @recorder
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|