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

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

Issue 1010073002: clang: Add a tool for MessageLoop refactoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed some hacks. 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
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 editable_filenames = filenames
318 else: 319 else:
319 filenames = set(_GetFilesFromGit(argv[2:])) 320 all_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 filenames = [f for f in all_filenames
323 if os.path.splitext(f)[1] in extensions] 324 if os.path.splitext(f)[1] in extensions]
325 # Some files (e.g., headers) are not part of the compile database but can
326 # still be edited.
327 editable_extensions = frozenset(('.h', )) | extensions
328 editable_filenames = [f for f in all_filenames
329 if os.path.splitext(f)[1] in editable_extensions]
324 dispatcher = _CompilerDispatcher(argv[0], argv[1], filenames) 330 dispatcher = _CompilerDispatcher(argv[0], argv[1], filenames)
325 dispatcher.Run() 331 dispatcher.Run()
326 # Filter out edits to files that aren't in the git repository, since it's not 332 # 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 333 # 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. 334 # 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() 335 _ApplyEdits({k : v for k, v in dispatcher.edits.iteritems()
330 if os.path.realpath(k) in filenames}, 336 if os.path.realpath(k) in editable_filenames},
dcheng 2015/05/26 20:35:44 I think it's OK to just have this be "all_filename
331 clang_format_diff_path) 337 clang_format_diff_path)
332 if dispatcher.failed_count != 0: 338 if dispatcher.failed_count != 0:
333 return 2 339 return 2
334 return 0 340 return 0
335 341
336 342
337 if __name__ == '__main__': 343 if __name__ == '__main__':
338 sys.exit(main(sys.argv[1:])) 344 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698