OLD | NEW |
---|---|
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 sources = [ | 259 sources = [ |
260 "hello.cc", | 260 "hello.cc", |
261 ] | 261 ] |
262 all_dependent_configs = [ | 262 all_dependent_configs = [ |
263 ":hello_config" | 263 ":hello_config" |
264 ] | 264 ] |
265 } | 265 } |
266 ``` | 266 ``` |
267 | 267 |
268 This applies the `hello_config` to the `hello` target itself, plus all | 268 This applies the `hello_config` to the `hello` target itself, plus all |
269 targets that depend on transitively depend on the current one. Now | 269 targets that transitively depend on the current one. Now everybody that |
270 everybody that depends on us will get our settings. You can also set | 270 depends on us will get our settings. You can also set `public_configs` |
271 `public_configs` which applies only to targets that directly | 271 which applies only to targets that directly depend on your target (not |
272 depend on your target (not transitively). | 272 transitively). |
273 | 273 |
274 Now if you compile and run, you'll see the new version with two people: | 274 Now if you compile and run, you'll see the new version with two people: |
275 | 275 |
276 ``` | 276 ``` |
277 > ninja -C out/Default say_hello | 277 > ninja -C out/Default say_hello |
278 ninja: Entering directory 'out/Default' | 278 ninja: Entering directory 'out/Default' |
279 [1/1] Regenerating ninja files | 279 [1/1] Regenerating ninja files |
280 [4/4] LINK say_hello | 280 [4/4] LINK say_hello |
281 > out/Default/say_hello | 281 > out/Default/say_hello |
282 Hello, Bill and Joy. | 282 Hello, Bill and Joy. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 | 316 |
317 ``` | 317 ``` |
318 > gn desc out/Default //tools/gn/tutorial:say_hello defines --blame | 318 > gn desc out/Default //tools/gn/tutorial:say_hello defines --blame |
319 ...lots of other stuff omitted... | 319 ...lots of other stuff omitted... |
320 From //tools/gn/tutorial:hello_config | 320 From //tools/gn/tutorial:hello_config |
321 (Added by //tools/gn/tutorial/BUILD.gn:12) | 321 (Added by //tools/gn/tutorial/BUILD.gn:12) |
322 TWO_PEOPLE | 322 TWO_PEOPLE |
323 ``` | 323 ``` |
324 | 324 |
325 You can see that `TWO_PEOPLE` was defined by a config, and you can also | 325 You can see that `TWO_PEOPLE` was defined by a config, and you can also |
326 see the which like caused that config to be applied to your target (in | 326 see the which line caused that config to be applied to your target (in |
brettw
2016/01/19 23:59:46
"see the which line"? Looks like we still have som
Michael Achenbach
2016/01/20 07:50:10
Doh. The human brain is a weird thing. I probably
| |
327 this case, the `all_dependent_configs` line). | 327 this case, the `all_dependent_configs` line). |
328 | 328 |
329 Another particularly interesting variation: | 329 Another particularly interesting variation: |
330 | 330 |
331 ``` | 331 ``` |
332 gn desc out/Default //base:base_i18n deps --tree | 332 gn desc out/Default //base:base_i18n deps --tree |
333 ``` | 333 ``` |
334 | 334 |
335 See `gn help desc` for more. | 335 See `gn help desc` for more. |
336 | 336 |
337 ### Performance | 337 ### Performance |
338 | 338 |
339 You can see what took a long time by running it with the --time command | 339 You can see what took a long time by running it with the --time command |
340 line flag. This will output a summary of timings for various things. | 340 line flag. This will output a summary of timings for various things. |
341 | 341 |
342 You can also make a trace of how the build files were executed: | 342 You can also make a trace of how the build files were executed: |
343 | 343 |
344 ``` | 344 ``` |
345 gn --tracelog=mylog.trace | 345 gn --tracelog=mylog.trace |
346 ``` | 346 ``` |
347 | 347 |
348 and you can load the resulting file in Chrome's `about:tracing` page to | 348 and you can load the resulting file in Chrome's `about:tracing` page to |
349 look at everything. | 349 look at everything. |
OLD | NEW |