build 2.4.5 → 2.5.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
- data/.gitignore +0 -1
- data/build.gemspec +1 -1
- data/lib/build/build_node.rb +186 -0
- data/lib/build/chain_node.rb +30 -63
- data/lib/build/controller.rb +2 -2
- data/lib/build/dependency_node.rb +163 -0
- data/lib/build/rule_node.rb +16 -1
- data/lib/build/task.rb +10 -107
- data/lib/build/version.rb +1 -1
- data/spec/build/controller_spec.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 187be1c77bccf22983d403cf42a37354afe68a658fd1c7114f0f7db9202e898c
|
4
|
+
data.tar.gz: 755feeca9f4d0b9a68c9ad66cb22dabca4e85e68c55323fa0057a667181c9c17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f5949efc5f2a163c323c3b396c14b07af51dd7504484c01e7a09c3450a4312fd3011f2c5c189dfa800accfb1be6abb67ea68f74063d190226e97b1570077dc3
|
7
|
+
data.tar.gz: f19cca0cf2eeabadfba042ed91dd2498c508331b2ef3d391c27d46748c3aa92d93f6aa491bab4b96b957146facaeb2e0683c4311b8dba12ecb8a1d4ab789b69e
|
data/.gitignore
CHANGED
data/build.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
|
18
18
|
spec.required_ruby_version = '>= 2.0'
|
19
19
|
|
20
|
-
spec.add_dependency "build-graph", "~>
|
20
|
+
spec.add_dependency "build-graph", "~> 2.0"
|
21
21
|
spec.add_dependency "build-environment", "~> 1.3"
|
22
22
|
spec.add_dependency "build-dependency", "~> 1.4"
|
23
23
|
spec.add_dependency "build-makefile", "~> 1.0"
|
@@ -0,0 +1,186 @@
|
|
1
|
+
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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.
|
20
|
+
|
21
|
+
require 'fileutils'
|
22
|
+
require 'build/graph'
|
23
|
+
|
24
|
+
require 'console/event/spawn'
|
25
|
+
|
26
|
+
module Build
|
27
|
+
class BuildNode < Graph::Node
|
28
|
+
def initialize(environment, dependency, provisions, arguments)
|
29
|
+
@environment = environment
|
30
|
+
@dependency = dependency
|
31
|
+
@provisions = provisions
|
32
|
+
@arguments = arguments
|
33
|
+
|
34
|
+
super(Files::List::NONE, :inherit)
|
35
|
+
end
|
36
|
+
|
37
|
+
attr :environment
|
38
|
+
attr :dependency
|
39
|
+
attr :provisions
|
40
|
+
attr :arguments
|
41
|
+
|
42
|
+
def == other
|
43
|
+
super and
|
44
|
+
@environment == other.environment and
|
45
|
+
@dependency == other.dependency and
|
46
|
+
@provisions == other.provisions and
|
47
|
+
@arguments == other.arguments
|
48
|
+
end
|
49
|
+
|
50
|
+
def hash
|
51
|
+
super ^ @environment.hash ^ @dependency.hash ^ @provisions.hash ^ @arguments.hash
|
52
|
+
end
|
53
|
+
|
54
|
+
def task_class(parent_task)
|
55
|
+
task_class = Rulebook.for(@environment).with(BuildTask, environment: @environment)
|
56
|
+
end
|
57
|
+
|
58
|
+
def initial_environment
|
59
|
+
Build::Environment.new(@environment, name: @dependency.name)
|
60
|
+
end
|
61
|
+
|
62
|
+
def name
|
63
|
+
@dependency.name
|
64
|
+
end
|
65
|
+
|
66
|
+
def apply!(task)
|
67
|
+
output_environment = self.initial_environment
|
68
|
+
|
69
|
+
@provisions.each do |provision|
|
70
|
+
output_environment.construct!(task, *@arguments, &provision.value)
|
71
|
+
end
|
72
|
+
|
73
|
+
task.output_environment = output_environment
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# This task class serves as the base class for the environment specific task classes genearted when adding targets.
|
78
|
+
class BuildTask < Task
|
79
|
+
class CommandFailure < Graph::TransientError
|
80
|
+
def initialize(task, arguments, status)
|
81
|
+
@task = task
|
82
|
+
@arguments = arguments
|
83
|
+
@status = status
|
84
|
+
|
85
|
+
super "#{File.basename(executable_name).inspect} exited with status #{@status.to_i}"
|
86
|
+
end
|
87
|
+
|
88
|
+
def executable_name
|
89
|
+
if @arguments[0].kind_of? Hash
|
90
|
+
@arguments[1]
|
91
|
+
else
|
92
|
+
@arguments[0]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
attr :task
|
97
|
+
attr :arguments
|
98
|
+
attr :status
|
99
|
+
end
|
100
|
+
|
101
|
+
attr_accessor :output_environment
|
102
|
+
|
103
|
+
def wet?
|
104
|
+
@node.dirty?
|
105
|
+
end
|
106
|
+
|
107
|
+
def spawn(*arguments)
|
108
|
+
if wet?
|
109
|
+
@logger&.info(self) {Console::Event::Spawn.for(*arguments)}
|
110
|
+
status = @group.spawn(*arguments)
|
111
|
+
|
112
|
+
if status != 0
|
113
|
+
raise CommandFailure.new(self, arguments, status)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def shell_environment
|
119
|
+
@shell_environment ||= environment.flatten.export
|
120
|
+
end
|
121
|
+
|
122
|
+
def run!(*arguments)
|
123
|
+
self.spawn(shell_environment, *arguments)
|
124
|
+
end
|
125
|
+
|
126
|
+
def touch(path)
|
127
|
+
return unless wet?
|
128
|
+
|
129
|
+
@logger&.info(self) {Console::Shell.for('touch', path)}
|
130
|
+
FileUtils.touch(path)
|
131
|
+
end
|
132
|
+
|
133
|
+
def cp(source_path, destination_path)
|
134
|
+
return unless wet?
|
135
|
+
|
136
|
+
@logger&.info(self) {Console::Shell.for('cp', source_path, destination_path)}
|
137
|
+
FileUtils.copy(source_path, destination_path)
|
138
|
+
end
|
139
|
+
|
140
|
+
def rm(path)
|
141
|
+
return unless wet?
|
142
|
+
|
143
|
+
@logger&.info(self) {Console::Shell.for('rm -rf', path)}
|
144
|
+
FileUtils.rm_rf(path)
|
145
|
+
end
|
146
|
+
|
147
|
+
def mkpath(path)
|
148
|
+
return unless wet?
|
149
|
+
|
150
|
+
unless File.exist?(path)
|
151
|
+
@logger&.info(self) {Console::Shell.for('mkpath', path)}
|
152
|
+
FileUtils.mkpath(path)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def install(source_path, destination_path)
|
157
|
+
return unless wet?
|
158
|
+
|
159
|
+
@logger&.info(self) {Console::Shell.for('install', source_path, destination_path)}
|
160
|
+
FileUtils.install(source_path, destination_path)
|
161
|
+
end
|
162
|
+
|
163
|
+
def write(path, data, mode = "w")
|
164
|
+
return unless wet?
|
165
|
+
|
166
|
+
@logger&.info(self) {Console::Shell.for("write", path, "#{data.size}bytes")}
|
167
|
+
File.open(path, mode) do |file|
|
168
|
+
file.write(data)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def invoke_rule(rule, arguments, &block)
|
173
|
+
arguments = rule.normalize(arguments, self)
|
174
|
+
|
175
|
+
@logger&.debug(self) {"-> #{rule}(#{arguments.inspect})"}
|
176
|
+
|
177
|
+
invoke(
|
178
|
+
RuleNode.new(rule, arguments, &block)
|
179
|
+
)
|
180
|
+
|
181
|
+
@logger&.debug(self) {"<- #{rule}(...) -> #{rule.result(arguments)}"}
|
182
|
+
|
183
|
+
return rule.result(arguments)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
data/lib/build/chain_node.rb
CHANGED
@@ -22,91 +22,58 @@ require 'build/files'
|
|
22
22
|
require 'build/graph'
|
23
23
|
|
24
24
|
require_relative 'task'
|
25
|
+
require_relative 'dependency_node'
|
25
26
|
|
26
27
|
module Build
|
28
|
+
# Responsible for processing a chain into a series of dependency nodes.
|
27
29
|
class ChainNode < Graph::Node
|
30
|
+
# @param chain [Chain] the chain to build.
|
31
|
+
# @param arguments [Array] the arguments to pass to the output environment constructor.
|
32
|
+
# @param anvironment [Build::Environment] the root environment to prepend into the chain.
|
28
33
|
def initialize(chain, arguments, environment)
|
29
34
|
@chain = chain
|
30
35
|
@arguments = arguments
|
31
36
|
@environment = environment
|
32
37
|
|
33
38
|
# Wait here, for all dependent targets, to be done:
|
34
|
-
super(Files::List::NONE, :inherit
|
39
|
+
super(Files::List::NONE, :inherit)
|
35
40
|
end
|
36
41
|
|
37
|
-
|
38
|
-
|
42
|
+
attr :chain
|
43
|
+
attr :arguments
|
44
|
+
attr :environment
|
45
|
+
|
46
|
+
def == other
|
47
|
+
super and
|
48
|
+
@chain == other.chain and
|
49
|
+
@arguments == other.arguments and
|
50
|
+
@environment == other.environment
|
39
51
|
end
|
40
52
|
|
41
|
-
def
|
53
|
+
def hash
|
54
|
+
super ^ @chain.hash ^ @arguments.hash ^ @environment.hash
|
55
|
+
end
|
56
|
+
|
57
|
+
def task_class(parent_task)
|
42
58
|
Task
|
43
59
|
end
|
44
60
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
# logger.debug {"Traversing: #{dependency}..."}
|
49
|
-
|
50
|
-
environments = [@environment]
|
51
|
-
public_environments = []
|
52
|
-
provisions = @chain.resolved[dependency]
|
53
|
-
public_alias = dependency.alias?
|
54
|
-
|
55
|
-
provisions.each do |provision|
|
56
|
-
provision.each_dependency do |nested_dependency|
|
57
|
-
if environment = apply_dependency(scope, nested_dependency)
|
58
|
-
# logger.debug("Evaluating #{nested_dependency} -> #{provision} generated: #{environment}")
|
59
|
-
|
60
|
-
environments << environment
|
61
|
-
|
62
|
-
if public_alias || nested_dependency.public?
|
63
|
-
public_environments << environment
|
64
|
-
# else
|
65
|
-
# logger.debug("Skipping #{nested_dependency} in public environment.")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
unless dependency.alias?
|
72
|
-
logger.debug {"Building: #{dependency}"}
|
73
|
-
|
74
|
-
# environments.each do |environment|
|
75
|
-
# logger.debug {"Using #{environment}"}
|
76
|
-
# end
|
77
|
-
|
78
|
-
local_environment = Build::Environment.combine(*environments)&.evaluate || Build::Environment.new
|
79
|
-
|
80
|
-
# logger.debug("Local Environment: #{local_environment}")
|
81
|
-
|
82
|
-
task_class = Rulebook.for(local_environment).with(Task, environment: local_environment)
|
83
|
-
task = task_class.new(scope.walker, self, scope.group, logger: scope.logger)
|
84
|
-
|
85
|
-
output_environment = nil
|
86
|
-
|
87
|
-
task.visit do
|
88
|
-
output_environment = Build::Environment.new(local_environment, name: dependency.name)
|
89
|
-
|
90
|
-
provisions.each do |provision|
|
91
|
-
# When executing the environment build steps, we create new build nodes. But those build nodes are not capturing the right task class.
|
92
|
-
output_environment.construct!(task, *@arguments, &provision.value)
|
93
|
-
end
|
94
|
-
|
95
|
-
public_environments << output_environment.dup(parent: nil, name: dependency.name)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
return Build::Environment.combine(*public_environments)
|
61
|
+
def name
|
62
|
+
@environment.name
|
100
63
|
end
|
101
64
|
|
102
|
-
|
65
|
+
# This is the main entry point when invoking the node from `Build::Task`.
|
66
|
+
def apply!(task)
|
67
|
+
# Go through all the dependencies in order and apply them to the build graph:
|
103
68
|
@chain.dependencies.each do |dependency|
|
104
|
-
|
69
|
+
node = DependencyNode.new(@chain, dependency, @environment, @arguments)
|
70
|
+
|
71
|
+
task.invoke(node)
|
105
72
|
end
|
106
73
|
end
|
107
74
|
|
108
|
-
def
|
109
|
-
"#<#{self.class}>"
|
75
|
+
def inspect
|
76
|
+
"#<#{self.class} #{@environment.inspect}>"
|
110
77
|
end
|
111
78
|
end
|
112
79
|
end
|
data/lib/build/controller.rb
CHANGED
@@ -57,8 +57,8 @@ module Build
|
|
57
57
|
attr :nodes
|
58
58
|
attr :walker
|
59
59
|
|
60
|
-
|
61
|
-
task_class = parent_task
|
60
|
+
def step(walker, node, parent_task = nil)
|
61
|
+
task_class = node.task_class(parent_task) || Task
|
62
62
|
task = task_class.new(walker, node, @group, logger: @logger)
|
63
63
|
|
64
64
|
task.visit do
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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.
|
20
|
+
|
21
|
+
require 'build/graph'
|
22
|
+
|
23
|
+
require_relative 'build_node'
|
24
|
+
|
25
|
+
module Build
|
26
|
+
class DependencyNode < Graph::Node
|
27
|
+
def initialize(chain, dependency, environment, arguments)
|
28
|
+
@chain = chain
|
29
|
+
@dependency = dependency
|
30
|
+
@environment = environment
|
31
|
+
@arguments = arguments
|
32
|
+
|
33
|
+
# Wait here, for all dependent targets, to be done:
|
34
|
+
super(Files::List::NONE, :inherit)
|
35
|
+
end
|
36
|
+
|
37
|
+
attr :chain
|
38
|
+
attr :dependency
|
39
|
+
attr :environment
|
40
|
+
attr :arguments
|
41
|
+
|
42
|
+
def == other
|
43
|
+
super and
|
44
|
+
@chain == other.chain and
|
45
|
+
@dependency == other.dependency and
|
46
|
+
@environment == other.environment and
|
47
|
+
@arguments == other.arguments
|
48
|
+
end
|
49
|
+
|
50
|
+
def hash
|
51
|
+
super ^ @chain.hash ^ @environment.hash ^ @arguments.hash
|
52
|
+
end
|
53
|
+
|
54
|
+
def task_class(parent_task)
|
55
|
+
DependencyTask
|
56
|
+
end
|
57
|
+
|
58
|
+
def name
|
59
|
+
@dependency.name
|
60
|
+
end
|
61
|
+
|
62
|
+
def provisions
|
63
|
+
@chain.resolved[@dependency]
|
64
|
+
end
|
65
|
+
|
66
|
+
def alias?
|
67
|
+
@dependency.alias?
|
68
|
+
end
|
69
|
+
|
70
|
+
def public?
|
71
|
+
@dependency.public?
|
72
|
+
end
|
73
|
+
|
74
|
+
# This is the main entry point when invoking the node from `Build::Task`.
|
75
|
+
def apply!(task)
|
76
|
+
# Go through all the dependencies in order and apply them to the build graph:
|
77
|
+
@chain.dependencies.each do |dependency|
|
78
|
+
node = DependencyNode.new(@chain, dependency, @environment, @arguments)
|
79
|
+
|
80
|
+
task.invoke(node)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def dependency_node_for(dependency)
|
85
|
+
DependencyNode.new(@chain, dependency, @environment, @arguments)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
class DependencyTask < Task
|
90
|
+
def initialize(*arguments, **options)
|
91
|
+
super
|
92
|
+
|
93
|
+
@environment = nil
|
94
|
+
@tasks = []
|
95
|
+
end
|
96
|
+
|
97
|
+
attr :group
|
98
|
+
attr :logger
|
99
|
+
|
100
|
+
attr :environment
|
101
|
+
|
102
|
+
def update
|
103
|
+
logger.debug(self) do |buffer|
|
104
|
+
buffer.puts "building #{@node} which #{@node.dependency}"
|
105
|
+
@node.provisions.each do |provision|
|
106
|
+
buffer.puts "\tbuilding #{provision.provider.name} which #{provision}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Lookup what things this dependency provides:
|
111
|
+
@node.provisions.each do |provision|
|
112
|
+
provision.each_dependency do |nested_dependency|
|
113
|
+
@tasks << invoke(@node.dependency_node_for(nested_dependency))
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def update_outputs
|
119
|
+
dependency = @node.dependency
|
120
|
+
environments = [@node.environment]
|
121
|
+
|
122
|
+
public_environments = []
|
123
|
+
public_alias = @node.alias?
|
124
|
+
|
125
|
+
@tasks.each do |task|
|
126
|
+
if environment = task.environment
|
127
|
+
environments << environment
|
128
|
+
|
129
|
+
if public_alias || task.node.public?
|
130
|
+
public_environments << environment
|
131
|
+
# else
|
132
|
+
# logger.debug("Skipping #{nested_dependency} in public environment.")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
unless public_alias
|
138
|
+
logger.debug(self) {"Building: #{dependency} <- #{@tasks.join}"}
|
139
|
+
|
140
|
+
# environments.each do |environment|
|
141
|
+
# logger.debug {"Using #{environment}"}
|
142
|
+
# end
|
143
|
+
|
144
|
+
local_environment = Build::Environment.combine(*environments)&.evaluate || Build::Environment.new
|
145
|
+
|
146
|
+
# logger.debug("Local Environment: #{local_environment}")
|
147
|
+
|
148
|
+
build_task = invoke(
|
149
|
+
BuildNode.new(local_environment, dependency, @node.provisions, @node.arguments)
|
150
|
+
)
|
151
|
+
|
152
|
+
if wait_for_children?
|
153
|
+
output_environment = build_task.output_environment
|
154
|
+
public_environments << output_environment.dup(parent: nil, name: dependency.name)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
@environment = Build::Environment.combine(*public_environments)
|
159
|
+
|
160
|
+
super
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
data/lib/build/rule_node.rb
CHANGED
@@ -30,13 +30,28 @@ module Build
|
|
30
30
|
|
31
31
|
inputs, outputs = @rule.files(@arguments)
|
32
32
|
|
33
|
-
super(inputs, outputs
|
33
|
+
super(inputs, outputs)
|
34
34
|
end
|
35
35
|
|
36
36
|
attr :arguments
|
37
37
|
attr :rule
|
38
38
|
attr :callback
|
39
39
|
|
40
|
+
def == other
|
41
|
+
super and
|
42
|
+
@arguments == other.arguments and
|
43
|
+
@rule == other.rule and
|
44
|
+
@callback == other.callback
|
45
|
+
end
|
46
|
+
|
47
|
+
def hash
|
48
|
+
super ^ @arguments.hash ^ @rule.hash ^ @callback.hash
|
49
|
+
end
|
50
|
+
|
51
|
+
def task_class(parent_task)
|
52
|
+
parent_task.class
|
53
|
+
end
|
54
|
+
|
40
55
|
def name
|
41
56
|
@rule.name
|
42
57
|
end
|
data/lib/build/task.rb
CHANGED
@@ -26,127 +26,30 @@ require 'console/event/spawn'
|
|
26
26
|
module Build
|
27
27
|
# This task class serves as the base class for the environment specific task classes genearted when adding targets.
|
28
28
|
class Task < Graph::Task
|
29
|
-
|
30
|
-
|
31
|
-
@task = task
|
32
|
-
@arguments = arguments
|
33
|
-
@status = status
|
34
|
-
|
35
|
-
super "#{File.basename(executable_name).inspect} exited with status #{@status.to_i}"
|
36
|
-
end
|
37
|
-
|
38
|
-
def executable_name
|
39
|
-
if @arguments[0].kind_of? Hash
|
40
|
-
@arguments[1]
|
41
|
-
else
|
42
|
-
@arguments[0]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
attr :task
|
47
|
-
attr :arguments
|
48
|
-
attr :status
|
49
|
-
end
|
50
|
-
|
51
|
-
def initialize(walker, node, group, logger: nil)
|
52
|
-
super(walker, node)
|
29
|
+
def initialize(walker, node, group, logger: nil, **options)
|
30
|
+
super(walker, node, **options)
|
53
31
|
|
54
32
|
@group = group
|
55
33
|
@logger = logger
|
56
34
|
end
|
57
35
|
|
58
|
-
def
|
59
|
-
|
36
|
+
def task_class
|
37
|
+
self.class
|
60
38
|
end
|
61
39
|
|
62
40
|
attr :group
|
63
41
|
attr :logger
|
64
42
|
|
65
|
-
def wet?
|
66
|
-
@node.dirty?
|
67
|
-
end
|
68
|
-
|
69
|
-
def spawn(*arguments)
|
70
|
-
if wet?
|
71
|
-
@logger&.info(self) {Console::Event::Spawn.for(*arguments)}
|
72
|
-
status = @group.spawn(*arguments)
|
73
|
-
|
74
|
-
if status != 0
|
75
|
-
raise CommandFailure.new(self, arguments, status)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def shell_environment
|
81
|
-
@shell_environment ||= environment.flatten.export
|
82
|
-
end
|
83
|
-
|
84
|
-
def run!(*arguments)
|
85
|
-
self.spawn(shell_environment, *arguments)
|
86
|
-
end
|
87
|
-
|
88
|
-
def touch(path)
|
89
|
-
return unless wet?
|
90
|
-
|
91
|
-
@logger&.info(self) {Console::Shell.for('touch', path)}
|
92
|
-
FileUtils.touch(path)
|
93
|
-
end
|
94
|
-
|
95
|
-
def cp(source_path, destination_path)
|
96
|
-
return unless wet?
|
97
|
-
|
98
|
-
@logger&.info(self) {Console::Shell.for('cp', source_path, destination_path)}
|
99
|
-
FileUtils.copy(source_path, destination_path)
|
100
|
-
end
|
101
|
-
|
102
|
-
def rm(path)
|
103
|
-
return unless wet?
|
104
|
-
|
105
|
-
@logger&.info(self) {Console::Shell.for('rm -rf', path)}
|
106
|
-
FileUtils.rm_rf(path)
|
107
|
-
end
|
108
|
-
|
109
|
-
def mkpath(path)
|
110
|
-
return unless wet?
|
111
|
-
|
112
|
-
unless File.exist?(path)
|
113
|
-
@logger&.info(self) {Console::Shell.for('mkpath', path)}
|
114
|
-
FileUtils.mkpath(path)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def install(source_path, destination_path)
|
119
|
-
return unless wet?
|
120
|
-
|
121
|
-
@logger&.info(self) {Console::Shell.for('install', source_path, destination_path)}
|
122
|
-
FileUtils.install(source_path, destination_path)
|
123
|
-
end
|
124
|
-
|
125
|
-
def write(path, data, mode = "w")
|
126
|
-
return unless wet?
|
127
|
-
|
128
|
-
@logger&.info(self) {Console::Shell.for("write", path, "#{data.size}bytes")}
|
129
|
-
File.open(path, mode) do |file|
|
130
|
-
file.write(data)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
43
|
def update
|
135
44
|
@node.apply!(self)
|
136
45
|
end
|
137
46
|
|
138
|
-
def
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
RuleNode.new(rule, arguments, &block)
|
145
|
-
)
|
146
|
-
|
147
|
-
@logger&.debug(self) {"<- #{rule}(...) -> #{rule.result(arguments)}"}
|
148
|
-
|
149
|
-
return rule.result(arguments)
|
47
|
+
def name
|
48
|
+
self.to_s
|
49
|
+
end
|
50
|
+
|
51
|
+
def node_string
|
52
|
+
@node.name
|
150
53
|
end
|
151
54
|
end
|
152
55
|
end
|
data/lib/build/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: build-graph
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: build-environment
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,8 +166,10 @@ files:
|
|
166
166
|
- Rakefile
|
167
167
|
- build.gemspec
|
168
168
|
- lib/build.rb
|
169
|
+
- lib/build/build_node.rb
|
169
170
|
- lib/build/chain_node.rb
|
170
171
|
- lib/build/controller.rb
|
172
|
+
- lib/build/dependency_node.rb
|
171
173
|
- lib/build/graphviz.rb
|
172
174
|
- lib/build/name.rb
|
173
175
|
- lib/build/rule.rb
|