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

Side by Side Diff: checkdeps/checkdeps.py

Issue 1954943003: Fix checkdeps when includes contain "../" in them. (Closed) Base URL: https://chromium.googlesource.com/chromium/buildtools.git@master
Patch Set: Created 4 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
« 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 2012 The Chromium Authors. All rights reserved. 2 # Copyright 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" and "import" directives in the .cpp and .java source files. 9 "#include" and "import" directives in the .cpp and .java source files.
10 Any source file including something not permitted by the DEPS files will fail. 10 Any source file including something not permitted by the DEPS files will fail.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 the change being presubmit checked. 100 the change being presubmit checked.
101 101
102 Args: 102 Args:
103 added_includes: ((file_path, (include_line, include_line, ...), ...) 103 added_includes: ((file_path, (include_line, include_line, ...), ...)
104 104
105 Return: 105 Return:
106 A list of tuples, (bad_file_path, rule_type, rule_description) 106 A list of tuples, (bad_file_path, rule_type, rule_description)
107 where rule_type is one of Rule.DISALLOW or Rule.TEMP_ALLOW and 107 where rule_type is one of Rule.DISALLOW or Rule.TEMP_ALLOW and
108 rule_description is human-readable. Empty if no problems. 108 rule_description is human-readable. Empty if no problems.
109 """ 109 """
110 cpp = cpp_checker.CppChecker(self.verbose) 110 cpp = cpp_checker.CppChecker(self.verbose, self._resolve_dotdot)
111 problems = [] 111 problems = []
112 for file_path, include_lines in added_includes: 112 for file_path, include_lines in added_includes:
113 if not cpp.IsCppFile(file_path): 113 if not cpp.IsCppFile(file_path):
114 continue 114 continue
115 rules_for_file = self.GetDirectoryRules(os.path.dirname(file_path)) 115 rules_for_file = self.GetDirectoryRules(os.path.dirname(file_path))
116 if not rules_for_file: 116 if not rules_for_file:
117 continue 117 continue
118 for line in include_lines: 118 for line in include_lines:
119 is_include, violation = cpp.CheckLine( 119 is_include, violation = cpp.CheckLine(
120 rules_for_file, line, file_path, True) 120 rules_for_file, line, file_path, True)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if options.json: 221 if options.json:
222 deps_checker.results_formatter = results.JSONResultsFormatter( 222 deps_checker.results_formatter = results.JSONResultsFormatter(
223 options.json, deps_checker.results_formatter) 223 options.json, deps_checker.results_formatter)
224 224
225 deps_checker.CheckDirectory(start_dir) 225 deps_checker.CheckDirectory(start_dir)
226 return deps_checker.Report() 226 return deps_checker.Report()
227 227
228 228
229 if '__main__' == __name__: 229 if '__main__' == __name__:
230 sys.exit(main()) 230 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