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..78f44d9f4c1f83b2d37b87f505179e571060b6e5 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))') |
Nico
2016/01/05 19:53:07
nit: consider non-capturing groups (?:asdf) since
agrieve
2016/01/05 20:53:24
Done.
|
+ |
+ def __init__(self): |
+ self._last_line_ignored = False |
+ |
+ def __call__(self, output): |
+ ret = [] |
+ for line in output.splitlines(True): |
Nico
2016/01/05 19:53:07
nit: consider always naming bool parameters (split
agrieve
2016/01/05 20:53:24
I did actually try that, but it gives me:
|
+ 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 |
Nico
2016/01/05 19:53:07
This keeps
Maybe this is program method 'android.
agrieve
2016/01/05 20:53:24
It hides them because in this case the line starts
|
+ |
+ if not self._last_line_ignored: |
+ 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, |