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

Side by Side Diff: docs/gn_check.md

Issue 1309473002: WIP: Migrate Wiki content over to src/docs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « docs/git_tips.md ('k') | docs/graphical_debugging_aid_chromium_views.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 GN has several different ways to check dependencies. Many of them are checked by the `gn check` command. Running checks involve opening and scanning all source files so this isn't run every time a build is updated. To run check on an existi ng build:
2 ```
3 gn check out/mybuild
4 ```
5
6 To run the check as part of the "gen" command to update the build (this is what the bots do):
7 ```
8 gn gen out/mybuild --check
9 ```
10
11 # Concepts
12
13 ## Visibility
14
15 Targets can control which other targets may depend on them by specifying `visibi lity`. Visibility is always checked when running any GN command (not just `gn ch eck`.
16
17 By default, targets are "public" meaning any target can depend on them. If you s upply a list, visibility will be listed to those targets (possibly including wil dcards):
18
19 ```
20 visibility = [
21 ":*", # All targets in this file.
22 "//content/*", # All targets in content and any subdirectory thereof.
23 "//tools:doom_melon", # This specific target.
24 ]
25 ```
26
27 See `gn help visibility` for more details and examples.
28
29 ## Public header files
30
31 Targets can control which headers may be included by dependent targets so as to define a public API. If your target specifies only `sources`, then all headers l isted there are public and can be included by all dependents.
32
33 If your target defines a `public` variable, only the files listed in that list w ill be public. Files in `sources` but not `public` (they can be in both or only one) may not be included by dependent targets.
34
35 ```
36 source_set("foo") {
37 public = [
38 "foo.h",
39 "foo_config.h",
40 ]
41 sources = [
42 "foo.cc",
43 "foo.h",
44 "bar.cc",
45 "bar.h",
46 ]
47 }
48 ```
49
50 ## Public dependencies
51
52 In order to include files from your target, that target must be listed in your t arget's dependencies. By default, transitively depending on a target doesn't giv e your files this privilege.
53
54 If a target exposes a dependency as part of its public API, then it can list tha t dependency as a `public_deps`:
55 ```
56 source_set("foo") {
57 sources = [ ... ]
58 public_deps = [
59 "//base",
60 ]
61 deps = [
62 "//tools/doom_melon",
63 ]
64 }
65 ```
66 Targets that depend on `foo` can include files from `base` but not from `doom_me lon`. To include public headers from `doom\_melon, a target would need to depend directly on it.
67
68 Public dependencies work transitively, so listing a target as a public dependenc y also exposes that target's public dependencies. Along with the ability to incl ude headers, public dependencies forward the `public_configs` which allow settin gs like defines and include directories to apply to dependents.
69
70 # Putting it all together
71
72 In order to include a header from target Y in a file that is part of target X:
73
74 * X must be in Y's `visibility` list (or B must have no `visibility` defined).
75 * The header must be in Y's `public` headers (or Y must have no `public` varia ble defined).
76 * X must depend directly on Y, or there must be a path from X to Y following o nly public dependencies.
77
78 ### What gets checked
79
80 Chrome currently doesn't come close to passing a `gn check` pass. You can check specific targets or subtrees for issues:
81 ```
82 gn check out/mybuild //base
83
84 gn check out/mybuild "//mojo/*"
85 ```
OLDNEW
« no previous file with comments | « docs/git_tips.md ('k') | docs/graphical_debugging_aid_chromium_views.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698