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

Side by Side Diff: tools/checkdeps/checkdeps.py

Issue 10806049: Add checkdeps presubmit check. Warns on new #includes of dependencies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to parent. Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « PRESUBMIT.py ('k') | tools/checkdeps/cpp_checker.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) 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 """Makes sure that files include headers from allowed directories. 6 """Makes sure that files include headers from allowed directories.
7 7
8 Checks DEPS files in the source tree for rules, and applies those rules to 8 Checks DEPS files in the source tree for rules, and applies those rules to
9 "#include" commands in source files. Any source file including something not 9 "#include" commands in source files. Any source file including something not
10 permitted by the DEPS files will fail. 10 permitted by the DEPS files will fail.
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 directory_rules[norm_dir_path] = None 333 directory_rules[norm_dir_path] = None
334 else: 334 else:
335 ApplyDirectoryRulesAndSkipSubdirs(parent_rules, dir_path) 335 ApplyDirectoryRulesAndSkipSubdirs(parent_rules, dir_path)
336 return directory_rules[norm_dir_path] 336 return directory_rules[norm_dir_path]
337 337
338 cpp = cpp_checker.CppChecker(self.verbose) 338 cpp = cpp_checker.CppChecker(self.verbose)
339 339
340 problems = [] 340 problems = []
341 for file_path, include_lines in added_includes: 341 for file_path, include_lines in added_includes:
342 # TODO(joi): Make this cover Java as well. 342 # TODO(joi): Make this cover Java as well.
343 if not os.path.splitext(file_path)[1] in cpp.EXTENSIONS: 343 if not cpp.IsCppFile(file_path):
344 pass 344 pass
345 rules_for_file = GetDirectoryRules(os.path.dirname(file_path)) 345 rules_for_file = GetDirectoryRules(os.path.dirname(file_path))
346 if rules_for_file: 346 if rules_for_file:
347 for line in include_lines: 347 for line in include_lines:
348 is_include, line_status, rule_type = cpp.CheckLine( 348 is_include, line_status, rule_type = cpp.CheckLine(
349 rules_for_file, line, True) 349 rules_for_file, line, True)
350 if rule_type != Rule.ALLOW: 350 if rule_type != Rule.ALLOW:
351 problems.append((file_path, rule_type, line_status)) 351 problems.append((file_path, rule_type, line_status))
352 return problems 352 return problems
353 353
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 for result in results: 418 for result in results:
419 print result 419 print result
420 print "\nFAILED\n" 420 print "\nFAILED\n"
421 return 1 421 return 1
422 print "\nSUCCESS\n" 422 print "\nSUCCESS\n"
423 return 0 423 return 0
424 424
425 425
426 if '__main__' == __name__: 426 if '__main__' == __name__:
427 sys.exit(main()) 427 sys.exit(main())
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | tools/checkdeps/cpp_checker.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698