build system: consolidate puts_runq and $verbose

This commit is contained in:
KonaBlend 2016-03-28 05:32:00 -04:00
parent 5c33f13935
commit ca686f2ff8
3 changed files with 29 additions and 27 deletions

View File

@ -31,6 +31,9 @@ require_relative "rake.d/config"
read_config
$verbose = ENV['V'].to_bool
$action_width = 12
$build_system_modules = {}
$have_gtest = (c(:GTEST_TYPE) == "system") || (c(:GTEST_TYPE) == "internal")
$gtest_apps = []
@ -407,7 +410,7 @@ namespace :translations do
end
end
puts " CREATE po/#{locale}.po"
puts_action "create", "po/#{locale}.po"
File.open "po/#{locale}.po", "w" do |out|
now = Time.now
email = ENV['EMAIL']
@ -584,7 +587,7 @@ EOT
task task_name do
FileList["po/*.po", "doc/man/po4a/po/*.po"].each do |name|
command = "msgfmt --statistics -o /dev/null #{name} 2>&1"
if verbose
if $verbose
runq "msgfmt", name, command, :allow_failure => true
else
puts "#{name} : " + `#{command}`.split(/\n/).first
@ -758,7 +761,7 @@ end
# Cleaning tasks
desc "Remove all compiled files"
task :clean do
puts " CLEAN"
puts_action "clean"
patterns = %w{
**/*.a
@ -789,7 +792,7 @@ task :clean do
remove_files_by_patterns patterns
if Dir.exists? $dependency_dir
puts " rm -rf #{$dependency_dir}" if verbose
puts_vaction "rm -rf", "#{$dependency_dir}"
FileUtils.rm_rf $dependency_dir
end
end

View File

@ -13,6 +13,20 @@ def puts(message)
}
end
def puts_action(action, target=nil)
msg = sprintf "%*s", $action_width, action.gsub(/ +/, '_').upcase
msg += " #{target}" if target && !target.empty?
puts msg
end
def puts_qaction(action, target=nil)
puts_action(action, target) unless $verbose
end
def puts_vaction(action, target=nil)
puts_action(action, target) if $verbose
end
def error(message)
puts message
exit 1
@ -65,27 +79,14 @@ ensure
end
end
def puts_runq action, target
return if verbose
msg = sprintf "%12s", action.gsub(/ +/, '_').upcase
msg += " #{target}" if target && !target.empty?
puts msg
end
def runq(action, target, cmdline, options = {})
verbose = ENV['V'].to_bool
puts_runq action, target
run cmdline, options.clone.merge(:dont_echo => !verbose)
puts_qaction action, target
run cmdline, options.clone.merge(:dont_echo => !$verbose)
end
def runq_git(msg, cmdline, options = {})
verbose = ENV['V'].to_bool
sub_cmd = cmdline.split(/\s+/)[0]
msg = " GIT #{sub_cmd.upcase} #{msg}"
puts msg if !verbose
$git_mutex.synchronize { run "git #{cmdline}", options.clone.merge(:dont_echo => !verbose) }
puts_qaction "git", cmdline.split(/\s+/)[0].upcase + " #{msg}"
$git_mutex.synchronize { run "git #{cmdline}", options.clone.merge(:dont_echo => !$verbose) }
end
def ensure_dir dir
@ -167,10 +168,8 @@ def install_data(destination, *files)
end
def remove_files_by_patterns patterns
verbose = ENV['V'].to_bool
patterns.collect { |pattern| FileList[pattern].to_a }.flatten.uniq.select { |file_name| File.exists? file_name }.each do |file_name|
puts " rm #{file_name}" if verbose
puts_vaction "rm", file_name
File.unlink file_name
end
end

View File

@ -372,7 +372,7 @@ PCH status: <%= c?(:USE_PRECOMPILED_HEADERS) ? "enabled" : "disabled" %>
if @verbose
verb = @config_file.exist? ? "rescan" : "scan"
else
verb = "%12s" % [(@config_file.exist? ? "rescan" : "scan").upcase]
verb = "%*s" % [$action_width, (@config_file.exist? ? "rescan" : "scan").upcase]
end
puts "#{verb} pch candidates (total=#{@users.size}, #{file_types(@users.keys)})"
@users.each_pair { |k,v| scan_user(k,v) }
@ -515,7 +515,7 @@ PCH status: <%= c?(:USE_PRECOMPILED_HEADERS) ? "enabled" : "disabled" %>
h = options.fetch(:htrace, nil) ? 't' : '-'
u = options.fetch(:user, nil) ? 'u' : '-'
p = options.fetch(:precompile, nil) ? 'p' : '-'
puts "%c%c%c %8s %s" % [h, u, p, action.gsub(/ +/, '_').upcase, subject]
puts "%c%c%c %*s %s" % [h, u, p, $action_width - 4, action.gsub(/ +/, '_').upcase, subject]
end
htrace = options.fetch(:htrace, nil)
return execute(command, options) unless htrace
@ -616,7 +616,7 @@ PCH status: <%= c?(:USE_PRECOMPILED_HEADERS) ? "enabled" : "disabled" %>
@extension = c?(:USE_CLANG) ? ".pch" : ".gch"
# Cache global verbose flag.
@verbose = ENV['V'].to_bool
@verbose = $verbose
# Each pch file must be unambiguous for simple scanning techniques.
# The scanner needs to know the string of a pch file as it is used in