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

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: Add warning to script. Created 5 years, 7 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 else: 318 else:
319 filenames = set(_GetFilesFromGit(argv[2:])) 319 filenames = set(_GetFilesFromGit(argv[2:]))
320 # Filter out files that aren't C/C++/Obj-C/Obj-C++. 320 # Filter out files that aren't C/C++/Obj-C/Obj-C++.
321 extensions = frozenset(('.c', '.cc', '.m', '.mm')) 321 extensions = frozenset(('.c', '.cc', '.h', '.m', '.mm'))
dcheng 2015/05/06 17:31:18 Why does this need to change? There (should) never
Sami 2015/05/07 10:37:37 IIRC without this some .h files were never getting
Sami 2015/05/07 13:31:35 Yeah, turns out if I don't do this, none of the .h
322 filenames = [f for f in filenames 322 filenames = [f for f in filenames
323 if os.path.splitext(f)[1] in extensions] 323 if os.path.splitext(f)[1] in extensions]
324 dispatcher = _CompilerDispatcher(argv[0], argv[1], filenames) 324 dispatcher = _CompilerDispatcher(argv[0], argv[1], filenames)
325 dispatcher.Run() 325 dispatcher.Run()
326 # Filter out edits to files that aren't in the git repository, since it's not 326 # 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 327 # 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. 328 # 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() 329 _ApplyEdits({k : v for k, v in dispatcher.edits.iteritems()
330 if os.path.realpath(k) in filenames}, 330 if os.path.realpath(k) in filenames},
331 clang_format_diff_path) 331 clang_format_diff_path)
332 if dispatcher.failed_count != 0: 332 if dispatcher.failed_count != 0:
333 return 2 333 return 2
334 return 0 334 return 0
335 335
336 336
337 if __name__ == '__main__': 337 if __name__ == '__main__':
338 sys.exit(main(sys.argv[1:])) 338 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698