build system: show start/stop messages including duration with RUN_SHOW_START_STOP

This commit is contained in:
Moritz Bunkus 2018-01-02 15:40:24 +01:00
parent 75a99fc2cc
commit 80761260be
5 changed files with 28 additions and 16 deletions

View File

@ -40,6 +40,7 @@ require_relative "rake.d/config"
$config = read_build_config
$verbose = ENV['V'].to_bool
$run_show_start_stop = !$verbose && ENV['RUN_SHOW_START_STOP'].to_bool
$build_system_modules = {}
$have_gtest = (c(:GTEST_TYPE) == "system") || (c(:GTEST_TYPE) == "internal")
$gtest_apps = []
@ -437,7 +438,7 @@ namespace :translations do
end
end
puts_action "create", "po/#{locale}.po"
puts_action "create", :target => "po/#{locale}.po"
File.open "po/#{locale}.po", "w" do |out|
now = Time.now
email = ENV['EMAIL']
@ -881,7 +882,7 @@ task :clean do
remove_files_by_patterns patterns
if Dir.exists? $dependency_dir
puts_vaction "rm -rf", "#{$dependency_dir}"
puts_vaction "rm -rf", :target => "#{$dependency_dir}"
FileUtils.rm_rf $dependency_dir
end
end

View File

@ -14,18 +14,19 @@ def puts(message)
}
end
def puts_action(action, target=nil)
def puts_action(action, options = {})
msg = sprintf "%*s", $action_width, action.gsub(/ +/, '_').upcase
msg += " #{target}" if target && !target.empty?
msg += " #{options[:target]}" if !options[:target].blank?
msg = "#{options[:prefix]} #{msg}" if !options[:prefix].blank?
puts msg
end
def puts_qaction(action, target=nil)
puts_action(action, target) unless $verbose
def puts_qaction(action, options = {})
puts_action(action, options) unless $verbose
end
def puts_vaction(action, target=nil)
puts_action(action, target) if $verbose
def puts_vaction(action, options = {})
puts_action(action, options) if $verbose
end
def error(message)
@ -81,12 +82,22 @@ ensure
end
def runq(action, target, cmdline, options = {})
puts_qaction action, target
run cmdline, options.clone.merge(:dont_echo => !$verbose)
start = Time.now
puts_action action, :target => target, :prefix => $run_show_start_stop ? "[start ]" : nil
code = run_wrapper cmdline, options.clone.merge(:dont_echo => !$verbose)
duration = Time.now - start
if $run_show_start_stop
puts_action action, :target => target, :prefix => sprintf("[%s %02d:%02d.%03d]", code == 0 ? "done" : "fail", (duration / 60).to_i, duration.to_i % 60, (duration * 1000).to_i % 1000)
end
exit code if (code != 0) && !options[:allow_failure].to_bool
end
def runq_git(msg, cmdline, options = {})
puts_qaction "git #{cmdline.split(/\s+/)[0]}", "#{msg}"
puts_qaction "git #{cmdline.split(/\s+/)[0]}", :target => "#{msg}"
$git_mutex.synchronize { run "git #{cmdline}", options.clone.merge(:dont_echo => !$verbose) }
end
@ -170,7 +181,7 @@ end
def remove_files_by_patterns patterns
patterns.collect { |pattern| FileList[pattern].to_a }.flatten.uniq.select { |file_name| File.exists? file_name }.each do |file_name|
puts_vaction "rm", file_name
puts_vaction "rm", :target => file_name
File.unlink file_name
end
end

View File

@ -25,7 +25,7 @@ module Mtx::Installer
end
def self.update_one_translation_file file_name, english
puts_qaction "nsh_update", file_name
puts_qaction "nsh_update", :target => file_name
language = self.read_translation_file file_name
translation_lines = []

View File

@ -152,7 +152,7 @@ def write_po file_name, items
end
def normalize_po file
puts_action "NORMALIZE-PO", file
puts_action "NORMALIZE-PO", :target => file
write_po file, read_po(file)
end
@ -219,7 +219,7 @@ def transifex_pull_and_merge resource, language
runq "tx pull", po_file, "tx pull -f -r mkvtoolnix.#{resource} -l #{language} > /dev/null"
puts_qaction "merge", po_file
puts_qaction "merge", :target => po_file
transifex_items = read_po(po_file)
merged_items = merge_po orig_items, transifex_items

View File

@ -44,7 +44,7 @@ module AddPo
orig_items = read_po target
puts_qaction "merge", target
puts_qaction "merge", :target => target
updated_items = read_po file_name
merged_items = merge_po orig_items, updated_items, :headers_to_update => %w{Project-Id-Version}