Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 25 matching lines...) Expand all Loading... | |
| 36 """Parses include_rules from DEPS files and verifies files in the | 36 """Parses include_rules from DEPS files and verifies files in the |
| 37 source tree against them. | 37 source tree against them. |
| 38 """ | 38 """ |
| 39 | 39 |
| 40 def __init__(self, | 40 def __init__(self, |
| 41 base_directory=None, | 41 base_directory=None, |
| 42 verbose=False, | 42 verbose=False, |
| 43 being_tested=False, | 43 being_tested=False, |
| 44 ignore_temp_rules=False, | 44 ignore_temp_rules=False, |
| 45 skip_tests=False, | 45 skip_tests=False, |
| 46 resolve_dotdot=False): | 46 resolve_dotdot=False): |
|
agrieve
2016/05/12 14:32:14
nit: can you change this default to True as well?
smaier
2016/05/12 14:46:48
Done.
| |
| 47 """Creates a new DepsChecker. | 47 """Creates a new DepsChecker. |
| 48 | 48 |
| 49 Args: | 49 Args: |
| 50 base_directory: OS-compatible path to root of checkout, e.g. C:\chr\src. | 50 base_directory: OS-compatible path to root of checkout, e.g. C:\chr\src. |
| 51 verbose: Set to true for debug output. | 51 verbose: Set to true for debug output. |
| 52 being_tested: Set to true to ignore the DEPS file at tools/checkdeps/DEPS. | 52 being_tested: Set to true to ignore the DEPS file at tools/checkdeps/DEPS. |
| 53 ignore_temp_rules: Ignore rules that start with Rule.TEMP_ALLOW ("!"). | 53 ignore_temp_rules: Ignore rules that start with Rule.TEMP_ALLOW ("!"). |
| 54 """ | 54 """ |
| 55 DepsBuilder.__init__( | 55 DepsBuilder.__init__( |
| 56 self, base_directory, verbose, being_tested, ignore_temp_rules) | 56 self, base_directory, verbose, being_tested, ignore_temp_rules) |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 action='store_true', dest='skip_tests', default=False, | 172 action='store_true', dest='skip_tests', default=False, |
| 173 help='Skip checking test files (best effort).') | 173 help='Skip checking test files (best effort).') |
| 174 option_parser.add_option( | 174 option_parser.add_option( |
| 175 '-v', '--verbose', | 175 '-v', '--verbose', |
| 176 action='store_true', default=False, | 176 action='store_true', default=False, |
| 177 help='Print debug logging') | 177 help='Print debug logging') |
| 178 option_parser.add_option( | 178 option_parser.add_option( |
| 179 '', '--json', | 179 '', '--json', |
| 180 help='Path to JSON output file') | 180 help='Path to JSON output file') |
| 181 option_parser.add_option( | 181 option_parser.add_option( |
| 182 '', '--resolve-dotdot', | 182 '', '--no-resolve-dotdot', |
| 183 action='store_true', dest='resolve_dotdot', default=False, | 183 action='store_false', dest='resolve_dotdot', default=True, |
| 184 help='resolve leading ../ in include directive paths relative ' | 184 help='resolve leading ../ in include directive paths relative ' |
| 185 'to the file perfoming the inclusion.') | 185 'to the file perfoming the inclusion.') |
| 186 | 186 |
| 187 options, args = option_parser.parse_args() | 187 options, args = option_parser.parse_args() |
| 188 | 188 |
| 189 deps_checker = DepsChecker(options.base_directory, | 189 deps_checker = DepsChecker(options.base_directory, |
| 190 verbose=options.verbose, | 190 verbose=options.verbose, |
| 191 ignore_temp_rules=options.ignore_temp_rules, | 191 ignore_temp_rules=options.ignore_temp_rules, |
| 192 skip_tests=options.skip_tests, | 192 skip_tests=options.skip_tests, |
| 193 resolve_dotdot=options.resolve_dotdot) | 193 resolve_dotdot=options.resolve_dotdot) |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 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()) |
| OLD | NEW |