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

Unified Diff: build/android/gyp/util/proguard_util.py

Issue 1565433002: Fix up proguard output filtering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: non-capturing groups Created 4 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 | « build/android/gyp/proguard.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/util/proguard_util.py
diff --git a/build/android/gyp/util/proguard_util.py b/build/android/gyp/util/proguard_util.py
index 8ca86462631939eb0f44eb2b506b8e508e5fe762..70b781dfedce2f8ea04ac712d1faee9bbcda89c4 100644
--- a/build/android/gyp/util/proguard_util.py
+++ b/build/android/gyp/util/proguard_util.py
@@ -3,29 +3,33 @@
# found in the LICENSE file.
import os
+import re
from util import build_utils
-def FilterProguardOutput(output):
- '''ProGuard outputs boring stuff to stdout (proguard version, jar path, etc)
+
+class _ProguardOutputFilter(object):
+ """ProGuard outputs boring stuff to stdout (proguard version, jar path, etc)
as well as interesting stuff (notes, warnings, etc). If stdout is entirely
- boring, this method suppresses the output.
- '''
- ignore_patterns = [
- 'ProGuard, version ',
- 'Reading program jar [',
- 'Reading library jar [',
- 'Preparing output jar [',
- ' Copying resources from program jar [',
- ]
- for line in output.splitlines():
- for pattern in ignore_patterns:
- if line.startswith(pattern):
- break
- else:
- # line doesn't match any of the patterns; it's probably something worth
- # printing out.
- return output
- return ''
+ boring, this class suppresses the output.
+ """
+
+ IGNORE_RE = re.compile(
+ r'(?:Pro.*version|Note:|Reading|Preparing|.*:.*(?:MANIFEST\.MF|\.empty))')
+
+ def __init__(self):
+ self._last_line_ignored = False
+
+ def __call__(self, output):
+ ret = []
+ for line in output.splitlines(True):
+ if not line.startswith(' '):
+ self._last_line_ignored = bool(self.IGNORE_RE.match(line))
+ elif 'You should check if you need to specify' in line:
+ self._last_line_ignored = True
+
+ if not self._last_line_ignored:
Nico 2016/01/05 22:22:21 Ooh I see, I was misreading this.
+ ret.append(line)
+ return ''.join(ret)
class ProguardCmdBuilder(object):
@@ -145,7 +149,7 @@ class ProguardCmdBuilder(object):
return inputs
- def CheckOutput(self):
+ def CheckOutput(self, verbose=False):
self.build()
# Proguard will skip writing these files if they would be empty. Create
# empty versions of them all now so that they are updated as the build
@@ -154,8 +158,17 @@ class ProguardCmdBuilder(object):
open(self._outjar + '.seeds', 'w').close()
open(self._outjar + '.usage', 'w').close()
open(self._outjar + '.mapping', 'w').close()
+ # Warning: and Error: are sent to stderr, but messages and Note: are sent
+ # to stdout.
+ stdout_filter = None
+ stderr_filter = None
+ if not verbose:
+ stdout_filter = _ProguardOutputFilter()
+ stderr_filter = _ProguardOutputFilter()
build_utils.CheckOutput(self._cmd, print_stdout=True,
- stdout_filter=FilterProguardOutput)
+ print_stderr=True,
+ stdout_filter=stdout_filter,
+ stderr_filter=stderr_filter)
this_info = {
'inputs': self._injars,
« no previous file with comments | « build/android/gyp/proguard.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698