1cb93a386Sopenharmony_ci# DEPS Files
2cb93a386Sopenharmony_ci
3cb93a386Sopenharmony_ciDEPS files specify which files the sources in a directory tree may include.
4cb93a386Sopenharmony_ci
5cb93a386Sopenharmony_ci## File format
6cb93a386Sopenharmony_ci
7cb93a386Sopenharmony_ciFirst you have the normal module-level deps. These are the ones used by
8cb93a386Sopenharmony_cigclient. An example would be:
9cb93a386Sopenharmony_ci
10cb93a386Sopenharmony_ci```
11cb93a386Sopenharmony_cideps = {
12cb93a386Sopenharmony_ci  "base":"http://foo.bar/trunk/base"
13cb93a386Sopenharmony_ci}
14cb93a386Sopenharmony_ci```
15cb93a386Sopenharmony_ci
16cb93a386Sopenharmony_ciDEPS files not in the top-level of a module won't need this. Then you have any
17cb93a386Sopenharmony_ciadditional include rules. You can add (using `+`) or subtract (using `-`) from
18cb93a386Sopenharmony_cithe previously specified rules (including module-level deps). You can also
19cb93a386Sopenharmony_cispecify a path that is allowed for now but that we intend to remove, using `!`;
20cb93a386Sopenharmony_cithis is treated the same as `+` when `check_deps` is run by our bots, but a
21cb93a386Sopenharmony_cipresubmit step will show a warning if you add a new include of a file that is
22cb93a386Sopenharmony_cionly allowed by `!`.
23cb93a386Sopenharmony_ci
24cb93a386Sopenharmony_ciNote that for .java files, there is currently no difference between `+` and
25cb93a386Sopenharmony_ci`!`, even in the presubmit step.
26cb93a386Sopenharmony_ci
27cb93a386Sopenharmony_ci```
28cb93a386Sopenharmony_ciinclude_rules = [
29cb93a386Sopenharmony_ci  # Code should be able to use base (it's specified in the module-level
30cb93a386Sopenharmony_ci  # deps above), but nothing in "base/evil" because it's evil.
31cb93a386Sopenharmony_ci  "-base/evil",
32cb93a386Sopenharmony_ci
33cb93a386Sopenharmony_ci  # But this one subdirectory of evil is OK.
34cb93a386Sopenharmony_ci  "+base/evil/not",
35cb93a386Sopenharmony_ci
36cb93a386Sopenharmony_ci  # And it can include files from this other directory even though there is
37cb93a386Sopenharmony_ci  # no deps rule for it.
38cb93a386Sopenharmony_ci  "+tools/crime_fighter",
39cb93a386Sopenharmony_ci
40cb93a386Sopenharmony_ci  # This dependency is allowed for now but work is ongoing to remove it,
41cb93a386Sopenharmony_ci  # so you shouldn't add further dependencies on it.
42cb93a386Sopenharmony_ci  "!base/evil/ok_for_now.h",
43cb93a386Sopenharmony_ci]
44cb93a386Sopenharmony_ci```
45cb93a386Sopenharmony_ci
46cb93a386Sopenharmony_ciIf you have certain include rules that should only be applied for some files
47cb93a386Sopenharmony_ciwithin this directory and subdirectories, you can write a section named
48cb93a386Sopenharmony_ci`specific_include_rules` that is a hash map of regular expressions to the list
49cb93a386Sopenharmony_ciof rules that should apply to files matching them. Note that such rules will
50cb93a386Sopenharmony_cialways be applied before the rules from `include_rules` have been applied, but
51cb93a386Sopenharmony_cithe order in which rules associated with different regular expressions is
52cb93a386Sopenharmony_ciapplied is arbitrary.
53cb93a386Sopenharmony_ci
54cb93a386Sopenharmony_ci```
55cb93a386Sopenharmony_cispecific_include_rules = {
56cb93a386Sopenharmony_ci  ".*_(unit|browser|api)test\.cc": [
57cb93a386Sopenharmony_ci    "+libraries/testsupport",
58cb93a386Sopenharmony_ci  ],
59cb93a386Sopenharmony_ci}
60cb93a386Sopenharmony_ci```
61cb93a386Sopenharmony_ci
62cb93a386Sopenharmony_ciTo add different dependencies for Java instrumentation and unit tests, the
63cb93a386Sopenharmony_cifollowing regular expressions may be useful:
64cb93a386Sopenharmony_ci
65cb93a386Sopenharmony_ci```
66cb93a386Sopenharmony_cispecific_include_rules = {
67cb93a386Sopenharmony_ci  '.*UnitTest\.java': [
68cb93a386Sopenharmony_ci    # Rules for unit tests.
69cb93a386Sopenharmony_ci  ],
70cb93a386Sopenharmony_ci  '.*(?<!Unit)Test\.java': [
71cb93a386Sopenharmony_ci    # Rules for instrumentation tests.
72cb93a386Sopenharmony_ci  ],
73cb93a386Sopenharmony_ci}
74cb93a386Sopenharmony_ci```
75cb93a386Sopenharmony_ci
76cb93a386Sopenharmony_ciYou can optionally ignore the rules inherited from parent directories, similar
77cb93a386Sopenharmony_cito "set noparent" in OWNERS files. For example, adding `noparent = True` in
78cb93a386Sopenharmony_ci//ash/components/DEPS will cause rules from //ash/DEPS to be ignored, thereby
79cb93a386Sopenharmony_ciforcing each //ash/component/foo to explicitly declare foo's dependencies.
80cb93a386Sopenharmony_ci
81cb93a386Sopenharmony_ci```
82cb93a386Sopenharmony_cinoparent = True
83cb93a386Sopenharmony_ci```
84cb93a386Sopenharmony_ci
85cb93a386Sopenharmony_ci# Directory structure
86cb93a386Sopenharmony_ci
87cb93a386Sopenharmony_ciDEPS files may be placed anywhere in the tree. Each one applies to all
88cb93a386Sopenharmony_cisubdirectories, where there may be more DEPS files that provide additions or
89cb93a386Sopenharmony_cisubtractions for their own sub-trees.
90cb93a386Sopenharmony_ci
91cb93a386Sopenharmony_ciThere is an implicit rule for the current directory (where the DEPS file lives)
92cb93a386Sopenharmony_ciand all of its subdirectories. This prevents you from having to explicitly
93cb93a386Sopenharmony_ciallow the current directory everywhere. This implicit rule is applied first, so
94cb93a386Sopenharmony_ciyou can modify or remove it using the normal include rules.
95cb93a386Sopenharmony_ci
96cb93a386Sopenharmony_ciThe rules are processed in order. This means you can explicitly allow a higher
97cb93a386Sopenharmony_cidirectory and then take away permissions from sub-parts, or the reverse.
98cb93a386Sopenharmony_ci
99cb93a386Sopenharmony_ciNote that all directory separators must be `/` slashes (Unix-style) and not
100cb93a386Sopenharmony_cibackslashes. All directories should be relative to the source root and use
101cb93a386Sopenharmony_cionly lowercase.
102