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 # Add the directory as well as all the parent directories. |
| 420 while dir_name != root: |
| 421 git_source_directory.add(dir_name) |
| 422 dir_name = os.path.dirname(dir_name) |
420 git_source_directory.add(root) | 423 git_source_directory.add(root) |
421 return git_source_directory | 424 return git_source_directory |
422 | 425 |
423 | 426 |
424 def PrintUsage(): | 427 def PrintUsage(): |
425 print """Usage: python checkdeps.py [--root <root>] [tocheck] | 428 print """Usage: python checkdeps.py [--root <root>] [tocheck] |
426 --root Specifies the repository root. This defaults to "../../.." relative | 429 --root Specifies the repository root. This defaults to "../../.." relative |
427 to the script file. This will be correct given the normal location | 430 to the script file. This will be correct given the normal location |
428 of the script in "<root>/tools/checkdeps". | 431 of the script in "<root>/tools/checkdeps". |
429 | 432 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 if '__main__' == __name__: | 491 if '__main__' == __name__: |
489 option_parser = optparse.OptionParser() | 492 option_parser = optparse.OptionParser() |
490 option_parser.add_option("", "--root", default="", dest="base_directory", | 493 option_parser.add_option("", "--root", default="", dest="base_directory", |
491 help='Specifies the repository root. This defaults ' | 494 help='Specifies the repository root. This defaults ' |
492 'to "../../.." relative to the script file, which ' | 495 'to "../../.." relative to the script file, which ' |
493 'will normally be the repository root.') | 496 'will normally be the repository root.') |
494 option_parser.add_option("-v", "--verbose", action="store_true", | 497 option_parser.add_option("-v", "--verbose", action="store_true", |
495 default=False, help="Print debug logging") | 498 default=False, help="Print debug logging") |
496 options, args = option_parser.parse_args() | 499 options, args = option_parser.parse_args() |
497 main(options, args) | 500 main(options, args) |
OLD | NEW |