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

Side by Side Diff: checkdeps/builddeps.py

Issue 2799113002: Move DEPS file docs into a README.md (Closed)
Patch Set: wording Created 3 years, 8 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 | « checkdeps/README.md ('k') | checkdeps/checkdeps.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 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 """Traverses the source tree, parses all found DEPS files, and constructs 6 """Traverses the source tree, parses all found DEPS files, and constructs
7 a dependency rule table to be used by subclasses. 7 a dependency rule table to be used by subclasses.
8 8
9 The format of the deps file: 9 See README.md for the format of the deps file.
10
11 First you have the normal module-level deps. These are the ones used by
12 gclient. An example would be:
13
14 deps = {
15 "base":"http://foo.bar/trunk/base"
16 }
17
18 DEPS files not in the top-level of a module won't need this. Then you
19 have any additional include rules. You can add (using "+") or subtract
20 (using "-") from the previously specified rules (including
21 module-level deps). You can also specify a path that is allowed for
22 now but that we intend to remove, using "!"; this is treated the same
23 as "+" when check_deps is run by our bots, but a presubmit step will
24 show a warning if you add a new include of a file that is only allowed
25 by "!".
26
27 Note that for .java files, there is currently no difference between
28 "+" and "!", even in the presubmit step.
29
30 include_rules = [
31 # Code should be able to use base (it's specified in the module-level
32 # deps above), but nothing in "base/evil" because it's evil.
33 "-base/evil",
34
35 # But this one subdirectory of evil is OK.
36 "+base/evil/not",
37
38 # And it can include files from this other directory even though there is
39 # no deps rule for it.
40 "+tools/crime_fighter",
41
42 # This dependency is allowed for now but work is ongoing to remove it,
43 # so you shouldn't add further dependencies on it.
44 "!base/evil/ok_for_now.h",
45 ]
46
47 If you have certain include rules that should only be applied for some
48 files within this directory and subdirectories, you can write a
49 section named specific_include_rules that is a hash map of regular
50 expressions to the list of rules that should apply to files matching
51 them. Note that such rules will always be applied before the rules
52 from 'include_rules' have been applied, but the order in which rules
53 associated with different regular expressions is applied is arbitrary.
54
55 specific_include_rules = {
56 ".*_(unit|browser|api)test\.cc": [
57 "+libraries/testsupport",
58 ],
59 }
60
61 DEPS files may be placed anywhere in the tree. Each one applies to all
62 subdirectories, where there may be more DEPS files that provide additions or
63 subtractions for their own sub-trees.
64
65 There is an implicit rule for the current directory (where the DEPS file lives)
66 and all of its subdirectories. This prevents you from having to explicitly
67 allow the current directory everywhere. This implicit rule is applied first,
68 so you can modify or remove it using the normal include rules.
69
70 The rules are processed in order. This means you can explicitly allow a higher
71 directory and then take away permissions from sub-parts, or the reverse.
72
73 Note that all directory separators must be slashes (Unix-style) and not
74 backslashes. All directories should be relative to the source root and use
75 only lowercase.
76 """ 10 """
77 11
78 import copy 12 import copy
79 import os.path 13 import os.path
80 import posixpath 14 import posixpath
81 import subprocess 15 import subprocess
82 16
83 from rules import Rule, Rules 17 from rules import Rule, Rules
84 18
85 19
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 if dir_path_norm in self.directory_rules: 358 if dir_path_norm in self.directory_rules:
425 return self.directory_rules[dir_path_norm] 359 return self.directory_rules[dir_path_norm]
426 360
427 if parent_rules: 361 if parent_rules:
428 self._ApplyDirectoryRulesAndSkipSubdirs(parent_rules, dir_path_local_abs) 362 self._ApplyDirectoryRulesAndSkipSubdirs(parent_rules, dir_path_local_abs)
429 else: 363 else:
430 # If the parent directory should be skipped, then the current 364 # If the parent directory should be skipped, then the current
431 # directory should also be skipped. 365 # directory should also be skipped.
432 self.directory_rules[dir_path_norm] = None 366 self.directory_rules[dir_path_norm] = None
433 return self.directory_rules[dir_path_norm] 367 return self.directory_rules[dir_path_norm]
OLDNEW
« no previous file with comments | « checkdeps/README.md ('k') | checkdeps/checkdeps.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698