OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 """Wrapper script to help run clang tools across Chromium code. | 5 """Wrapper script to help run clang tools across Chromium code. |
6 | 6 |
7 How to use this tool: | 7 How to use this tool: |
8 If you want to run the tool across all Chromium code: | 8 If you want to run the tool across all Chromium code: |
9 run_tool.py <tool> <path/to/compiledb> | 9 run_tool.py <tool> <path/to/compiledb> |
10 | 10 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 os.environ['PATH'] = '%s%s%s' % ( | 312 os.environ['PATH'] = '%s%s%s' % ( |
313 os.path.abspath(os.path.join( | 313 os.path.abspath(os.path.join( |
314 os.path.dirname(__file__), | 314 os.path.dirname(__file__), |
315 '../../../third_party/llvm-build/Release+Asserts/bin')), | 315 '../../../third_party/llvm-build/Release+Asserts/bin')), |
316 os.pathsep, | 316 os.pathsep, |
317 os.environ['PATH']) | 317 os.environ['PATH']) |
318 | 318 |
319 if args.generate_compdb: | 319 if args.generate_compdb: |
320 compile_db.GenerateWithNinja(args.compile_database) | 320 compile_db.GenerateWithNinja(args.compile_database) |
321 | 321 |
| 322 filenames = set(_GetFilesFromGit(args.path_filter)) |
322 if args.all: | 323 if args.all: |
323 filenames = set(_GetFilesFromCompileDB(args.compile_database)) | 324 source_filenames = set(_GetFilesFromCompileDB(args.compile_database)) |
324 source_filenames = filenames | |
325 else: | 325 else: |
326 filenames = set(_GetFilesFromGit(args.path_filter)) | |
327 # Filter out files that aren't C/C++/Obj-C/Obj-C++. | 326 # Filter out files that aren't C/C++/Obj-C/Obj-C++. |
328 extensions = frozenset(('.c', '.cc', '.cpp', '.m', '.mm')) | 327 extensions = frozenset(('.c', '.cc', '.cpp', '.m', '.mm')) |
329 source_filenames = [f | 328 source_filenames = [f |
330 for f in filenames | 329 for f in filenames |
331 if os.path.splitext(f)[1] in extensions] | 330 if os.path.splitext(f)[1] in extensions] |
332 dispatcher = _CompilerDispatcher(args.tool, args.tool_args, | 331 dispatcher = _CompilerDispatcher(args.tool, args.tool_args, |
333 args.compile_database, | 332 args.compile_database, |
334 source_filenames) | 333 source_filenames) |
335 dispatcher.Run() | 334 dispatcher.Run() |
336 # Filter out edits to files that aren't in the git repository, since it's not | 335 # Filter out edits to files that aren't in the git repository, since it's not |
337 # useful to modify files that aren't under source control--typically, these | 336 # useful to modify files that aren't under source control--typically, these |
338 # are generated files or files in a git submodule that's not part of Chromium. | 337 # are generated files or files in a git submodule that's not part of Chromium. |
339 _ApplyEdits({k: v | 338 _ApplyEdits({k: v |
340 for k, v in dispatcher.edits.iteritems() | 339 for k, v in dispatcher.edits.iteritems() |
341 if os.path.realpath(k) in filenames}) | 340 if os.path.realpath(k) in filenames}) |
342 return -dispatcher.failed_count | 341 return -dispatcher.failed_count |
343 | 342 |
344 | 343 |
345 if __name__ == '__main__': | 344 if __name__ == '__main__': |
346 sys.exit(main()) | 345 sys.exit(main()) |
OLD | NEW |