class Build::BuildTask
This task class serves as the base class for the environment specific task classes genearted when adding targets.
Attributes
output_environment[RW]
Public Instance Methods
cp(source_path, destination_path)
click to toggle source
# File lib/build/build_node.rb, line 128 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)
click to toggle source
# File lib/build/build_node.rb, line 151 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)
click to toggle source
# File lib/build/build_node.rb, line 167 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)
click to toggle source
# File lib/build/build_node.rb, line 142 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)
click to toggle source
# File lib/build/build_node.rb, line 135 def rm(path) return unless wet? @logger&.info(self) {Console::Shell.for('rm -rf', path)} FileUtils.rm_rf(path) end
run!(*arguments)
click to toggle source
# File lib/build/build_node.rb, line 117 def run!(*arguments) self.spawn(shell_environment, *arguments) end
shell_environment()
click to toggle source
# File lib/build/build_node.rb, line 113 def shell_environment @shell_environment ||= environment.flatten.export end
spawn(*arguments)
click to toggle source
# File lib/build/build_node.rb, line 102 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)
click to toggle source
# File lib/build/build_node.rb, line 121 def touch(path) return unless wet? @logger&.info(self) {Console::Shell.for('touch', path)} FileUtils.touch(path) end
wet?()
click to toggle source
# File lib/build/build_node.rb, line 98 def wet? @node.dirty? end
write(path, data, mode = "w")
click to toggle source
# File lib/build/build_node.rb, line 158 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