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

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

Issue 1386783003: [GN]: Support for loadable modules (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 # GN Language and Operation 1 # GN Language and Operation
2 2
3 [TOC] 3 [TOC]
4 4
5 ## Introduction 5 ## Introduction
6 6
7 This page describes many of the language details and behaviors. 7 This page describes many of the language details and behaviors.
8 8
9 ### Use the built-in help! 9 ### Use the built-in help!
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 There is no way to get the length of a list. If you find yourself 87 There is no way to get the length of a list. If you find yourself
88 wanting to do this kind of thing, you're trying to do too much work in 88 wanting to do this kind of thing, you're trying to do too much work in
89 the build. 89 the build.
90 90
91 Lists support appending: 91 Lists support appending:
92 92
93 ``` 93 ```
94 a = [ "first" ] 94 a = [ "first" ]
95 a += [ "second" ] # [ "first", "second" ] 95 a += [ "second" ] # [ "first", "second" ]
96 a += [ "third", "fourth" ] # [ "first", "second", "third", "fourth" ] 96 a += [ "third", "fourth" ] # [ "first", "second", "third", "fourth" ]
97 b = a + [ "fifth" ] # [ "first", "second", "third", "fourth", "fifth" ] 97 b = a + [ "fifth" ] # [ "first", "second", "third", "fourth", "fifth" ]
98 ``` 98 ```
99 99
100 Appending a list to another list appends the items in the second list 100 Appending a list to another list appends the items in the second list
101 rather than appending the list as a nested member. 101 rather than appending the list as a nested member.
102 102
103 You can remove items from a list: 103 You can remove items from a list:
104 104
105 ``` 105 ```
106 a = [ "first", "second", "third", "first" ] 106 a = [ "first", "second", "third", "first" ]
107 b = a - [ "first" ] # [ "second", "third" ] 107 b = a - [ "first" ] # [ "second", "third" ]
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 Conditionals look like C: 154 Conditionals look like C:
155 155
156 ``` 156 ```
157 if (is_linux || (is_win && target_cpu == "x86")) { 157 if (is_linux || (is_win && target_cpu == "x86")) {
158 sources -= [ "something.cc" ] 158 sources -= [ "something.cc" ]
159 } else if (...) { 159 } else if (...) {
160 ... 160 ...
161 } else { 161 } else {
162 ... 162 ...
163 } 163 }
164 ``` 164 ```
165 165
166 You can use them in most places, even around entire targets if the 166 You can use them in most places, even around entire targets if the
167 target should only be declared in certain circumstances. 167 target should only be declared in certain circumstances.
168 168
169 ### Functions 169 ### Functions
170 170
171 Simple functions look like most other languages: 171 Simple functions look like most other languages:
172 172
173 ``` 173 ```
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 other targets. The built-in target types (see `gn help <targettype>` for 369 other targets. The built-in target types (see `gn help <targettype>` for
370 more help) are: 370 more help) are:
371 371
372 * `action`: Run a script to generate a file. 372 * `action`: Run a script to generate a file.
373 * `action_foreach`: Run a script once for each source file. 373 * `action_foreach`: Run a script once for each source file.
374 * `component`: Configurable to be another type of library. 374 * `component`: Configurable to be another type of library.
375 * `executable`: Generates an executable file. 375 * `executable`: Generates an executable file.
376 * `group`: A virtual dependency node that refers to one or more other 376 * `group`: A virtual dependency node that refers to one or more other
377 targets. 377 targets.
378 * `shared_library`: A .dll or .so. 378 * `shared_library`: A .dll or .so.
379 * `loadable_module`: A .dll or .so loadable only at runtime.
379 * `source_set`: A lightweight virtual static library (usually 380 * `source_set`: A lightweight virtual static library (usually
380 preferrable over a real static library since it will build faster). 381 preferrable over a real static library since it will build faster).
381 * `static_library`: A .lib or .a file (normally you'll want a 382 * `static_library`: A .lib or .a file (normally you'll want a
382 source\_set instead). 383 `source_set` instead).
383 384
384 You can extend this to make custom target types using templates (see below). 385 You can extend this to make custom target types using templates (see below).
385 386
386 ## Configs 387 ## Configs
387 388
388 Configs are named objects that specify sets of flags, include 389 Configs are named objects that specify sets of flags, include
389 directories, and defines. They can be applied to a target and pushed to 390 directories, and defines. They can be applied to a target and pushed to
390 dependent targets. 391 dependent targets.
391 392
392 To define a config: 393 To define a config:
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 settings which work a bit differently in Blaze. This is partially to 726 settings which work a bit differently in Blaze. This is partially to
726 make conversion from the existing GYP code easier, and the GYP 727 make conversion from the existing GYP code easier, and the GYP
727 constructs generally offer more fine-grained control (which is either 728 constructs generally offer more fine-grained control (which is either
728 good or bad, depending on the situation). 729 good or bad, depending on the situation).
729 730
730 GN also uses GYP names like "sources" instead of "srcs" since 731 GN also uses GYP names like "sources" instead of "srcs" since
731 abbreviating this seems needlessly obscure, although it uses Blaze's 732 abbreviating this seems needlessly obscure, although it uses Blaze's
732 "deps" since "dependencies" is so hard to type. Chromium also compiles 733 "deps" since "dependencies" is so hard to type. Chromium also compiles
733 multiple languages in one target so specifying the language type on the 734 multiple languages in one target so specifying the language type on the
734 target name prefix was dropped (e.g. from `cc_library`). 735 target name prefix was dropped (e.g. from `cc_library`).
OLDNEW
« no previous file with comments | « tools/gn/docs/faq.md ('k') | tools/gn/docs/reference.md » ('j') | tools/gn/function_toolchain.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698