build 2.6.2 → 2.7.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/build/build_node.rb +63 -31
- data/lib/build/chain_node.rb +16 -26
- data/lib/build/controller.rb +26 -36
- data/lib/build/dependency_node.rb +28 -22
- data/lib/build/graphviz.rb +12 -26
- data/lib/build/name.rb +15 -24
- data/lib/build/provision_node.rb +28 -21
- data/lib/build/rule.rb +60 -23
- data/lib/build/rule_node.rb +16 -20
- data/lib/build/rulebook.rb +22 -22
- data/lib/build/task.rb +16 -25
- data/lib/build/version.rb +6 -20
- data/lib/build.rb +5 -20
- data/license.md +21 -0
- data/readme.md +47 -0
- data/releases.md +3 -0
- data.tar.gz.sig +0 -0
- metadata +11 -80
- metadata.gz.sig +0 -0
data/lib/build/provision_node.rb
CHANGED
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
20
2
|
|
|
21
|
-
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2019, by Samuel Williams.
|
|
22
5
|
|
|
23
|
-
|
|
6
|
+
require "build/graph"
|
|
7
|
+
|
|
8
|
+
require_relative "build_node"
|
|
24
9
|
|
|
25
10
|
module Build
|
|
11
|
+
# Represents a build graph node for applying a single provision within a dependency chain.
|
|
26
12
|
class ProvisionNode < Graph::Node
|
|
13
|
+
# Initialize the provision node.
|
|
14
|
+
# @parameter chain [Build::Dependency::Chain] The dependency chain.
|
|
15
|
+
# @parameter provision [Build::Dependency::Provision] The provision to apply.
|
|
16
|
+
# @parameter environment [Build::Environment] The root environment.
|
|
17
|
+
# @parameter arguments [Array] Arguments passed down the build chain.
|
|
27
18
|
def initialize(chain, provision, environment, arguments)
|
|
28
19
|
@chain = chain
|
|
29
20
|
@provision = provision
|
|
@@ -39,6 +30,7 @@ module Build
|
|
|
39
30
|
attr :environment
|
|
40
31
|
attr :arguments
|
|
41
32
|
|
|
33
|
+
# @returns [Boolean] Whether this node is equal to another.
|
|
42
34
|
def == other
|
|
43
35
|
super and
|
|
44
36
|
@chain == other.chain and
|
|
@@ -47,30 +39,40 @@ module Build
|
|
|
47
39
|
@arguments == other.arguments
|
|
48
40
|
end
|
|
49
41
|
|
|
42
|
+
# @returns [Integer] A hash value for this node.
|
|
50
43
|
def hash
|
|
51
44
|
super ^ @chain.hash ^ @provision.hash ^ @environment.hash ^ @arguments.hash
|
|
52
45
|
end
|
|
53
46
|
|
|
47
|
+
# @returns [Class] The task class to use for this node.
|
|
54
48
|
def task_class(parent_task)
|
|
55
49
|
ProvisionTask
|
|
56
50
|
end
|
|
57
51
|
|
|
52
|
+
# @returns [String] The name of the provision.
|
|
58
53
|
def name
|
|
59
54
|
@provision.name
|
|
60
55
|
end
|
|
61
56
|
|
|
57
|
+
# Build a {DependencyNode} for the given dependency.
|
|
58
|
+
# @parameter dependency [Build::Dependency] The dependency to wrap.
|
|
59
|
+
# @returns [Build::DependencyNode] The corresponding dependency node.
|
|
62
60
|
def dependency_node_for(dependency)
|
|
63
61
|
DependencyNode.new(@chain, dependency, @environment, @arguments)
|
|
64
62
|
end
|
|
65
63
|
end
|
|
66
64
|
|
|
65
|
+
# @namespace
|
|
67
66
|
module DependenciesFailed
|
|
67
|
+
# @returns [String] A description of the failure.
|
|
68
68
|
def self.to_s
|
|
69
69
|
"Failed to build all dependencies!"
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
+
# Represents a task that builds the dependencies of a provision and applies the provision itself.
|
|
73
74
|
class ProvisionTask < Task
|
|
75
|
+
# Initialize the provision task.
|
|
74
76
|
def initialize(*arguments, **options)
|
|
75
77
|
super
|
|
76
78
|
|
|
@@ -87,10 +89,12 @@ module Build
|
|
|
87
89
|
|
|
88
90
|
attr :build_task
|
|
89
91
|
|
|
92
|
+
# @returns [Build::Dependency::Provision] The provision being built by this task.
|
|
90
93
|
def provision
|
|
91
94
|
@node.provision
|
|
92
95
|
end
|
|
93
96
|
|
|
97
|
+
# Build all dependencies and then apply the provision.
|
|
94
98
|
def update
|
|
95
99
|
provision.each_dependency do |dependency|
|
|
96
100
|
@dependencies << invoke(@node.dependency_node_for(dependency))
|
|
@@ -103,16 +107,19 @@ module Build
|
|
|
103
107
|
end
|
|
104
108
|
end
|
|
105
109
|
|
|
110
|
+
# @returns [Build::Environment] The combined local environment for this provision.
|
|
106
111
|
def local_environment
|
|
107
112
|
Build::Environment.combine(@node.environment, *@environments)&.evaluate(name: @node.name).freeze
|
|
108
113
|
end
|
|
109
114
|
|
|
115
|
+
# @returns [Build::Environment | Nil] The output environment produced by the build task, if any.
|
|
110
116
|
def output_environment
|
|
111
117
|
if @build_task
|
|
112
118
|
@build_task.output_environment.dup(parent: nil)
|
|
113
119
|
end
|
|
114
120
|
end
|
|
115
121
|
|
|
122
|
+
# @returns [Array(Build::Environment)] All output environments including any public ones.
|
|
116
123
|
def output_environments
|
|
117
124
|
environments = @public_environments.dup
|
|
118
125
|
|
data/lib/build/rule.rb
CHANGED
|
@@ -1,35 +1,28 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2015-2019, by Samuel Williams.
|
|
20
5
|
|
|
21
6
|
module Build
|
|
22
7
|
# A rule is a function with a specific set of input and output parameters, which can match against a given set of specific arguments. For example, there might be several rules for compiling, but the specific rules depend on the language being compiled.
|
|
23
8
|
class Rule
|
|
9
|
+
# Build a frozen rule from a name and a definition block.
|
|
10
|
+
# @parameter name [String] The rule name in `"process.type"` format.
|
|
11
|
+
# @returns [Build::Rule] The constructed and frozen rule.
|
|
24
12
|
def self.build(name, &block)
|
|
25
|
-
rule = self.new(*name.split(
|
|
13
|
+
rule = self.new(*name.split(".", 2))
|
|
26
14
|
|
|
27
15
|
rule.instance_eval(&block)
|
|
28
16
|
|
|
29
17
|
return rule.freeze
|
|
30
18
|
end
|
|
31
19
|
|
|
20
|
+
# Represents a single input, output, or argument parameter of a rule.
|
|
32
21
|
class Parameter
|
|
22
|
+
# Initialize the parameter.
|
|
23
|
+
# @parameter direction [Symbol] One of `:input`, `:output`, or `:argument`.
|
|
24
|
+
# @parameter name [Symbol] The parameter name.
|
|
25
|
+
# @parameter options [Hash] Options such as `:default`, `:optional`, `:implicit`, `:pattern`.
|
|
33
26
|
def initialize(direction, name, options = {}, &block)
|
|
34
27
|
@direction = direction
|
|
35
28
|
@name = name
|
|
@@ -45,14 +38,17 @@ module Build
|
|
|
45
38
|
attr :options
|
|
46
39
|
attr :dynamic
|
|
47
40
|
|
|
41
|
+
# @returns [Boolean] Whether this is an input parameter.
|
|
48
42
|
def input?
|
|
49
43
|
@direction == :input
|
|
50
44
|
end
|
|
51
45
|
|
|
46
|
+
# @returns [Boolean] Whether this is an output parameter.
|
|
52
47
|
def output?
|
|
53
48
|
@direction == :output
|
|
54
49
|
end
|
|
55
50
|
|
|
51
|
+
# @returns [Boolean] Whether this parameter has a dynamic computation block.
|
|
56
52
|
def dynamic?
|
|
57
53
|
@dynamic != nil
|
|
58
54
|
end
|
|
@@ -62,6 +58,7 @@ module Build
|
|
|
62
58
|
@options.key?(:default)
|
|
63
59
|
end
|
|
64
60
|
|
|
61
|
+
# @returns [Boolean] Whether this parameter is implicitly computed and can be overridden.
|
|
65
62
|
def implicit?
|
|
66
63
|
dynamic? and @options[:implicit]
|
|
67
64
|
end
|
|
@@ -71,6 +68,9 @@ module Build
|
|
|
71
68
|
@options[:optional] || implicit? || default?
|
|
72
69
|
end
|
|
73
70
|
|
|
71
|
+
# Check whether the given arguments satisfy this parameter.
|
|
72
|
+
# @parameter arguments [Hash] The arguments to check.
|
|
73
|
+
# @returns [Boolean] Whether this parameter is satisfied.
|
|
74
74
|
def applicable? arguments
|
|
75
75
|
value = arguments.fetch(@name) do
|
|
76
76
|
# Value couldn't be found, if it wasn't optional, this parameter didn't apply:
|
|
@@ -79,12 +79,16 @@ module Build
|
|
|
79
79
|
|
|
80
80
|
# If a pattern is provided, we must match it.
|
|
81
81
|
if pattern = @options[:pattern]
|
|
82
|
-
return Array(value).all?
|
|
82
|
+
return Array(value).all?{|item| pattern.match(item)}
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
return true
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
+
# Compute the value for this parameter given the arguments and scope.
|
|
89
|
+
# @parameter arguments [Hash] The current argument set.
|
|
90
|
+
# @parameter scope [Object] The task scope used for dynamic evaluation.
|
|
91
|
+
# @returns [Object] The computed parameter value.
|
|
88
92
|
def compute(arguments, scope)
|
|
89
93
|
if implicit?
|
|
90
94
|
# Can be replaced if supplied:
|
|
@@ -99,6 +103,7 @@ module Build
|
|
|
99
103
|
end
|
|
100
104
|
end
|
|
101
105
|
|
|
106
|
+
# @returns [Integer] A hash value for this parameter.
|
|
102
107
|
def hash
|
|
103
108
|
[self.class, @direction, @name, @options].hash
|
|
104
109
|
end
|
|
@@ -108,16 +113,20 @@ module Build
|
|
|
108
113
|
other.kind_of?(self.class) and @direction.eql?(other.direction) and @name.eql?(other.name) and @options.eql?(other.options) # and @dynamic == other.dynamic
|
|
109
114
|
end
|
|
110
115
|
|
|
116
|
+
# @returns [String] A human-readable representation of the parameter.
|
|
111
117
|
def inspect
|
|
112
118
|
"#{direction}:#{@name} (#{options.inspect})"
|
|
113
119
|
end
|
|
114
120
|
end
|
|
115
121
|
|
|
122
|
+
# Initialize a rule with a process name and type.
|
|
123
|
+
# @parameter process_name [String] The process name, e.g. `"compile"`.
|
|
124
|
+
# @parameter type [String] The file type, e.g. `"cpp"`.
|
|
116
125
|
def initialize(process_name, type)
|
|
117
126
|
@name = process_name + "." + type
|
|
118
|
-
@full_name = @name.gsub(/[^\w]/,
|
|
127
|
+
@full_name = @name.gsub(/[^\w]/, "_")
|
|
119
128
|
|
|
120
|
-
@process_name = process_name.gsub(
|
|
129
|
+
@process_name = process_name.gsub("-", "_").to_sym
|
|
121
130
|
@type = type
|
|
122
131
|
|
|
123
132
|
@apply = nil
|
|
@@ -139,6 +148,8 @@ module Build
|
|
|
139
148
|
|
|
140
149
|
attr :primary_output
|
|
141
150
|
|
|
151
|
+
# Freeze the rule and all its components.
|
|
152
|
+
# @returns [Build::Rule] The frozen rule.
|
|
142
153
|
def freeze
|
|
143
154
|
return self if frozen?
|
|
144
155
|
|
|
@@ -154,18 +165,29 @@ module Build
|
|
|
154
165
|
super
|
|
155
166
|
end
|
|
156
167
|
|
|
168
|
+
# Add an input parameter to the rule.
|
|
169
|
+
# @parameter name [Symbol] The parameter name.
|
|
170
|
+
# @parameter options [Hash] Parameter options.
|
|
157
171
|
def input(name, options = {}, &block)
|
|
158
172
|
self << Parameter.new(:input, name, options, &block)
|
|
159
173
|
end
|
|
160
174
|
|
|
175
|
+
# Add a generic argument parameter to the rule.
|
|
176
|
+
# @parameter name [Symbol] The parameter name.
|
|
177
|
+
# @parameter options [Hash] Parameter options.
|
|
161
178
|
def parameter(name, options = {}, &block)
|
|
162
179
|
self << Parameter.new(:argument, name, options, &block)
|
|
163
180
|
end
|
|
164
181
|
|
|
182
|
+
# Add an output parameter to the rule.
|
|
183
|
+
# @parameter name [Symbol] The parameter name.
|
|
184
|
+
# @parameter options [Hash] Parameter options.
|
|
165
185
|
def output(name, options = {}, &block)
|
|
166
186
|
self << Parameter.new(:output, name, options, &block)
|
|
167
187
|
end
|
|
168
188
|
|
|
189
|
+
# Append a parameter to the rule.
|
|
190
|
+
# @parameter parameter [Build::Rule::Parameter] The parameter to add.
|
|
169
191
|
def << parameter
|
|
170
192
|
@parameters << parameter
|
|
171
193
|
|
|
@@ -194,6 +216,9 @@ module Build
|
|
|
194
216
|
]
|
|
195
217
|
end
|
|
196
218
|
|
|
219
|
+
# Derive the input and output file lists from the given arguments.
|
|
220
|
+
# @parameter arguments [Hash] The argument set.
|
|
221
|
+
# @returns [Array(Build::Files::Composite, Build::Files::Composite)] Input and output file composites.
|
|
197
222
|
def files(arguments)
|
|
198
223
|
input_files = []
|
|
199
224
|
output_files = []
|
|
@@ -215,34 +240,46 @@ module Build
|
|
|
215
240
|
return Build::Files::Composite.new(input_files), Build::Files::Composite.new(output_files)
|
|
216
241
|
end
|
|
217
242
|
|
|
243
|
+
# Set the apply block that is executed when the rule is invoked.
|
|
218
244
|
def apply(&block)
|
|
219
245
|
@apply = Proc.new(&block)
|
|
220
246
|
end
|
|
221
247
|
|
|
248
|
+
# Apply the rule in the given scope with the provided arguments.
|
|
249
|
+
# @parameter scope [Object] The task scope.
|
|
250
|
+
# @parameter arguments [Hash] The normalised arguments.
|
|
222
251
|
def apply!(scope, arguments)
|
|
223
252
|
scope.instance_exec(arguments, &@apply) if @apply
|
|
224
253
|
end
|
|
225
254
|
|
|
255
|
+
# @returns [Object | Nil] The primary output value from the given arguments, if any.
|
|
226
256
|
def result(arguments)
|
|
227
257
|
if @primary_output
|
|
228
258
|
arguments[@primary_output.name]
|
|
229
259
|
end
|
|
230
260
|
end
|
|
231
261
|
|
|
262
|
+
# @returns [Integer] A hash value for this rule.
|
|
232
263
|
def hash
|
|
233
264
|
[self.class, @name, @parameters].hash
|
|
234
265
|
end
|
|
235
266
|
|
|
267
|
+
# @returns [Boolean] Whether this rule is equal to another by name and parameters.
|
|
236
268
|
def eql?(other)
|
|
237
269
|
other.kind_of?(self.class) and @name.eql?(other.name) and @parameters.eql?(other.parameters)
|
|
238
270
|
end
|
|
239
271
|
|
|
272
|
+
# @returns [String] A human-readable representation of the rule.
|
|
240
273
|
def to_s
|
|
241
274
|
"#<#{self.class} #{@name.dump}>"
|
|
242
275
|
end
|
|
243
276
|
end
|
|
244
277
|
|
|
278
|
+
# Raised when no applicable rule can be found for a given process name and arguments.
|
|
245
279
|
class NoApplicableRule < StandardError
|
|
280
|
+
# Initialize with the process name and arguments that had no matching rule.
|
|
281
|
+
# @parameter name [String] The process name that was looked up.
|
|
282
|
+
# @parameter arguments [Hash] The arguments that could not be matched.
|
|
246
283
|
def initialize(name, arguments)
|
|
247
284
|
super "No applicable rule with name #{name}.* for parameters: #{arguments.inspect}"
|
|
248
285
|
|
data/lib/build/rule_node.rb
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
20
2
|
|
|
21
|
-
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2016-2019, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require "build/graph"
|
|
22
7
|
|
|
23
8
|
module Build
|
|
9
|
+
# Represents a build graph node that applies a specific rule with given arguments.
|
|
24
10
|
class RuleNode < Graph::Node
|
|
11
|
+
# Initialize the rule node.
|
|
12
|
+
# @parameter rule [Build::Rule] The rule to apply.
|
|
13
|
+
# @parameter arguments [Hash] The normalised arguments for the rule.
|
|
25
14
|
def initialize(rule, arguments, &block)
|
|
26
15
|
@arguments = arguments
|
|
27
16
|
@rule = rule
|
|
@@ -37,6 +26,7 @@ module Build
|
|
|
37
26
|
attr :rule
|
|
38
27
|
attr :callback
|
|
39
28
|
|
|
29
|
+
# @returns [Boolean] Whether this node is equal to another.
|
|
40
30
|
def == other
|
|
41
31
|
super and
|
|
42
32
|
@arguments == other.arguments and
|
|
@@ -44,18 +34,23 @@ module Build
|
|
|
44
34
|
@callback == other.callback
|
|
45
35
|
end
|
|
46
36
|
|
|
37
|
+
# @returns [Integer] A hash value for this node.
|
|
47
38
|
def hash
|
|
48
39
|
super ^ @arguments.hash ^ @rule.hash ^ @callback.hash
|
|
49
40
|
end
|
|
50
41
|
|
|
42
|
+
# @returns [Class] The task class inherited from the parent task.
|
|
51
43
|
def task_class(parent_task)
|
|
52
44
|
parent_task.class
|
|
53
45
|
end
|
|
54
46
|
|
|
47
|
+
# @returns [String] The name of the rule.
|
|
55
48
|
def name
|
|
56
49
|
@rule.name
|
|
57
50
|
end
|
|
58
51
|
|
|
52
|
+
# Apply the rule in the given scope, then invoke the callback if present.
|
|
53
|
+
# @parameter scope [Object] The task scope.
|
|
59
54
|
def apply!(scope)
|
|
60
55
|
@rule.apply!(scope, @arguments)
|
|
61
56
|
|
|
@@ -64,6 +59,7 @@ module Build
|
|
|
64
59
|
end
|
|
65
60
|
end
|
|
66
61
|
|
|
62
|
+
# @returns [String] A human-readable representation of the rule node.
|
|
67
63
|
def inspect
|
|
68
64
|
@rule.name.inspect
|
|
69
65
|
end
|
data/lib/build/rulebook.rb
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
20
2
|
|
|
21
|
-
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2015-2019, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require_relative "rule"
|
|
22
7
|
|
|
23
8
|
module Build
|
|
9
|
+
# Represents a collection of rules, organized by process name for fast lookup.
|
|
24
10
|
class Rulebook
|
|
11
|
+
# Initialize the rulebook.
|
|
12
|
+
# @parameter name [String | Nil] An optional name for this rulebook.
|
|
25
13
|
def initialize(name = nil)
|
|
26
14
|
@name = name
|
|
27
15
|
@rules = {}
|
|
@@ -30,18 +18,27 @@ module Build
|
|
|
30
18
|
|
|
31
19
|
attr :rules
|
|
32
20
|
|
|
21
|
+
# Add a rule to this rulebook.
|
|
22
|
+
# @parameter rule [Build::Rule] The rule to add.
|
|
33
23
|
def << rule
|
|
34
24
|
@rules[rule.name] = rule
|
|
35
|
-
|
|
25
|
+
|
|
36
26
|
# A cache for fast process/file-type lookup:
|
|
37
27
|
processes = @processes[rule.process_name] ||= []
|
|
38
28
|
processes << rule
|
|
39
29
|
end
|
|
40
30
|
|
|
31
|
+
# Look up a rule by its full name.
|
|
32
|
+
# @parameter name [String] The rule name, e.g. `"compile.cpp"`.
|
|
33
|
+
# @returns [Build::Rule | Nil] The matching rule, or `nil`.
|
|
41
34
|
def [] name
|
|
42
35
|
@rules[name]
|
|
43
36
|
end
|
|
44
37
|
|
|
38
|
+
# Generate a task subclass with methods for all rules in this rulebook.
|
|
39
|
+
# @parameter superclass [Class] The base task class to inherit from.
|
|
40
|
+
# @parameter state [Hash] Additional state methods to define on the subclass.
|
|
41
|
+
# @returns [Class] The generated task subclass.
|
|
45
42
|
def with(superclass, **state)
|
|
46
43
|
task_class = Class.new(superclass)
|
|
47
44
|
|
|
@@ -54,7 +51,7 @@ module Build
|
|
|
54
51
|
@processes.each do |key, rules|
|
|
55
52
|
# Define general rules, which use rule applicability for disambiguation:
|
|
56
53
|
task_class.send(:define_method, key) do |arguments, &block|
|
|
57
|
-
rule = rules.find{|rule| rule.applicable? arguments
|
|
54
|
+
rule = rules.find{|rule| rule.applicable? arguments}
|
|
58
55
|
|
|
59
56
|
if rule
|
|
60
57
|
invoke_rule(rule, arguments, &block)
|
|
@@ -81,6 +78,9 @@ module Build
|
|
|
81
78
|
return task_class
|
|
82
79
|
end
|
|
83
80
|
|
|
81
|
+
# Build a rulebook from all rule definitions in the given environment.
|
|
82
|
+
# @parameter environment [Build::Environment] The environment to extract rules from.
|
|
83
|
+
# @returns [Build::Rulebook] The populated rulebook.
|
|
84
84
|
def self.for(environment)
|
|
85
85
|
rulebook = self.new(environment.name)
|
|
86
86
|
|
data/lib/build/task.rb
CHANGED
|
@@ -1,53 +1,44 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
20
2
|
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2016-2019, by Samuel Williams.
|
|
23
5
|
|
|
24
|
-
require
|
|
6
|
+
require "fileutils"
|
|
7
|
+
require "build/graph"
|
|
8
|
+
|
|
9
|
+
require "console/event/spawn"
|
|
25
10
|
|
|
26
11
|
module Build
|
|
27
12
|
# This task class serves as the base class for the environment specific task classes genearted when adding targets.
|
|
28
13
|
class Task < Graph::Task
|
|
29
|
-
|
|
14
|
+
# Initialize the task.
|
|
15
|
+
# @parameter walker [Build::Graph::Walker] The graph walker.
|
|
16
|
+
# @parameter node [Build::Graph::Node] The node being processed.
|
|
17
|
+
# @parameter group [Process::Group] The process group for spawning commands.
|
|
18
|
+
def initialize(walker, node, group)
|
|
30
19
|
super(walker, node)
|
|
31
20
|
|
|
32
21
|
@group = group
|
|
33
|
-
@logger = logger
|
|
34
22
|
end
|
|
35
23
|
|
|
24
|
+
# @returns [Class] The class of this task.
|
|
36
25
|
def task_class
|
|
37
26
|
self.class
|
|
38
27
|
end
|
|
39
28
|
|
|
40
29
|
attr :group
|
|
41
|
-
attr :logger
|
|
42
30
|
|
|
31
|
+
# Apply the node to this task, executing any build logic.
|
|
43
32
|
def update
|
|
44
33
|
@node.apply!(self)
|
|
45
34
|
end
|
|
46
35
|
|
|
36
|
+
# @returns [String] A string representation of the task.
|
|
47
37
|
def name
|
|
48
38
|
self.to_s
|
|
49
39
|
end
|
|
50
40
|
|
|
41
|
+
# @returns [String] The name of the underlying node.
|
|
51
42
|
def node_string
|
|
52
43
|
@node.name
|
|
53
44
|
end
|
data/lib/build/version.rb
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
20
2
|
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2015-2024, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
# @namespace
|
|
21
7
|
module Build
|
|
22
|
-
VERSION = "2.
|
|
8
|
+
VERSION = "2.7.0"
|
|
23
9
|
end
|
data/lib/build.rb
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
9
|
-
#
|
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
12
|
-
#
|
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
1
|
+
# frozen_string_literal: true
|
|
20
2
|
|
|
21
|
-
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2015, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require_relative "build/version"
|
data/license.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright, 2015-2024, by Samuel Williams.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|