build 2.5.2 → 2.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b25bab5ea87cc44e752b996feef7556f532917a44b5c8a806abcaa835a5be46
4
- data.tar.gz: 6994d82f7e62c9b1755f4bfc1cd2e4d59cab5bb635157c289cb7f66cbf17e183
3
+ metadata.gz: 0ad08615d58ed88206dd99c9a77400daf263343bf9e00d8c724cc73050abb702
4
+ data.tar.gz: 840fde0567eccfce19a4eb3b99219f8aec9d798ca6443a67dafa825bef8c01df
5
5
  SHA512:
6
- metadata.gz: 5463598ea2a50099f0b7d5462fc231eb207009e2f75808da8dd99b976a5639ece50db6822dd36ed5c7674c4afae090098fc77a9d1e6da1c7893f77f3dae40ef2
7
- data.tar.gz: 9efd1dc567f4532209c07eac0cb59bc7513bff228078563d58a0c052c29bda3a3eee9123bcc0a698973f5404281699824064ec81efcccb9ce84f1af9ad133d7c
6
+ metadata.gz: 86a6d619396f7215c3b816a12bfbfb4c6b3aecf57b83ae48a57549cddf94b4ee77d08a41ffcc222241c981d73fb3686b56b23f818044200512c0cfbda70fb61a
7
+ data.tar.gz: 99ff73db7486709ab8691d6243bffd28342bce8de5afc0783b90c72a396fccc15bd838e4ddfd8b3d25f212abdaa111d31ae5bf54402cd4a84306e1b7ed640794
@@ -17,9 +17,9 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.required_ruby_version = '>= 2.0'
19
19
 
20
- spec.add_dependency "build-graph", "~> 2.0"
21
- spec.add_dependency "build-environment", "~> 1.3"
22
- spec.add_dependency "build-dependency", "~> 1.4"
20
+ spec.add_dependency "build-graph", "~> 2.1"
21
+ spec.add_dependency "build-environment", "~> 1.12"
22
+ spec.add_dependency "build-dependency", "~> 1.5"
23
23
  spec.add_dependency "build-makefile", "~> 1.0"
24
24
 
25
25
  spec.add_dependency "graphviz", "~> 1.0"
@@ -25,27 +25,27 @@ require 'console/event/spawn'
25
25
 
26
26
  module Build
27
27
  class BuildNode < Graph::Node
28
- def initialize(environment, provisions, arguments)
28
+ def initialize(environment, provision, arguments)
29
29
  @environment = environment
30
- @provisions = provisions
30
+ @provision = provision
31
31
  @arguments = arguments
32
32
 
33
33
  super(Files::List::NONE, :inherit)
34
34
  end
35
35
 
36
36
  attr :environment
37
- attr :provisions
37
+ attr :provision
38
38
  attr :arguments
39
39
 
40
40
  def == other
41
41
  super and
42
42
  @environment == other.environment and
43
- @provisions == other.provisions and
43
+ @provision == other.provision and
44
44
  @arguments == other.arguments
45
45
  end
46
46
 
47
47
  def hash
48
- super ^ @environment.hash ^ @provisions.hash ^ @arguments.hash
48
+ super ^ @environment.hash ^ @provision.hash ^ @arguments.hash
49
49
  end
50
50
 
51
51
  def task_class(parent_task)
@@ -63,9 +63,7 @@ module Build
63
63
  def apply!(task)
64
64
  output_environment = self.initial_environment
65
65
 
66
- @provisions.each do |provision|
67
- output_environment.construct!(task, *@arguments, &provision.value)
68
- end
66
+ output_environment.construct!(task, *@arguments, &@provision.value)
69
67
 
70
68
  task.output_environment = output_environment
71
69
  end
@@ -66,9 +66,9 @@ module Build
66
66
  def apply!(task)
67
67
  # Go through all the dependencies in order and apply them to the build graph:
68
68
  @chain.dependencies.each do |dependency|
69
- node = DependencyNode.new(@chain, dependency, @environment, @arguments)
70
-
71
- task.invoke(node)
69
+ task.invoke(
70
+ DependencyNode.new(@chain, dependency, @environment, @arguments)
71
+ )
72
72
  end
73
73
  end
74
74
 
@@ -20,7 +20,7 @@
20
20
 
21
21
  require 'build/graph'
22
22
 
23
- require_relative 'build_node'
23
+ require_relative 'provision_node'
24
24
 
25
25
  module Build
26
26
  class DependencyNode < Graph::Node
@@ -48,7 +48,7 @@ module Build
48
48
  end
49
49
 
50
50
  def hash
51
- super ^ @chain.hash ^ @environment.hash ^ @arguments.hash
51
+ super ^ @chain.hash ^ @dependency.hash ^ @environment.hash ^ @arguments.hash
52
52
  end
53
53
 
54
54
  def task_class(parent_task)
@@ -63,40 +63,18 @@ module Build
63
63
  @chain.resolved[@dependency]
64
64
  end
65
65
 
66
- def alias?
67
- @dependency.alias?
68
- end
69
-
70
66
  def public?
71
67
  @dependency.public?
72
68
  end
73
69
 
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)
70
+ def provision_node_for(provision)
71
+ ProvisionNode.new(@chain, provision, @environment, @arguments)
86
72
  end
87
-
88
- def print_dependencies(buffer = $stderr, level = 0)
89
- self.provisions.each do |provision|
90
- buffer.puts "#{" " * indentation}building #{provision.provider.name} which #{provision} which depends on:"
91
-
92
- provision.each_dependency do |nested_dependency|
93
- child = self.dependency_node_for(nested_dependency)
94
-
95
- child.print_dependencies(buffer, level + 1)
96
- end
97
- end
98
-
99
- return nil
73
+ end
74
+
75
+ module ProvisionsFailed
76
+ def self.to_s
77
+ "Failed to build all provisions!"
100
78
  end
101
79
  end
102
80
 
@@ -104,15 +82,18 @@ module Build
104
82
  def initialize(*arguments, **options)
105
83
  super
106
84
 
85
+ @provisions = []
86
+
87
+ @environments = nil
107
88
  @environment = nil
108
- @tasks = []
109
89
  end
110
90
 
111
- attr :group
112
- attr :logger
113
-
114
91
  attr :environment
115
92
 
93
+ def dependency
94
+ @node.dependency
95
+ end
96
+
116
97
  def update
117
98
  logger.debug(self) do |buffer|
118
99
  buffer.puts "building #{@node} which #{@node.dependency}"
@@ -123,55 +104,24 @@ module Build
123
104
 
124
105
  # Lookup what things this dependency provides:
125
106
  @node.provisions.each do |provision|
126
- provision.each_dependency do |nested_dependency|
127
- @tasks << invoke(@node.dependency_node_for(nested_dependency))
128
- end
129
- end
130
- end
131
-
132
- def update_outputs
133
- dependency = @node.dependency
134
- environments = [@node.environment]
135
-
136
- public_environments = []
137
- public_alias = @node.alias?
138
-
139
- @tasks.each do |task|
140
- if environment = task.environment
141
- environments << environment
142
-
143
- if public_alias || task.node.public?
144
- public_environments << environment
145
- # else
146
- # logger.debug("Skipping #{nested_dependency} in public environment.")
147
- end
148
- end
149
- end
150
-
151
- unless public_alias
152
- logger.debug(self) {"Building: #{dependency} <- #{@tasks.join}"}
153
-
154
- # environments.each do |environment|
155
- # logger.debug {"Using #{environment}"}
156
- # end
157
-
158
- local_environment = Build::Environment.combine(*environments)&.evaluate(name: dependency.name) || Build::Environment.new(name: dependency.name)
159
-
160
- # logger.debug("Local Environment: #{local_environment}")
161
-
162
- build_task = invoke(
163
- BuildNode.new(local_environment, @node.provisions, @node.arguments)
107
+ @provisions << invoke(
108
+ @node.provision_node_for(provision)
164
109
  )
165
-
166
- if wait_for_children?
167
- output_environment = build_task.output_environment
168
- public_environments << output_environment.dup(parent: nil, name: dependency.name)
169
- end
170
110
  end
171
111
 
172
- @environment = Build::Environment.combine(*public_environments)
112
+ if wait_for_children?
113
+ update_environments!
114
+ else
115
+ fail!(ProvisionsFailed)
116
+ end
117
+ end
118
+
119
+ private
120
+
121
+ def update_environments!
122
+ @environments = @provisions.flat_map(&:output_environments)
173
123
 
174
- super
124
+ @environment = Build::Environment.combine(*@environments)
175
125
  end
176
126
  end
177
127
  end
@@ -0,0 +1,146 @@
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 ProvisionNode < Graph::Node
27
+ def initialize(chain, provision, environment, arguments)
28
+ @chain = chain
29
+ @provision = provision
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 :provision
39
+ attr :environment
40
+ attr :arguments
41
+
42
+ def == other
43
+ super and
44
+ @chain == other.chain and
45
+ @provision == other.provision and
46
+ @environment == other.environment and
47
+ @arguments == other.arguments
48
+ end
49
+
50
+ def hash
51
+ super ^ @chain.hash ^ @provision.hash ^ @environment.hash ^ @arguments.hash
52
+ end
53
+
54
+ def task_class(parent_task)
55
+ ProvisionTask
56
+ end
57
+
58
+ def name
59
+ @provision.name
60
+ end
61
+
62
+ def dependency_node_for(dependency)
63
+ DependencyNode.new(@chain, dependency, @environment, @arguments)
64
+ end
65
+ end
66
+
67
+ module DependenciesFailed
68
+ def self.to_s
69
+ "Failed to build all dependencies!"
70
+ end
71
+ end
72
+
73
+ class ProvisionTask < Task
74
+ def initialize(*arguments, **options)
75
+ super
76
+
77
+ @dependencies = []
78
+
79
+ @environments = []
80
+ @public_environments = []
81
+
82
+ @build_task = nil
83
+ end
84
+
85
+ attr :environments
86
+ attr :public_environments
87
+
88
+ attr :build_task
89
+
90
+ def provision
91
+ @node.provision
92
+ end
93
+
94
+ def update
95
+ provision.each_dependency do |dependency|
96
+ @dependencies << invoke(@node.dependency_node_for(dependency))
97
+ end
98
+
99
+ if wait_for_children?
100
+ update_environments!
101
+ else
102
+ fail!(DependenciesFailed)
103
+ end
104
+ end
105
+
106
+ def local_environment
107
+ Build::Environment.combine(@node.environment, *@environments)&.evaluate(name: @node.name).freeze
108
+ end
109
+
110
+ def output_environment
111
+ if @build_task
112
+ @build_task.output_environment.dup(parent: nil)
113
+ end
114
+ end
115
+
116
+ def output_environments
117
+ environments = @public_environments.dup
118
+
119
+ if environment = self.output_environment
120
+ environments << environment
121
+ end
122
+
123
+ return environments
124
+ end
125
+
126
+ private
127
+
128
+ def update_environments!
129
+ @dependencies.each do |task|
130
+ if environment = task.environment
131
+ @environments << environment
132
+
133
+ if task.dependency.public? || @node.provision.alias?
134
+ @public_environments << environment
135
+ end
136
+ end
137
+ end
138
+
139
+ unless @node.provision.alias?
140
+ @build_task = invoke(
141
+ BuildNode.new(local_environment, @node.provision, @node.arguments)
142
+ )
143
+ end
144
+ end
145
+ end
146
+ end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Build
22
- VERSION = "2.5.2"
22
+ VERSION = "2.6.0"
23
23
  end
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.5.2
4
+ version: 2.6.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-10-06 00:00:00.000000000 Z
11
+ date: 2019-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: build-graph
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '2.1'
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: '2.0'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: build-environment
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '1.12'
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: '1.3'
40
+ version: '1.12'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: build-dependency
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.4'
47
+ version: '1.5'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.4'
54
+ version: '1.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: build-makefile
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -172,6 +172,7 @@ files:
172
172
  - lib/build/dependency_node.rb
173
173
  - lib/build/graphviz.rb
174
174
  - lib/build/name.rb
175
+ - lib/build/provision_node.rb
175
176
  - lib/build/rule.rb
176
177
  - lib/build/rule_node.rb
177
178
  - lib/build/rulebook.rb