scons: Add a mechanism to accumulate warnings to reprint at the end.

When building gem5, it's possible for warnings printed early in the
build to be quickly wisked away in a see of compile lines, never to be
seen again (or driven off the end of the scrollback buffer).

To avoid those messages getting lost or ignored, this change adds a
mechanism to aggregate them into a list so that they can be summarized
at the end of the build, successful or not.

Change-Id: Ie13320717698fcbcd3a8f8d1c062467e8d6d2914
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27129
Tested-by: Gem5 Cloud Project GCB service account <345032938727@cloudbuild.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabeblack@google.com>
This commit is contained in:
Gabe Black
2020-03-26 04:41:39 -07:00
committed by Gabe Black
parent 47579e693b
commit 3d572a49b8

View File

@@ -169,12 +169,25 @@ def print_message(prefix, color, message, **kwargs):
# Finally add the prefix and padding on extra lines, and glue it all back
# together.
message = prefix + ('\n' + padding).join(wrapped_lines)
# Print the message in bold in the requested color.
print(color + termcap.Bold + message + termcap.Normal, **kwargs)
# Add in terminal escape sequences.
message = color + termcap.Bold + message + termcap.Normal
# Actually print the message.
print(message, **kwargs)
return message
all_warnings = []
def summarize_warnings():
if not all_warnings:
return
print(termcap.Yellow + termcap.Bold +
'*** Summary of Warnings ***' +
termcap.Normal)
list(map(print, all_warnings))
def warning(*args, **kwargs):
message = ' '.join(args)
print_message('Warning: ', termcap.Yellow, message, **kwargs)
printed = print_message('Warning: ', termcap.Yellow, message, **kwargs)
all_warnings.append(printed)
def error(*args, **kwargs):
message = ' '.join(args)