build-graph 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/build-graph.gemspec +5 -3
- data/lib/build/graph/controller.rb +19 -14
- data/lib/build/graph/edge.rb +10 -5
- data/lib/build/graph/error.rb +12 -10
- data/lib/build/graph/version.rb +1 -1
- data/lib/build/graph/walker.rb +15 -13
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ac0622352764d8a850dc19bd98394fad151e1fe
|
4
|
+
data.tar.gz: 67f61c902d33f69b7ea262532dd135bd5b58fa95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acaf99a70edf2f1540e5814b70f9e879d48494a8509462a87c262d7cd1000172445bfec444bd2d6eff1bef620f5ebd6eef86470e34be9929edba4cc9a5c9fb76
|
7
|
+
data.tar.gz: e3abaa8571aac1584b6578fa42f58f1cd3fdc2f51033b080cc3e0a581e3f8327d5acf83bc34669641ca0d0dda4dbb79866400744bde03826052e8c1198e944f2
|
data/build-graph.gemspec
CHANGED
@@ -19,13 +19,15 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ["lib"]
|
22
|
-
|
22
|
+
|
23
|
+
spec.required_ruby_version = '>= 2.0'
|
24
|
+
|
23
25
|
spec.add_dependency "process-group", "~> 0.2.1"
|
24
|
-
spec.add_dependency "build-files", "~> 0.2.
|
26
|
+
spec.add_dependency "build-files", "~> 0.2.6"
|
25
27
|
|
26
28
|
spec.add_dependency "system"
|
27
29
|
spec.add_dependency "rainbow", "~> 2.0.0"
|
28
|
-
|
30
|
+
|
29
31
|
spec.add_development_dependency "bundler", "~> 1.3"
|
30
32
|
spec.add_development_dependency "rspec", "~> 3.0.0"
|
31
33
|
spec.add_development_dependency "build-makefile", "~> 0.2.0"
|
@@ -27,6 +27,7 @@ require_relative 'edge'
|
|
27
27
|
|
28
28
|
module Build
|
29
29
|
module Graph
|
30
|
+
# The top level graph controller is responsible for managing build graph state.
|
30
31
|
class Controller < Files::Monitor
|
31
32
|
def initialize
|
32
33
|
super
|
@@ -35,43 +36,46 @@ module Build
|
|
35
36
|
|
36
37
|
build_graph!
|
37
38
|
end
|
38
|
-
|
39
|
+
|
39
40
|
attr :nodes
|
40
|
-
|
41
|
-
#
|
41
|
+
|
42
|
+
# Override this to traverse the top nodes as required.
|
42
43
|
def traverse!(walker)
|
43
44
|
#Array(top).each do |node|
|
44
45
|
# node.update!(walker)
|
45
46
|
#end
|
46
47
|
end
|
47
|
-
|
48
|
+
|
49
|
+
# Walk the graph with the given callback.
|
48
50
|
def walk(&block)
|
49
51
|
Walker.new(self, &block)
|
50
52
|
end
|
51
|
-
|
53
|
+
|
54
|
+
# Build the initial graph structure.
|
52
55
|
def build_graph!
|
53
56
|
# We build the graph without doing any actual execution:
|
54
57
|
nodes = []
|
55
|
-
|
58
|
+
|
56
59
|
walker = walk do |walker, node|
|
57
60
|
nodes << node
|
58
61
|
|
59
62
|
yield walker, node
|
60
63
|
end
|
61
|
-
|
64
|
+
|
62
65
|
traverse! walker
|
63
|
-
|
66
|
+
|
64
67
|
# We should update the status of all nodes in the graph once we've traversed the graph.
|
65
68
|
nodes.each do |node|
|
66
69
|
node.update_status!
|
67
70
|
end
|
68
71
|
end
|
69
|
-
|
72
|
+
|
73
|
+
# Update the graph and print out timing information.
|
70
74
|
def update_with_log
|
71
75
|
puts Rainbow("*** Graph update traversal ***").green
|
72
|
-
|
76
|
+
|
73
77
|
start_time = Time.now
|
74
|
-
|
78
|
+
|
75
79
|
walker = update!
|
76
80
|
ensure
|
77
81
|
end_time = Time.now
|
@@ -80,14 +84,15 @@ module Build
|
|
80
84
|
$stdout.flush
|
81
85
|
$stderr.puts Rainbow("Graph Update Time: %0.3fs" % elapsed_time).magenta
|
82
86
|
end
|
83
|
-
|
87
|
+
|
88
|
+
# Update the graph.
|
84
89
|
def update!
|
85
90
|
walker = walk do |walker, node|
|
86
91
|
yield walker, node
|
87
92
|
end
|
88
|
-
|
93
|
+
|
89
94
|
traverse! walker
|
90
|
-
|
95
|
+
|
91
96
|
return walker
|
92
97
|
end
|
93
98
|
end
|
data/lib/build/graph/edge.rb
CHANGED
@@ -24,12 +24,14 @@ require 'fiber'
|
|
24
24
|
|
25
25
|
module Build
|
26
26
|
module Graph
|
27
|
-
# Represents
|
27
|
+
# Represents a set of inputs to a graph node.
|
28
28
|
class Edge
|
29
29
|
def initialize(count = 0)
|
30
30
|
@fiber = Fiber.current
|
31
|
+
|
32
|
+
# The number of inputs we are waiting for:
|
31
33
|
@count = count
|
32
|
-
|
34
|
+
|
33
35
|
@failed = []
|
34
36
|
end
|
35
37
|
|
@@ -37,7 +39,8 @@ module Build
|
|
37
39
|
|
38
40
|
attr :fiber
|
39
41
|
attr :count
|
40
|
-
|
42
|
+
|
43
|
+
# Wait until all inputs to the edge have been traversed.
|
41
44
|
def wait
|
42
45
|
if @count > 0
|
43
46
|
Fiber.yield
|
@@ -51,7 +54,8 @@ module Build
|
|
51
54
|
def failed?
|
52
55
|
@failed.size != 0
|
53
56
|
end
|
54
|
-
|
57
|
+
|
58
|
+
# Traverse the edge, mark the edge as failed if the source was also failed.
|
55
59
|
def traverse(node)
|
56
60
|
@count -= 1
|
57
61
|
|
@@ -63,7 +67,8 @@ module Build
|
|
63
67
|
@fiber.resume
|
64
68
|
end
|
65
69
|
end
|
66
|
-
|
70
|
+
|
71
|
+
# Increase the number of traversals we are waiting for.
|
67
72
|
def increment!
|
68
73
|
@count += 1
|
69
74
|
end
|
data/lib/build/graph/error.rb
CHANGED
@@ -19,18 +19,20 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
module Build
|
22
|
-
|
23
|
-
|
22
|
+
module Graph
|
23
|
+
class TransientError < StandardError
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
class CommandFailure < TransientError
|
27
|
+
def initialize(command, status)
|
28
|
+
super "Command #{command.inspect} failed with exit status #{status}!"
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
@command = command
|
31
|
+
@status = status
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
attr :command
|
35
|
+
attr :status
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
data/lib/build/graph/version.rb
CHANGED
data/lib/build/graph/walker.rb
CHANGED
@@ -29,9 +29,10 @@ module Build
|
|
29
29
|
def initialize(controller, &task)
|
30
30
|
@controller = controller
|
31
31
|
@task = task
|
32
|
-
|
32
|
+
|
33
|
+
# The number of nodes we have touched:
|
33
34
|
@count = 0
|
34
|
-
|
35
|
+
|
35
36
|
@outputs = {}
|
36
37
|
@dirty = Set.new
|
37
38
|
|
@@ -40,9 +41,9 @@ module Build
|
|
40
41
|
# For a given child, a list of any parents waiting on it.
|
41
42
|
if node.dirty?
|
42
43
|
@dirty << node
|
43
|
-
|
44
|
+
|
44
45
|
@outputs[node] = []
|
45
|
-
|
46
|
+
|
46
47
|
node.outputs.each do |output|
|
47
48
|
@outputs[output] = []
|
48
49
|
end
|
@@ -54,19 +55,21 @@ module Build
|
|
54
55
|
# Failed output paths:
|
55
56
|
@failed = Set.new
|
56
57
|
end
|
57
|
-
|
58
|
+
|
58
59
|
attr :controller
|
59
|
-
attr :
|
60
|
-
|
60
|
+
attr :task
|
61
|
+
|
62
|
+
attr :outputs
|
63
|
+
|
61
64
|
attr_accessor :count
|
62
|
-
|
63
65
|
attr :dirty
|
66
|
+
|
64
67
|
attr :parents
|
65
|
-
|
68
|
+
|
66
69
|
def task(*arguments)
|
67
70
|
@task.call(self, *arguments)
|
68
71
|
end
|
69
|
-
|
72
|
+
|
70
73
|
def wait_on_paths(paths)
|
71
74
|
edge = Edge.new
|
72
75
|
failed = false
|
@@ -155,7 +158,6 @@ module Build
|
|
155
158
|
# If all inputs were good, we can update the node.
|
156
159
|
unless any_inputs_failed?
|
157
160
|
begin
|
158
|
-
#self.instance_eval(&update)e
|
159
161
|
yield
|
160
162
|
rescue TransientError => error
|
161
163
|
$stderr.puts Rainbow("Error: #{error.inspect}").red
|
@@ -172,9 +174,9 @@ module Build
|
|
172
174
|
elsif wet?
|
173
175
|
@node.clean!
|
174
176
|
end
|
175
|
-
|
177
|
+
|
176
178
|
@walker.exit(@node)
|
177
|
-
|
179
|
+
|
178
180
|
@walker.count += 1
|
179
181
|
end
|
180
182
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build-graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: process-group
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2.
|
33
|
+
version: 0.2.6
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.2.
|
40
|
+
version: 0.2.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: system
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
167
|
requirements:
|
168
168
|
- - ">="
|
169
169
|
- !ruby/object:Gem::Version
|
170
|
-
version: '0'
|
170
|
+
version: '2.0'
|
171
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
172
|
requirements:
|
173
173
|
- - ">="
|