From 686676803d9d84a968ed3509efb63b634e20d6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingemar=20=C3=85dahl?= Date: Thu, 6 Jul 2017 16:20:37 +0000 Subject: [PATCH] Add command line flag to override suppression.xml path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let the suppression script optionally write to a configuration file set on the command line, rather than the default. //build_overrides/build.gni can set a 'lint_suppressions_file' variable, allowing different products to override the lint suppression configuration. Updating this overriding suppression configuration can otherwise be cumbersome. Bug: 737897 Change-Id: I1551d7e6951f212e42ee79ffac568e9a5208aec9 Reviewed-on: https://chromium-review.googlesource.com/561137 Reviewed-by: Peter Wen Reviewed-by: Andrew Grieve Commit-Queue: Ingemar Ã…dahl Cr-Original-Commit-Position: refs/heads/master@{#484621} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0972c74b68f73edc01a5553243ca26b8c723a9e2 --- android/lint/suppress.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/android/lint/suppress.py b/android/lint/suppress.py index 1e3514a58..a3719c18f 100755 --- a/android/lint/suppress.py +++ b/android/lint/suppress.py @@ -9,8 +9,8 @@ # pylint: disable=no-member +import argparse import collections -import optparse import os import re import sys @@ -23,7 +23,8 @@ from pylib.constants import host_paths _TMP_DIR_RE = re.compile(r'^/tmp/.*/(SRC_ROOT[0-9]+|PRODUCT_DIR)/') _THIS_FILE = os.path.abspath(__file__) -_CONFIG_PATH = os.path.join(os.path.dirname(_THIS_FILE), 'suppressions.xml') +_DEFAULT_CONFIG_PATH = os.path.join(os.path.dirname(_THIS_FILE), + 'suppressions.xml') _DOC = ( '\nSTOP! It looks like you want to suppress some lint errors:\n' '- Have you tried identifing the offending patch?\n' @@ -121,13 +122,16 @@ def _Suppress(config_path, result_path): def main(): - parser = optparse.OptionParser(usage='%prog RESULT-FILE') - _, args = parser.parse_args() + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--config', + help='Path to suppression.xml config file', + default=_DEFAULT_CONFIG_PATH) + parser.add_argument('result_path', + help='Lint results xml file', + metavar='RESULT_FILE') + args = parser.parse_args() - if len(args) != 1 or not os.path.exists(args[0]): - parser.error('Must provide RESULT-FILE') - - _Suppress(_CONFIG_PATH, args[0]) + _Suppress(args.config, args.result_path) if __name__ == '__main__':