Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: tools/clang/scripts/run_tool.py

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/clang/scripts/package.sh ('k') | tools/clang/scripts/update.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5
6 """Wrapper script to help run clang tools across Chromium code. 6 """Wrapper script to help run clang tools across Chromium code.
7 7
8 How to use this tool: 8 How to use this tool:
9 If you want to run the tool across all Chromium code: 9 If you want to run the tool across all Chromium code:
10 run_tool.py <tool> <path/to/compiledb> 10 run_tool.py <tool> <path/to/compiledb>
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 '../../../third_party/llvm/tools/clang/tools/clang-format', 308 '../../../third_party/llvm/tools/clang/tools/clang-format',
309 'clang-format-diff.py') 309 'clang-format-diff.py')
310 # TODO(dcheng): Allow this to be controlled with a flag as well. 310 # TODO(dcheng): Allow this to be controlled with a flag as well.
311 # TODO(dcheng): Shell escaping of args to git diff to clang-format is broken 311 # TODO(dcheng): Shell escaping of args to git diff to clang-format is broken
312 # on Windows. 312 # on Windows.
313 if not os.path.isfile(clang_format_diff_path) or sys.platform == 'win32': 313 if not os.path.isfile(clang_format_diff_path) or sys.platform == 'win32':
314 clang_format_diff_path = None 314 clang_format_diff_path = None
315 315
316 if len(argv) == 3 and argv[2] == '--all': 316 if len(argv) == 3 and argv[2] == '--all':
317 filenames = set(_GetFilesFromCompileDB(argv[1])) 317 filenames = set(_GetFilesFromCompileDB(argv[1]))
318 source_filenames = filenames
318 else: 319 else:
319 filenames = set(_GetFilesFromGit(argv[2:])) 320 filenames = set(_GetFilesFromGit(argv[2:]))
320 # Filter out files that aren't C/C++/Obj-C/Obj-C++. 321 # Filter out files that aren't C/C++/Obj-C/Obj-C++.
321 extensions = frozenset(('.c', '.cc', '.m', '.mm')) 322 extensions = frozenset(('.c', '.cc', '.m', '.mm'))
322 filenames = [f for f in filenames 323 source_filenames = [f for f in filenames
323 if os.path.splitext(f)[1] in extensions] 324 if os.path.splitext(f)[1] in extensions]
324 dispatcher = _CompilerDispatcher(argv[0], argv[1], filenames) 325 dispatcher = _CompilerDispatcher(argv[0], argv[1], source_filenames)
325 dispatcher.Run() 326 dispatcher.Run()
326 # Filter out edits to files that aren't in the git repository, since it's not 327 # Filter out edits to files that aren't in the git repository, since it's not
327 # useful to modify files that aren't under source control--typically, these 328 # useful to modify files that aren't under source control--typically, these
328 # are generated files or files in a git submodule that's not part of Chromium. 329 # are generated files or files in a git submodule that's not part of Chromium.
329 _ApplyEdits({k : v for k, v in dispatcher.edits.iteritems() 330 _ApplyEdits({k : v for k, v in dispatcher.edits.iteritems()
330 if os.path.realpath(k) in filenames}, 331 if os.path.realpath(k) in filenames},
331 clang_format_diff_path) 332 clang_format_diff_path)
332 if dispatcher.failed_count != 0: 333 if dispatcher.failed_count != 0:
333 return 2 334 return 2
334 return 0 335 return 0
335 336
336 337
337 if __name__ == '__main__': 338 if __name__ == '__main__':
338 sys.exit(main(sys.argv[1:])) 339 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « tools/clang/scripts/package.sh ('k') | tools/clang/scripts/update.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698