Index: scripts/slave/compile.py |
=================================================================== |
--- scripts/slave/compile.py (revision 117812) |
+++ scripts/slave/compile.py (working copy) |
@@ -115,6 +115,44 @@ |
env['LDPLUSPLUS'] = ldplusplus |
+class CombineFilter(chromium_utils.RunCommandFilter): |
+ """A RunCommandFilter that runs several RunCommandFilters in a sequence.""" |
+ def __init__(self, *filters): |
+ chromium_utils.RunCommandFilter.__init__(self) |
+ self.filters = filter(None, filters) |
+ |
+ def FilterLine(self, a_line): |
+ """Called by RunCommand for each line of output.""" |
+ for f in self.filters: a_line = f.FilterLine(a_line) |
+ return a_line |
+ |
+ def FilterDone(self, last_bits): |
+ """Called by RunCommand when the command is done.""" |
+ for f in self.filters: last_bits = f.FilterDone(last_bits) |
+ return last_bits |
+ |
+ |
+# clang uses ANSII escape codes for colored diagnostics. Sadly, they get |
+# disabled when ninja is used (https://github.com/martine/ninja/issues/174), |
+# so we force clang's colors on. This filters the escape codes out so that |
+# they don't show up on the buildbot output. |
+# TODO(thakis): Pass escape sequences on to the master, and strip them there. |
+# Then they can be converted to html on the side. |
+class AnsiiEscapeSequenceStripper(chromium_utils.RunCommandFilter): |
+ # http://en.wikipedia.org/wiki/ANSI_escape_code#Sequence_elements |
+ # Only strip CSIs. |
+ # This regex was taken from colorama. |
+ ANSI_RE = re.compile('\033\[(?:\d|;)*[a-zA-Z]') |
+ |
+ def FilterLine(self, a_line): |
+ """Called by RunCommand for each line of output.""" |
+ return AnsiiEscapeSequenceStripper.ANSI_RE.sub('', a_line) |
+ |
+ def FilterDone(self, last_bits): |
+ """Called by RunCommand when the command is done.""" |
+ return AnsiiEscapeSequenceStripper.ANSI_RE.sub('', last_bits) |
+ |
+ |
# RunCommandFilter for xcodebuild |
class XcodebuildFilter(chromium_utils.RunCommandFilter): |
"""xcodebuild filter""" |
@@ -363,7 +401,7 @@ |
# Set up the filter before changing directories so the raw build log can |
# be recorded. |
# Support a local file blocking filters (for debugging). Also check the |
- # darwin version to make sure this is not 10.5 (easier then checking the |
+ # darwin version to make sure this is not 10.5 (easier than checking the |
# Xcode version), as Xcode 3.1.x has slightly different output. |
xcodebuild_filter = None |
no_filter_path = os.path.join(os.getcwd(), 'no_xcodebuild_filter') |
@@ -397,8 +435,12 @@ |
# Run the build. |
env.print_overrides() |
+ |
+ filter_obj = AnsiiEscapeSequenceStripper() |
+ if xcodebuild_filter: |
+ filter_obj = CombineFilter(filter_obj, xcodebuild_filter) |
result = chromium_utils.RunCommand(command, env=env, |
- filter_obj=xcodebuild_filter) |
+ filter_obj=filter_obj) |
if options.compiler in ('goma', 'goma-clang', 'gomaclang'): |
# Always stop the proxy for now to allow in-place update. |
@@ -643,8 +685,12 @@ |
chromium_utils.RunCommand(goma_ctl_cmd + ['ensure_start'], env=env) |
# Run the build. |
+ filter_obj = None |
+ if options.compiler in ('clang', 'goma-clang'): |
+ filter_obj = AnsiiEscapeSequenceStripper() |
env.print_overrides() |
- result = chromium_utils.RunCommand(command, env=env) |
+ result = chromium_utils.RunCommand(command, env=env, |
+ filter_obj=filter_obj) |
if options.compiler in ('goma', 'goma-clang'): |
# Always stop the proxy for now to allow in-place update. |