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

Side by Side Diff: tools/sort-headers.py

Issue 491243003: Add another special rule for Windows headers to tools/sort-headers.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Given a filename as an argument, sort the #include/#imports in that file. 6 """Given a filename as an argument, sort the #include/#imports in that file.
7 7
8 Shows a diff and prompts for confirmation before doing the deed. 8 Shows a diff and prompts for confirmation before doing the deed.
9 Works great with tools/git/for-all-touched-files.py. 9 Works great with tools/git/for-all-touched-files.py.
10 """ 10 """
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 line = line[len(prefix):] 46 line = line[len(prefix):]
47 break 47 break
48 48
49 # The win32 api has all sorts of implicit include order dependencies :-/ 49 # The win32 api has all sorts of implicit include order dependencies :-/
50 # Give a few headers special sort keys that make sure they appear before all 50 # Give a few headers special sort keys that make sure they appear before all
51 # other headers. 51 # other headers.
52 if line.startswith('<windows.h>'): # Must be before e.g. shellapi.h 52 if line.startswith('<windows.h>'): # Must be before e.g. shellapi.h
53 return '0' 53 return '0'
54 if line.startswith('<atlbase.h>'): # Must be before atlapp.h. 54 if line.startswith('<atlbase.h>'): # Must be before atlapp.h.
55 return '1' + line 55 return '1' + line
56 if line.startswith('<ole2.h>'): # Must be before e.g. intshcut.h
57 return '1' + line
56 if line.startswith('<unknwn.h>'): # Must be before e.g. intshcut.h 58 if line.startswith('<unknwn.h>'): # Must be before e.g. intshcut.h
57 return '1' + line 59 return '1' + line
58 60
59 # C++ system headers should come after C system headers. 61 # C++ system headers should come after C system headers.
60 if line.startswith('<'): 62 if line.startswith('<'):
61 if line.find('.h>') != -1: 63 if line.find('.h>') != -1:
62 return '2' + line.lower() 64 return '2' + line.lower()
63 else: 65 else:
64 return '3' + line.lower() 66 return '3' + line.lower()
65 67
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if len(filenames) < 1: 179 if len(filenames) < 1:
178 parser.print_help() 180 parser.print_help()
179 return 1 181 return 1
180 182
181 for filename in filenames: 183 for filename in filenames:
182 DiffAndConfirm(filename, opts.should_confirm, opts.perform_safety_checks) 184 DiffAndConfirm(filename, opts.should_confirm, opts.perform_safety_checks)
183 185
184 186
185 if __name__ == '__main__': 187 if __name__ == '__main__':
186 sys.exit(main()) 188 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698