Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """Invokes the Clang static analysis command using arguments provided on the | |
| 7 command line. | |
| 8 """ | |
| 9 | |
| 10 import argparse | |
| 11 import fnmatch | |
| 12 import os | |
| 13 import shutil | |
| 14 import sys | |
| 15 import tempfile | |
| 16 | |
| 17 import wrapper_utils | |
| 18 | |
| 19 | |
| 20 def main(): | |
| 21 parser = argparse.ArgumentParser(description=__doc__) | |
| 22 parser.add_argument('--clang-cc-path', | |
|
Nico
2017/01/11 20:20:05
can't the script hardcode that to script_dir/../..
Kevin M
2017/01/18 23:04:27
Acknowledged.
| |
| 23 help='Path to the clang compiler.', | |
| 24 metavar='PATH') | |
| 25 parser.add_argument('--clang-cxx-path', | |
| 26 help='Path to the clang++ compiler', | |
| 27 metavar='PATH') | |
| 28 parser.add_argument('--analyzer', | |
| 29 help='Path to the language-specific Clang analysis tool.', | |
| 30 required=True, | |
| 31 metavar='PATH') | |
| 32 args, compile_args = parser.parse_known_args() | |
| 33 | |
| 34 # Check that only one of --clang-cc-path or --clang-cxx-path are set. | |
| 35 assert ((args.clang_cc_path != None) != (args.clang_cxx_path != None)) | |
| 36 assert ((args.clang_cc_path != None) or (args.clang_cxx_path != None)) | |
|
Wez
2017/01/14 00:04:58
Isn't this implicit from the != case? If they wer
Kevin M
2017/01/18 23:04:27
Both of them being set is also a failure case.
Wez
2017/01/21 01:10:15
But if both of them are set (or not-set) then (a !
Kevin M
2017/01/24 01:20:49
Done.
| |
| 37 | |
| 38 is_cxx = args.clang_cxx_path != None | |
| 39 env = os.environ | |
| 40 env['CCC_ANALYZER_FORCE_ANALYZE_DEBUG_CODE'] = '0' | |
| 41 env['CCC_ANALYZER_OUTPUT_FORMAT'] = 'text' | |
| 42 clang_path = args.clang_cxx_path or args.clang_cc_path | |
| 43 if is_cxx: | |
| 44 env['CCC_CXX'] = clang_path | |
| 45 env['CLANG_CXX'] = clang_path | |
|
Wez
2017/01/14 00:04:58
This differs from the previous version, where you
Kevin M
2017/01/18 23:04:28
Yes.
| |
| 46 else: | |
| 47 env['CCC_CC'] = clang_path | |
| 48 env['CLANG'] = clang_path | |
| 49 | |
| 50 temp_dir = tempfile.mkdtemp() | |
|
Wez
2017/01/14 00:04:58
Do we want to be dumping stuff in temp files, rath
Kevin M
2017/01/18 23:04:25
This is for unsummarized output files. We have som
Wez
2017/01/21 01:10:15
Acknowledged.
| |
| 51 try: | |
| 52 env['CCC_ANALYZER_HTML'] = temp_dir | |
| 53 returncode, stderr = wrapper_utils.CaptureCommandStderr( | |
| 54 wrapper_utils.CommandToRun([args.analyzer] + compile_args), env) | |
| 55 sys.stderr.write(stderr) | |
|
Wez
2017/01/14 00:04:58
nit: It seems strange to "capture command stderr",
Kevin M
2017/01/18 23:04:27
I think this is the only way to get output to stde
Wez
2017/01/21 01:10:15
According to the documentation the default behavio
Kevin M
2017/01/24 01:20:49
Done.
| |
| 56 return returncode | |
| 57 finally: | |
| 58 shutil.rmtree(temp_dir) | |
| 59 | |
| 60 if __name__ == "__main__": | |
| 61 sys.exit(main()) | |
| OLD | NEW |