Class: Build::BuildTask
- Inherits:
-
Task
- Object
- Graph::Task
- Task
- Build::BuildTask
show all
- Defined in:
- lib/build/build_node.rb
Overview
This task class serves as the base class for the environment specific task classes genearted when adding targets.
Defined Under Namespace
Classes: CommandFailure
Instance Attribute Summary collapse
Attributes inherited from Task
#group, #logger
Instance Method Summary
collapse
Methods inherited from Task
#initialize, #name, #node_string, #task_class, #update
Constructor Details
This class inherits a constructor from Build::Task
Instance Attribute Details
#output_environment ⇒ Object
Returns the value of attribute output_environment.
101
102
103
|
# File 'lib/build/build_node.rb', line 101
def output_environment
@output_environment
end
|
Instance Method Details
#cp(source_path, destination_path) ⇒ Object
133
134
135
136
137
138
|
# File 'lib/build/build_node.rb', line 133
def cp(source_path, destination_path)
return unless wet?
@logger&.info(self) {Console::Shell.for('cp', source_path, destination_path)}
FileUtils.copy(source_path, destination_path)
end
|
#install(source_path, destination_path) ⇒ Object
156
157
158
159
160
161
|
# File 'lib/build/build_node.rb', line 156
def install(source_path, destination_path)
return unless wet?
@logger&.info(self) {Console::Shell.for('install', source_path, destination_path)}
FileUtils.install(source_path, destination_path)
end
|
#invoke_rule(rule, arguments, &block) ⇒ Object
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# File 'lib/build/build_node.rb', line 172
def invoke_rule(rule, arguments, &block)
arguments = rule.normalize(arguments, self)
@logger&.debug(self) {"-> #{rule}(#{arguments.inspect})"}
invoke(
RuleNode.new(rule, arguments, &block)
)
@logger&.debug(self) {"<- #{rule}(...) -> #{rule.result(arguments)}"}
return rule.result(arguments)
end
|
#mkpath(path) ⇒ Object
147
148
149
150
151
152
153
154
|
# File 'lib/build/build_node.rb', line 147
def mkpath(path)
return unless wet?
unless File.exist?(path)
@logger&.info(self) {Console::Shell.for('mkpath', path)}
FileUtils.mkpath(path)
end
end
|
#rm(path) ⇒ Object
140
141
142
143
144
145
|
# File 'lib/build/build_node.rb', line 140
def rm(path)
return unless wet?
@logger&.info(self) {Console::Shell.for('rm -rf', path)}
FileUtils.rm_rf(path)
end
|
#run!(*arguments) ⇒ Object
122
123
124
|
# File 'lib/build/build_node.rb', line 122
def run!(*arguments)
self.spawn(shell_environment, *arguments)
end
|
#shell_environment ⇒ Object
118
119
120
|
# File 'lib/build/build_node.rb', line 118
def shell_environment
@shell_environment ||= environment.flatten.export
end
|
#spawn(*arguments) ⇒ Object
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/build/build_node.rb', line 107
def spawn(*arguments)
if wet?
@logger&.info(self) {Console::Event::Spawn.for(*arguments)}
status = @group.spawn(*arguments)
if status != 0
raise CommandFailure.new(self, arguments, status)
end
end
end
|
#touch(path) ⇒ Object
126
127
128
129
130
131
|
# File 'lib/build/build_node.rb', line 126
def touch(path)
return unless wet?
@logger&.info(self) {Console::Shell.for('touch', path)}
FileUtils.touch(path)
end
|
#wet? ⇒ Boolean
103
104
105
|
# File 'lib/build/build_node.rb', line 103
def wet?
@node.dirty?
end
|
#write(path, data, mode = "w") ⇒ Object
163
164
165
166
167
168
169
170
|
# File 'lib/build/build_node.rb', line 163
def write(path, data, mode = "w")
return unless wet?
@logger&.info(self) {Console::Shell.for("write", path, "#{data.size}bytes")}
File.open(path, mode) do |file|
file.write(data)
end
end
|