update output coloring with highlighting for target and source filenames - close #104

This commit is contained in:
josh committed 2019-04-30 21:05:44 -04:00
1 parent a4fead7dc6
commit cd1c54bf0d
14 files changed
+83 -49

No files matched your search

+3 -1
View File
@@ -171,7 +171,9 @@ module Rscons
cache = Cache.instance
build_dir = cache["configuration_data"]["build_dir"]
clean
FileUtils.rm_rf(build_dir)
if build_dir
FileUtils.rm_rf(build_dir)
end
cache.clear
0
end
+1 -1
View File
@@ -26,7 +26,7 @@ module Rscons
raise "Unknown source file #{@sources.first.inspect} for CFile builder"
end
command = @env.build_command("${#{cmd}_CMD}", @vars)
standard_command("#{message} from #{Util.short_format_paths(@sources)} => #{@target}", command)
standard_command("#{message} from <source>#{Util.short_format_paths(@sources)}<reset> => <target>#{@target}<reset>", command)
end
end
+1 -1
View File
@@ -23,7 +23,7 @@ module Rscons
if @vars["CMD_STDOUT"]
options[:stdout] = @env.expand_varref("${CMD_STDOUT}", @vars)
end
standard_command("#{cmd_desc} => #{@target}", command, options)
standard_command("#{cmd_desc} <target>#{@target}<reset>", command, options)
end
end
+1 -1
View File
@@ -52,7 +52,7 @@ module Rscons
# Check the cache and copy if necessary
unless @cache.up_to_date?(dest, :Copy, [src], @env)
unless printed_message
message = "#{name} #{Util.short_format_paths(@sources)} => #{@target}"
message = "#{name} <source>#{Util.short_format_paths(@sources)}<reset> => <target>#{@target}<reset>"
print_run_message(message, nil)
printed_message = true
end
+1 -1
View File
@@ -30,7 +30,7 @@ module Rscons
Ansi.write($stderr, :red, "Error: `#{@target}' already exists and is not a directory", :reset, "\n")
false
else
print_run_message("Creating directory => #{@target}", nil)
print_run_message("Creating directory <target>#{@target}<reset>", nil)
@cache.mkdir_p(@target, install: @install_builder)
true
end
+1 -1
View File
@@ -10,7 +10,7 @@ module Rscons
else
@vars["_SOURCES"] = @sources
command = @env.build_command("${DISASM_CMD}", @vars)
standard_command("Disassembling #{Util.short_format_paths(@sources)} => #{target}", command, stdout: @target)
standard_command("Disassembling <source>#{Util.short_format_paths(@sources)}<reset> => <target>#{target}<reset>", command, stdout: @target)
end
end
+1 -1
View File
@@ -20,7 +20,7 @@ module Rscons
@vars["_TARGET"] = @target
@vars["_SOURCES"] = @objects
command = @env.build_command("${ARCMD}", @vars)
standard_command("Building static library archive => #{@target}", command, sources: @objects)
standard_command("Building static library archive <target>#{@target}<reset>", command, sources: @objects)
end
end
+2 -2
View File
@@ -83,9 +83,9 @@ module Rscons
command = @env.build_command(@command_template, @vars)
@env.produces(@target, @vars["_DEPFILE"])
if @vars[:direct]
message = "#{@short_description}/Linking #{Util.short_format_paths(@sources)} => #{@target}"
message = "#{@short_description}/Linking <source>#{Util.short_format_paths(@sources)}<reset> => <target>#{@target}<reset>"
else
message = "#{@short_description} #{Util.short_format_paths(@sources)}"
message = "#{@short_description} <source>#{Util.short_format_paths(@sources)}<reset>"
end
standard_command(message, command)
end
+1 -1
View File
@@ -27,7 +27,7 @@ module Rscons
@vars["_SOURCES"] = @objects
@vars["#{ld_var}"] = ld
command = @env.build_command("${#{ld_var}CMD}", @vars)
standard_command("Linking => #{@target}", command, sources: @objects)
standard_command("Linking <target>#{@target}<reset>", command, sources: @objects)
end
end
+1 -1
View File
@@ -26,7 +26,7 @@ module Rscons
@vars["_DEPFILE"] = Rscons.set_suffix(target, env.expand_varref("${DEPFILESUFFIX}", vars))
command = @env.build_command("${CPP_CMD}", @vars)
@env.produces(@target, @vars["_DEPFILE"])
standard_command("Preprocessing #{Util.short_format_paths(@sources)} => #{@target}", command)
standard_command("Preprocessing <source>#{Util.short_format_paths(@sources)}<reset> => <target>#{@target}<reset>", command)
end
end
+6 -4
View File
@@ -526,10 +526,12 @@ module Rscons
when :short
message = short_description if short_description
end
total_build_steps = Rscons.application.get_total_build_steps.to_s
this_build_step = sprintf("%#{total_build_steps.size}d", builder.build_step)
progress = "[#{this_build_step}/#{total_build_steps}]"
Ansi.write($stdout, :cyan, "#{progress} #{message}", :reset, "\n") if message
if message
total_build_steps = Rscons.application.get_total_build_steps.to_s
this_build_step = sprintf("%#{total_build_steps.size}d", builder.build_step)
progress = "[#{this_build_step}/#{total_build_steps}]"
Ansi.write($stdout, *Util.colorize_markup("#{progress} #{message}"), "\n")
end
end
# Get the Builder for a target.
+24
View File
@@ -15,6 +15,30 @@ module Rscons
end
end
# Colorize a builder run message.
#
# @param message [String]
# Builder run message.
#
# @return [Array]
# Colorized message with color codes for {Ansi} module.
def colorize_markup(message)
if message =~ /^(.*?)(<[^>]+>)(.*)$/
prefix, code, suffix = $1, $2, $3
case code
when "<target>"
code = :magenta
when "<source>"
code = :cyan
when "<reset>"
code = :reset
end
[prefix, code, *colorize_markup(suffix)].delete_if {|v| v == ""}
else
[message]
end
end
# Return a string representation of a command.
#
# @param command [Array<String>]