diff options
author | jbudorick <jbudorick@chromium.org> | 2015-08-22 16:33:16 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-22 23:34:09 +0000 |
commit | 5194d46039a269294d3e5bf7a1c827303521d79d (patch) | |
tree | ea03a98bc6b96b924e6b89cb8d820e0b097889ee | |
parent | 8c6e5cdb6e1182e37ddfef3758a34358481b5797 (diff) | |
download | chromium_src-5194d46039a269294d3e5bf7a1c827303521d79d.zip chromium_src-5194d46039a269294d3e5bf7a1c827303521d79d.tar.gz chromium_src-5194d46039a269294d3e5bf7a1c827303521d79d.tar.bz2 |
[Android] Suppress findbugs stderr output.
BUG=514342
Review URL: https://codereview.chromium.org/1258303003
Cr-Commit-Position: refs/heads/master@{#344992}
-rw-r--r-- | build/android/findbugs_action.gypi | 22 | ||||
-rwxr-xr-x | build/android/findbugs_diff.py | 6 | ||||
-rw-r--r-- | build/android/pylib/cmd_helper.py | 28 | ||||
-rw-r--r-- | build/android/pylib/utils/findbugs.py | 8 | ||||
-rw-r--r-- | build/config/android/config.gni | 4 | ||||
-rw-r--r-- | build/config/android/internal_rules.gni | 11 | ||||
-rw-r--r-- | build/config/android/rules.gni | 5 | ||||
-rw-r--r-- | build/java.gypi | 12 | ||||
-rw-r--r-- | build/java_apk.gypi | 12 |
9 files changed, 78 insertions, 30 deletions
diff --git a/build/android/findbugs_action.gypi b/build/android/findbugs_action.gypi deleted file mode 100644 index e3b3d36..0000000 --- a/build/android/findbugs_action.gypi +++ /dev/null @@ -1,22 +0,0 @@ - -{ - 'action_name': 'findbugs_<(_target_name)', - 'message': 'Running findbugs on <(_target_name)', - 'variables': { - }, - 'inputs': [ - '<(DEPTH)/build/android/findbugs_diff.py', - '<(DEPTH)/build/android/findbugs_filter/findbugs_exclude.xml', - '<(DEPTH)/build/android/pylib/utils/findbugs.py', - '<(findbugs_target_jar_path)', - ], - 'outputs': [ - '<(stamp_path)', - ], - 'action': [ - 'python', '<(DEPTH)/build/android/findbugs_diff.py', - '--auxclasspath-gyp', '>(auxclasspath)', - '--stamp', '<(stamp_path)', - '<(findbugs_target_jar_path)', - ], -} diff --git a/build/android/findbugs_diff.py b/build/android/findbugs_diff.py index f55e462..06c689a 100755 --- a/build/android/findbugs_diff.py +++ b/build/android/findbugs_diff.py @@ -22,6 +22,7 @@ import sys from pylib import constants from pylib.utils import findbugs +from pylib.utils import run_tests_helper _DEFAULT_BASE_DIR = os.path.join( constants.DIR_SOURCE_ROOT, 'build', 'android', 'findbugs_filter') @@ -35,6 +36,8 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument( + '-v', '--verbose', action='count', help='Enable verbose logging.') + parser.add_argument( '-a', '--auxclasspath', default=None, dest='auxclasspath', help='Set aux classpath for analysis.') parser.add_argument( @@ -69,6 +72,9 @@ def main(): help='JAR file to analyze') args = parser.parse_args(build_utils.ExpandFileArgs(sys.argv[1:])) + + run_tests_helper.SetLogLevel(args.verbose) + if args.auxclasspath: args.auxclasspath = args.auxclasspath.split(':') elif args.auxclasspath_gyp: diff --git a/build/android/pylib/cmd_helper.py b/build/android/pylib/cmd_helper.py index 1c2e9d9..8f3708b 100644 --- a/build/android/pylib/cmd_helper.py +++ b/build/android/pylib/cmd_helper.py @@ -145,17 +145,35 @@ def GetCmdStatusAndOutput(args, cwd=None, shell=False): Returns: The 2-tuple (exit code, output). """ - _ValidateAndLogCommand(args, cwd, shell) - pipe = Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - shell=shell, cwd=cwd) - stdout, stderr = pipe.communicate() + status, stdout, stderr = GetCmdStatusOutputAndError( + args, cwd=cwd, shell=shell) if stderr: logging.critical(stderr) if len(stdout) > 4096: logging.debug('Truncated output:') logging.debug(stdout[:4096]) - return (pipe.returncode, stdout) + return (status, stdout) + +def GetCmdStatusOutputAndError(args, cwd=None, shell=False): + """Executes a subprocess and returns its exit code, output, and errors. + + Args: + args: A string or a sequence of program arguments. The program to execute is + the string or the first item in the args sequence. + cwd: If not None, the subprocess's current directory will be changed to + |cwd| before it's executed. + shell: Whether to execute args as a shell command. Must be True if args + is a string and False if args is a sequence. + + Returns: + The 2-tuple (exit code, output). + """ + _ValidateAndLogCommand(args, cwd, shell) + pipe = Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + shell=shell, cwd=cwd) + stdout, stderr = pipe.communicate() + return (pipe.returncode, stdout, stderr) class TimeoutError(Exception): diff --git a/build/android/pylib/utils/findbugs.py b/build/android/pylib/utils/findbugs.py index 8deb0fe..6ad856f 100644 --- a/build/android/pylib/utils/findbugs.py +++ b/build/android/pylib/utils/findbugs.py @@ -142,12 +142,16 @@ def Run(exclude, classes_to_analyze, auxiliary_classes, output_file, cmd.extend(os.path.abspath(j) for j in jars or []) if output_file: - cmd_helper.RunCmd(cmd) + _, _, stderr = cmd_helper.GetCmdStatusOutputAndError(cmd) + results_doc = xml.dom.minidom.parse(output_file) else: - raw_out = cmd_helper.GetCmdOutput(cmd) + _, raw_out, stderr = cmd_helper.GetCmdStatusOutputAndError(cmd) results_doc = xml.dom.minidom.parseString(raw_out) + for line in stderr.splitlines(): + logging.debug(' %s', line) + current_warnings_set = _ParseXmlResults(results_doc) return (' '.join(cmd), current_warnings_set) diff --git a/build/config/android/config.gni b/build/config/android/config.gni index 8fe60ed..613b29d 100644 --- a/build/config/android/config.gni +++ b/build/config/android/config.gni @@ -48,6 +48,10 @@ if (is_android) { # Set to true to run findbugs on JAR targets. run_findbugs = false + # Set to true to enable verbose findbugs logging. This does nothing if + # run_findbugs is false. + findbugs_verbose = false + # Set to true to enable the Errorprone compiler use_errorprone_java_compiler = false } diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni index 913e0c23..287a006 100644 --- a/build/config/android/internal_rules.gni +++ b/build/config/android/internal_rules.gni @@ -107,6 +107,10 @@ template("findbugs") { rebase_path(result_path, root_build_dir), rebase_path(jar_path, root_build_dir), ] + + if (findbugs_verbose) { + args += [ "-vv" ] + } } } @@ -1185,12 +1189,17 @@ template("java_library_impl") { } } + if (defined(invoker.run_findbugs)) { + run_findbugs = invoker.run_findbugs + } if (run_findbugs) { _final_datadeps += [ ":${_template_name}__findbugs" ] findbugs("${_template_name}__findbugs") { build_config = _build_config jar_path = _jar_path - deps = build_config_deps + deps = [ + ":$_compile_java_target", + ] } } } diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni index c7e5ad6..4c6c4bb 100644 --- a/build/config/android/rules.gni +++ b/build/config/android/rules.gni @@ -1369,6 +1369,10 @@ template("android_apk") { srcjar_deps = _srcjar_deps dex_path = base_path + ".dex.jar" + if (defined(invoker.run_findbugs)) { + run_findbugs = invoker.run_findbugs + } + if (defined(invoker.deps)) { deps += invoker.deps } @@ -1656,6 +1660,7 @@ template("instrumentation_test_apk") { data_deps += test_runner_data_dep } deps += [ "//testing/android/broker:broker_java" ] + run_findbugs = false } } diff --git a/build/java.gypi b/build/java.gypi index 73c550d..614d50a 100644 --- a/build/java.gypi +++ b/build/java.gypi @@ -227,6 +227,17 @@ { 'action_name': 'findbugs_<(_target_name)', 'message': 'Running findbugs on <(_target_name)', + 'variables': { + 'additional_findbugs_args': [], + 'findbugs_verbose%': 0, + }, + 'conditions': [ + ['findbugs_verbose == 1', { + 'variables': { + 'additional_findbugs_args+': ['-vv'], + }, + }], + ], 'inputs': [ '<(DEPTH)/build/android/findbugs_diff.py', '<(DEPTH)/build/android/findbugs_filter/findbugs_exclude.xml', @@ -242,6 +253,7 @@ 'python', '<(DEPTH)/build/android/findbugs_diff.py', '--auxclasspath-gyp', '>(input_jars_paths)', '--stamp', '<(findbugs_stamp)', + '<@(additional_findbugs_args)', '<(jar_final_path)', ], }, diff --git a/build/java_apk.gypi b/build/java_apk.gypi index a1fc857..6dbb858 100644 --- a/build/java_apk.gypi +++ b/build/java_apk.gypi @@ -721,6 +721,17 @@ { 'action_name': 'findbugs_<(_target_name)', 'message': 'Running findbugs on <(_target_name)', + 'variables': { + 'additional_findbugs_args': [], + 'findbugs_verbose%': 0, + }, + 'conditions': [ + ['findbugs_verbose == 1', { + 'variables': { + 'additional_findbugs_args+': ['-vv'], + }, + }], + ], 'inputs': [ '<(DEPTH)/build/android/findbugs_diff.py', '<(DEPTH)/build/android/findbugs_filter/findbugs_exclude.xml', @@ -736,6 +747,7 @@ 'python', '<(DEPTH)/build/android/findbugs_diff.py', '--auxclasspath-gyp', '>(input_jars_paths)', '--stamp', '<(findbugs_stamp)', + '<@(additional_findbugs_args)', '<(jar_path)', ], }, |