Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 root: The repository root where .git directory exists. | 409 root: The repository root where .git directory exists. |
| 410 | 410 |
| 411 Returns: | 411 Returns: |
| 412 A set of directories which contain sources managed by git. | 412 A set of directories which contain sources managed by git. |
| 413 """ | 413 """ |
| 414 git_source_directory = set() | 414 git_source_directory = set() |
| 415 popen_out = os.popen("cd %s && git ls-files --full-name ." % | 415 popen_out = os.popen("cd %s && git ls-files --full-name ." % |
| 416 pipes.quote(root)) | 416 pipes.quote(root)) |
| 417 for line in popen_out.readlines(): | 417 for line in popen_out.readlines(): |
| 418 dir_name = os.path.join(root, os.path.dirname(line)) | 418 dir_name = os.path.join(root, os.path.dirname(line)) |
| 419 git_source_directory.add(dir_name) | 419 while dir_name != root: |
|
satorux1
2011/10/27 23:04:16
Would be nice to add some comment as the logic is
kinaba
2011/10/27 23:07:20
Done.
| |
| 420 git_source_directory.add(dir_name) | |
| 421 dir_name = os.path.dirname(dir_name) | |
| 420 git_source_directory.add(root) | 422 git_source_directory.add(root) |
| 421 return git_source_directory | 423 return git_source_directory |
| 422 | 424 |
| 423 | 425 |
| 424 def PrintUsage(): | 426 def PrintUsage(): |
| 425 print """Usage: python checkdeps.py [--root <root>] [tocheck] | 427 print """Usage: python checkdeps.py [--root <root>] [tocheck] |
| 426 --root Specifies the repository root. This defaults to "../../.." relative | 428 --root Specifies the repository root. This defaults to "../../.." relative |
| 427 to the script file. This will be correct given the normal location | 429 to the script file. This will be correct given the normal location |
| 428 of the script in "<root>/tools/checkdeps". | 430 of the script in "<root>/tools/checkdeps". |
| 429 | 431 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 if '__main__' == __name__: | 490 if '__main__' == __name__: |
| 489 option_parser = optparse.OptionParser() | 491 option_parser = optparse.OptionParser() |
| 490 option_parser.add_option("", "--root", default="", dest="base_directory", | 492 option_parser.add_option("", "--root", default="", dest="base_directory", |
| 491 help='Specifies the repository root. This defaults ' | 493 help='Specifies the repository root. This defaults ' |
| 492 'to "../../.." relative to the script file, which ' | 494 'to "../../.." relative to the script file, which ' |
| 493 'will normally be the repository root.') | 495 'will normally be the repository root.') |
| 494 option_parser.add_option("-v", "--verbose", action="store_true", | 496 option_parser.add_option("-v", "--verbose", action="store_true", |
| 495 default=False, help="Print debug logging") | 497 default=False, help="Print debug logging") |
| 496 options, args = option_parser.parse_args() | 498 options, args = option_parser.parse_args() |
| 497 main(options, args) | 499 main(options, args) |
| OLD | NEW |