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