lib/build/task.rb in build-2.2.0 vs lib/build/task.rb in build-2.3.0
- old
+ new
@@ -19,10 +19,12 @@
# THE SOFTWARE.
require 'fileutils'
require 'build/graph'
+require 'event/shell'
+
module Build
# This task class serves as the base class for the environment specific task classes genearted when adding targets.
class Task < Graph::Task
class CommandFailure < Graph::TransientError
def initialize(task, arguments, status)
@@ -60,11 +62,11 @@
@node.dirty?
end
def spawn(*arguments)
if wet?
- @logger&.info(:shell) {arguments}
+ @logger&.info(self) {Event::Shell.for(*arguments)}
status = @group.spawn(*arguments)
if status != 0
raise CommandFailure.new(self, arguments, status)
end
@@ -80,48 +82,48 @@
end
def touch(path)
return unless wet?
- @logger&.info(:shell) {['touch', path]}
+ @logger&.info(self) {Event::Shell.for('touch', path)}
FileUtils.touch(path)
end
def cp(source_path, destination_path)
return unless wet?
- @logger&.info(:shell) {['cp', source_path, destination_path]}
+ @logger&.info(self) {Event::Shell.for('cp', source_path, destination_path)}
FileUtils.copy(source_path, destination_path)
end
def rm(path)
return unless wet?
- @logger&.info(:shell) {['rm -rf', path]}
+ @logger&.info(self) {Event::Shell.for('rm -rf', path)}
FileUtils.rm_rf(path)
end
def mkpath(path)
return unless wet?
unless File.exist?(path)
- @logger&.info(:shell) {['mkpath', path]}
+ @logger&.info(self) {Event::Shell.for('mkpath', path)}
FileUtils.mkpath(path)
end
end
def install(source_path, destination_path)
return unless wet?
- @logger&.info(:shell) {['install', source_path, destination_path]}
+ @logger&.info(self) {Event::Shell.for('install', source_path, destination_path)}
FileUtils.install(source_path, destination_path)
end
def write(path, data, mode = "w")
return unless wet?
- @logger&.info(:shell) {["write", path, "#{data.size}bytes"]}
+ @logger&.info(self) {Event::Shell.for("write", path, "#{data.size}bytes")}
File.open(path, mode) do |file|
file.write(data)
end
end
@@ -130,16 +132,16 @@
end
def invoke_rule(rule, arguments, &block)
arguments = rule.normalize(arguments, self)
- @logger&.debug(:invoke) {"-> #{rule}(#{arguments.inspect})"}
+ @logger&.debug(self) {"-> #{rule}(#{arguments.inspect})"}
invoke(
RuleNode.new(rule, arguments, &block)
)
- @logger&.debug(:invoke) {"<- #{rule}(...) -> #{rule.result(arguments)}"}
+ @logger&.debug(self) {"<- #{rule}(...) -> #{rule.result(arguments)}"}
return rule.result(arguments)
end
end
end