Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Unified Diff: scripts/slave/compile.py

Issue 9179005: Filter out ANSI escape sequences when building with clang. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build/
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698