diff options
author | agrieve <agrieve@chromium.org> | 2016-01-05 19:04:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-06 03:05:07 +0000 |
commit | a8815d201980b613bf76d8f8977c718623e74d03 (patch) | |
tree | 67bef243847138935f25484505440527643f9b0f /build/android/gyp | |
parent | 34b2a9dee5cf6d69f1e7008e3cd161bda920acf2 (diff) | |
download | chromium_src-a8815d201980b613bf76d8f8977c718623e74d03.zip chromium_src-a8815d201980b613bf76d8f8977c718623e74d03.tar.gz chromium_src-a8815d201980b613bf76d8f8977c718623e74d03.tar.bz2 |
Fix up proguard output filtering
Removes build noise when building release on Android.
BUG=573257
Review URL: https://codereview.chromium.org/1565433002
Cr-Commit-Position: refs/heads/master@{#367762}
Diffstat (limited to 'build/android/gyp')
-rwxr-xr-x | build/android/gyp/apk_obfuscate.py | 4 | ||||
-rwxr-xr-x | build/android/gyp/proguard.py | 4 | ||||
-rw-r--r-- | build/android/gyp/util/proguard_util.py | 57 |
3 files changed, 41 insertions, 24 deletions
diff --git a/build/android/gyp/apk_obfuscate.py b/build/android/gyp/apk_obfuscate.py index 4a13cb1..f29f091 100755 --- a/build/android/gyp/apk_obfuscate.py +++ b/build/android/gyp/apk_obfuscate.py @@ -69,6 +69,8 @@ def ParseArgs(argv): 'These will not be obfuscated.') parser.add_option('--multidex-configuration-path', help='A JSON file containing multidex build configuration.') + parser.add_option('--verbose', '-v', action='store_true', + help='Print all proguard output') (options, args) = parser.parse_args(argv) @@ -118,7 +120,7 @@ def DoProguard(options): configs.append(multidex_config) proguard.configs(configs) - proguard.CheckOutput() + proguard.CheckOutput(options.verbose) def _PossibleMultidexConfig(options): diff --git a/build/android/gyp/proguard.py b/build/android/gyp/proguard.py index 2484354..4bbb5d5 100755 --- a/build/android/gyp/proguard.py +++ b/build/android/gyp/proguard.py @@ -31,6 +31,8 @@ def _ParseOptions(args): parser.add_option('--classpath', action='append', help='Classpath for proguard.') parser.add_option('--stamp', help='Path to touch on success.') + parser.add_option('--verbose', '-v', action='store_true', + help='Print all proguard output') options, _ = parser.parse_args(args) @@ -63,7 +65,7 @@ def main(args): input_paths = proguard.GetInputs() build_utils.CallAndWriteDepfileIfStale( - proguard.CheckOutput, + lambda: proguard.CheckOutput(options.verbose), options, input_paths=input_paths, input_strings=proguard.build(), diff --git a/build/android/gyp/util/proguard_util.py b/build/android/gyp/util/proguard_util.py index 8ca8646..70b781d 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: + 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, |