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

Side by Side Diff: tools/gn/docs/quick_start.md

Issue 1259763004: Clean up some typos in GN quick start page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove tutorial file Created 5 years, 4 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 | « no previous file | tools/gn/tutorial/say_hello.cc » ('j') | tools/gn/tutorial/say_hello.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # GN Quick Start guide 1 # GN Quick Start guide
2 2
3 [TOC] 3 [TOC]
4 4
5 ## Running GN 5 ## Running GN
6 6
7 You just run `gn` from the command line. There is a script in 7 You just run `gn` from the command line. There is a script in
8 depot\_tools (which is presumably on your path) with this name. The 8 depot\_tools (which is presumably on your path) with this name. The
9 script will find the binary in the source tree containing the current 9 script will find the binary in the source tree containing the current
10 directory and run it. 10 directory and run it.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 See [GNCrossCompiles](cross_compiles.md) for more info. 67 See [GNCrossCompiles](cross_compiles.md) for more info.
68 68
69 ## Configuring goma 69 ## Configuring goma
70 70
71 71
72 Run `gn args out/Default` (substituting your build directory as needed). 72 Run `gn args out/Default` (substituting your build directory as needed).
73 Add: 73 Add:
74 74
75 ``` 75 ```
76 use_goma = true 76 use_goma = true
77 goma_dir = "~/foo/bar/goma" 77 goma_dir = "~/foo/bar/goma"
78 ``` 78 ```
79 79
80 If your goma is in the default location (`~/goma`) then you can omit the 80 If your goma is in the default location (`~/goma`) then you can omit the
81 `goma_dir` line. 81 `goma_dir` line.
82 82
83 ## Configuring component mode 83 ## Configuring component mode
84 84
85 This is a build arg like the goma flags. run `gn args out/Default` and add: 85 This is a build arg like the goma flags. run `gn args out/Default` and add:
86 86
87 ``` 87 ```
(...skipping 10 matching lines...) Expand all
98 executable("hello_world") { 98 executable("hello_world") {
99 sources = [ 99 sources = [
100 "hello_world.cc", 100 "hello_world.cc",
101 ] 101 ]
102 } 102 }
103 ``` 103 ```
104 104
105 There should already be a `hello_world.cc` file in that directory, 105 There should already be a `hello_world.cc` file in that directory,
106 containing what you expect. That's it! Now we just need to tell the 106 containing what you expect. That's it! Now we just need to tell the
107 build about this file. Open the `BUILD.gn` file in the root directory 107 build about this file. Open the `BUILD.gn` file in the root directory
108 and add the label of this target to the dependencies of the root group 108 and add the label of this target to the dependencies of one of the root
109 (a "group" target is a meta-target that is just a collection of other 109 groups (a "group" target is a meta-target that is just a collection of
110 targets): 110 other targets):
111 111
112 ``` 112 ```
113 group("root") { 113 group("root") {
114 deps = [ 114 deps = [
115 ... 115 ...
116 "//url", 116 "//url",
117 "//tools/gn/tutorial:hello_world", 117 "//tools/gn/tutorial:hello_world",
118 ] 118 ]
119 } 119 }
120 ``` 120 ```
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 executable("say_hello") { 161 executable("say_hello") {
162 sources = [ 162 sources = [
163 "say_hello.cc", 163 "say_hello.cc",
164 ] 164 ]
165 deps = [ 165 deps = [
166 ":hello", 166 ":hello",
167 ] 167 ]
168 } 168 }
169 ``` 169 ```
170 170
171 This executable includes one source file,and depends on the previous 171 This executable includes one source file and depends on the previous
172 static library. The static library is referenced by its label in the 172 static library. The static library is referenced by its label in the
173 `deps`. You could have used the full label `//tools/gn/tutorial:hello` 173 `deps`. You could have used the full label `//tools/gn/tutorial:hello`
174 but if you're referencing a target in the same build file, you can use 174 but if you're referencing a target in the same build file, you can use
175 the shortcut `:hello`. 175 the shortcut `:hello`.
176 176
177 ### Test the static library version 177 ### Test the static library version
178 178
179 From the command line in the source root directory: 179 From the command line in the source root directory:
180 180
181 ``` 181 ```
182 ninja -C out/Default say_hello 182 ninja -C out/Default say_hello
183 out/Default/say_hello 183 out/Default/say_hello
184 ``` 184 ```
185 185
186 Note that you **didn't** need to re-run GN.GN will automatically rebuild 186 Note that you **didn't** need to re-run GN. GN will automatically rebuild
187 the ninja files when any build file has changed. You know this happens 187 the ninja files when any build file has changed. You know this happens
188 when ninja prints `[1/1] Regenerating ninja files` at the beginning of 188 when ninja prints `[1/1] Regenerating ninja files` at the beginning of
189 execution. 189 execution.
190 190
191 ### Compiler settings 191 ### Compiler settings
192 192
193 Our hello library has a new feature, the ability to say hello to two 193 Our hello library has a new feature, the ability to say hello to two
194 people at once. This feature is controlled by defining `TWO_PEOPLE`. We 194 people at once. This feature is controlled by defining `TWO_PEOPLE`. We
195 can add defines like so: 195 can add defines like so:
196 196
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 depend on your target (not transitively). 268 depend on your target (not transitively).
269 269
270 Now if you compile and run, you'll see the new version with two people: 270 Now if you compile and run, you'll see the new version with two people:
271 271
272 ``` 272 ```
273 > ninja -C out/Default say_hello 273 > ninja -C out/Default say_hello
274 ninja: Entering directory 'out/Default' 274 ninja: Entering directory 'out/Default'
275 [1/1] Regenerating ninja files 275 [1/1] Regenerating ninja files
276 [4/4] LINK say_hello 276 [4/4] LINK say_hello
277 > out/Default/say_hello 277 > out/Default/say_hello
278 Hello, Bill and Ted. 278 Hello, Bill and Joy.
279 ``` 279 ```
280 280
281 ## Don't know what's going on? 281 ## Don't know what's going on?
282 282
283 You can run GN in verbose mode to see lots of messages about what it's 283 You can run GN in verbose mode to see lots of messages about what it's
284 doing. Use `-v` for this. 284 doing. Use `-v` for this.
285 285
286 ### Print debugging 286 ### Print debugging
287 287
288 There is a `print` command which just writes to stdout: 288 There is a `print` command which just writes to stdout:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 line flag. This will output a summary of timings for various things. 336 line flag. This will output a summary of timings for various things.
337 337
338 You can also make a trace of how the build files were executed: 338 You can also make a trace of how the build files were executed:
339 339
340 ``` 340 ```
341 gn --tracelog=mylog.trace 341 gn --tracelog=mylog.trace
342 ``` 342 ```
343 343
344 and you can load the resulting file in Chrome's `about:tracing` page to 344 and you can load the resulting file in Chrome's `about:tracing` page to
345 look at everything. 345 look at everything.
OLDNEW
« no previous file with comments | « no previous file | tools/gn/tutorial/say_hello.cc » ('j') | tools/gn/tutorial/say_hello.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698