Class: Build::DependencyTask

Inherits:
Task
  • Object
show all
Defined in:
lib/build/dependency_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Task

#name, #node_string, #task_class

Constructor Details

#initialize(*arguments, **options) ⇒ DependencyTask

Returns a new instance of DependencyTask.



90
91
92
93
94
95
# File 'lib/build/dependency_node.rb', line 90

def initialize(*arguments, **options)
	super
	
	@environment = nil
	@tasks = []
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



100
101
102
# File 'lib/build/dependency_node.rb', line 100

def environment
  @environment
end

#groupObject (readonly)

Returns the value of attribute group.



97
98
99
# File 'lib/build/dependency_node.rb', line 97

def group
  @group
end

#loggerObject (readonly)

Returns the value of attribute logger.



98
99
100
# File 'lib/build/dependency_node.rb', line 98

def logger
  @logger
end

Instance Method Details

#updateObject



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/build/dependency_node.rb', line 102

def update
	logger.debug(self) do |buffer|
		buffer.puts "building #{@node} which #{@node.dependency}"
		@node.provisions.each do |provision|
			buffer.puts "\tbuilding #{provision.provider.name} which #{provision}"
		end
	end
	
	# Lookup what things this dependency provides:
	@node.provisions.each do |provision|
		provision.each_dependency do |nested_dependency|
			@tasks << invoke(@node.dependency_node_for(nested_dependency))
		end
	end
end

#update_outputsObject



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/build/dependency_node.rb', line 118

def update_outputs
	dependency = @node.dependency
	environments = [@node.environment]
	
	public_environments = []
	public_alias = @node.alias?
	
	@tasks.each do |task|
		if environment = task.environment
			environments << environment
			
			if public_alias || task.node.public?
				public_environments << environment
			# else
			# 	logger.debug("Skipping #{nested_dependency} in public environment.")
			end
		end
	end
	
	unless public_alias
		logger.debug(self) {"Building: #{dependency} <- #{@tasks.join}"}
		
		# environments.each do |environment|
		# 	logger.debug {"Using #{environment}"}
		# end
		
		local_environment = Build::Environment.combine(*environments)&.evaluate || Build::Environment.new
		
		# logger.debug("Local Environment: #{local_environment}")
		
		build_task = invoke(
			BuildNode.new(local_environment, dependency, @node.provisions, @node.arguments)
		)
		
		if wait_for_children?
			output_environment = build_task.output_environment
			public_environments << output_environment.dup(parent: nil, name: dependency.name)
		end
	end
	
	@environment = Build::Environment.combine(*public_environments)
	
	super
end