OLD | NEW |
| (Empty) |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 # ============================================================================= | |
6 # BUILD FLAGS | |
7 # ============================================================================= | |
8 # | |
9 # This block lists input arguments to the build, along with their default | |
10 # values. GN requires listing them explicitly so it can validate input and have | |
11 # a central place to manage the build flags. | |
12 # | |
13 # If a value is specified on the command line, it will overwrite the defaults | |
14 # given here, otherwise the default will be injected into the root scope. | |
15 # | |
16 # KEEP IN ALPHABETICAL ORDER and write a good description for everything. | |
17 # Use "is_*" names for intrinsic platform descriptions and build modes, and | |
18 # "use_*" names for optional features libraries, and configurations. | |
19 declare_args() { | |
20 # How many symbols to include in the build. This affects the performance of | |
21 # the build since the symbols are large and dealing with them is slow. | |
22 # 2 means regular build with symbols. | |
23 # 1 means minimal symbols, usually enough for backtraces only. | |
24 # 0 means no symbols. | |
25 symbol_level = 2 | |
26 | |
27 # Component build. | |
28 is_component_build = false | |
29 # Debug build. | |
30 is_debug = true | |
31 | |
32 # Set to true when compiling with the Clang compiler. Typically this is used | |
33 # to configure warnings. | |
34 is_clang = false | |
35 | |
36 # ASH is enabled. | |
37 # TODO(brettw) this should be moved out of the main build config file. | |
38 use_ash = false | |
39 # Aura is enabled. | |
40 # TODO(brettw) this should be moved out of the main build config file. | |
41 use_aura = false | |
42 # Ozone is enabled. | |
43 # TODO(brettw) this should be moved out of the main build config file. | |
44 use_ozone = false | |
45 | |
46 # Set to true on the command line when invoked by GYP. Build files can key | |
47 # off of this to make any GYP-output-specific changes to the build. | |
48 is_gyp = false | |
49 } | |
50 | |
51 # ============================================================================= | |
52 # OS DEFINITIONS | |
53 # ============================================================================= | |
54 # | |
55 # We set these various is_FOO booleans for convenience in writing OS-based | |
56 # conditions. | |
57 # | |
58 # - is_android, is_chromeos, is_ios, and is_win should be obvious. | |
59 # - is_mac is set only for desktop Mac. It is not set on iOS. | |
60 # - is_posix is true for mac and any Unix-like system (basically everything | |
61 # except Windows). | |
62 # - is_linux is true for any Linux variant including Android and ChromeOS. | |
63 # | |
64 # Do not add more is_* variants here for random lesser-used Unix systems like | |
65 # aix or one of the BSDs. If you need to check these, just check the os value | |
66 # directly. | |
67 | |
68 if (os == "win") { | |
69 is_android = false | |
70 is_chromeos = false | |
71 is_ios = false | |
72 is_linux = false | |
73 is_mac = false | |
74 is_nacl = false | |
75 is_posix = false | |
76 is_win = true | |
77 } else if (os == "mac") { | |
78 is_android = false | |
79 is_chromeos = false | |
80 is_ios = false | |
81 is_linux = false | |
82 is_mac = true | |
83 is_nacl = false | |
84 is_posix = true | |
85 is_win = false | |
86 is_clang = true # Always use clang on Mac. | |
87 } else if (os == "android") { | |
88 is_android = false | |
89 is_chromeos = false | |
90 is_ios = false | |
91 is_linux = true | |
92 is_mac = false | |
93 is_nacl = false | |
94 is_posix = true | |
95 is_win = false | |
96 } else if (os == "chromeos") { | |
97 is_android = false | |
98 is_chromeos = true | |
99 is_ios = false | |
100 is_linux = true | |
101 is_mac = false | |
102 is_nacl = false | |
103 is_posix = true | |
104 is_win = false | |
105 } else if (os == "nacl") { | |
106 # os == "nacl" will be passed by the nacl toolchain definition. It is not | |
107 # set by default or on the command line. We treat is as a Posix variant. | |
108 is_android = false | |
109 is_chromeos = false | |
110 is_ios = false | |
111 is_linux = false | |
112 is_mac = false | |
113 is_nacl = true | |
114 is_posix = true | |
115 is_win = false | |
116 } else if (os == "ios") { | |
117 is_android = false | |
118 is_chromeos = false | |
119 is_ios = true | |
120 is_linux = false | |
121 is_mac = false | |
122 is_nacl = false | |
123 is_posix = true | |
124 is_win = false | |
125 } else if (os == "linux") { | |
126 is_android = false | |
127 is_chromeos = false | |
128 is_ios = false | |
129 is_linux = true | |
130 is_mac = false | |
131 is_nacl = false | |
132 is_posix = true | |
133 is_win = false | |
134 } | |
135 | |
136 # ============================================================================= | |
137 # CPU ARCHITECTURE | |
138 # ============================================================================= | |
139 | |
140 if (is_win) { | |
141 # Always use 32-bit on Windows, even when compiling on a 64-bit host OS. | |
142 # TODO(brettw) when we support 64-bit cross-compiles, we probably need to | |
143 # set a build arg in the toolchain to disable this override. | |
144 cpu_arch = "ia32" | |
145 } | |
146 | |
147 # ============================================================================= | |
148 # SOURCES FILTERS | |
149 # ============================================================================= | |
150 # | |
151 # These patterns filter out platform-specific files when assigning to the | |
152 # sources variable. The magic variable |sources_assignment_filter| is applied | |
153 # to each assignment or appending to the sources variable and matches are | |
154 # automatcally removed. | |
155 # | |
156 # We define lists of filters for each platform for all builds so they can | |
157 # be used by individual targets if necessary (a target can always change | |
158 # sources_assignment_filter on itself if it needs something more specific). | |
159 # | |
160 # Note that the patterns are NOT regular expressions. Only "*" and "\b" (path | |
161 # boundary = end of string or slash) are supported, and the entire string | |
162 # muct match the pattern (so you need "*.cc" to match all .cc files, for | |
163 # example). | |
164 | |
165 windows_sources_filters = [ | |
166 "*_win.cc", | |
167 "*_win.h", | |
168 "*_win_unittest.cc", | |
169 "*\bwin/*", | |
170 ] | |
171 mac_sources_filters = [ | |
172 "*_mac.h", | |
173 "*_mac.cc", | |
174 "*_mac.mm", | |
175 "*_mac_unittest.h", | |
176 "*_mac_unittest.cc", | |
177 "*_mac_unittest.mm", | |
178 "*\bmac/*", | |
179 "*_cocoa.h", | |
180 "*_cocoa.cc", | |
181 "*_cocoa.mm", | |
182 "*_cocoa_unittest.h", | |
183 "*_cocoa_unittest.cc", | |
184 "*_cocoa_unittest.mm", | |
185 "*\bcocoa/*", | |
186 ] | |
187 ios_sources_filters = [ | |
188 "*_ios.h", | |
189 "*_ios.cc", | |
190 "*_ios.mm", | |
191 "*_ios_unittest.h", | |
192 "*_ios_unittest.cc", | |
193 "*_ios_unittest.mm", | |
194 "*\bios/*", | |
195 ] | |
196 objective_c_sources_filters = [ | |
197 "*.mm", | |
198 ] | |
199 linux_sources_filters = [ | |
200 "*_linux.h", | |
201 "*_linux.cc", | |
202 "*_linux_unittest.h", | |
203 "*_linux_unittest.cc", | |
204 "*\blinux/*", | |
205 "*_x11.cc", | |
206 "*_x11.h", | |
207 ] | |
208 android_sources_filters = [ | |
209 "*_android.h", | |
210 "*_android.cc", | |
211 "*_android_unittest.h", | |
212 "*_android_unittest.cc", | |
213 "*\bandroid/*", | |
214 ] | |
215 posix_sources_filters = [ | |
216 "*_posix.h", | |
217 "*_posix.cc", | |
218 "*_posix_unittest.h", | |
219 "*_posix_unittest.cc", | |
220 "*\bposix/*", | |
221 ] | |
222 | |
223 # Construct the full list of sources we're using for this platform. | |
224 sources_assignment_filter = [] | |
225 if (is_win) { | |
226 sources_assignment_filter += posix_sources_filters | |
227 } else { | |
228 sources_assignment_filter += windows_sources_filters | |
229 } | |
230 if (!is_mac) { | |
231 sources_assignment_filter += mac_sources_filters | |
232 } | |
233 if (!is_ios) { | |
234 sources_assignment_filter += ios_sources_filters | |
235 } | |
236 if (!is_mac && !is_ios) { | |
237 sources_assignment_filter += objective_c_sources_filters | |
238 } | |
239 if (!is_linux) { | |
240 sources_assignment_filter += linux_sources_filters | |
241 } | |
242 if (!is_android) { | |
243 sources_assignment_filter += android_sources_filters | |
244 } | |
245 | |
246 # This is the actual set. | |
247 set_sources_assignment_filter(sources_assignment_filter) | |
248 | |
249 # ============================================================================= | |
250 # BUILD OPTIONS | |
251 # ============================================================================= | |
252 | |
253 if (is_component_build) { | |
254 component_mode = "shared_library" | |
255 } else { | |
256 component_mode = "static_library" | |
257 } | |
258 | |
259 toolkit_uses_gtk = is_linux | |
260 | |
261 # ============================================================================= | |
262 # TARGET DEFAULTS | |
263 # ============================================================================= | |
264 # | |
265 # Set up the default configuration for every build target of the given type. | |
266 # The values configured here will be automatically set on the scope of the | |
267 # corresponding target. Target definitions can add or remove to the settings | |
268 # here as needed. | |
269 | |
270 # Holds all configs used for making native executables and libraries, to avoid | |
271 # duplication in each target below. | |
272 native_compiler_configs = [ | |
273 "//build/config:my_msvs", # TODO(brettw) eraseme | |
274 | |
275 "//build/config/compiler:compiler", | |
276 "//build/config/compiler:chromium_code", | |
277 "//build/config/compiler:default_warnings", | |
278 "//build/config/compiler:no_rtti", | |
279 "//build/config/compiler:runtime_library", | |
280 ] | |
281 if (is_win) { | |
282 native_compiler_configs += [ | |
283 "//build/config/win:sdk", | |
284 ] | |
285 } else if (is_clang) { | |
286 native_compiler_configs += "//build/config/clang:find_bad_constructs" | |
287 } | |
288 | |
289 # Optimizations and debug checking. | |
290 if (is_debug) { | |
291 native_compiler_configs += "//build/config:debug" | |
292 default_optimization_config = "//build/config/compiler:no_optimize" | |
293 } else { | |
294 native_compiler_configs += "//build/config:release" | |
295 default_optimization_config = "//build/config/compiler:optimize" | |
296 } | |
297 native_compiler_configs += default_optimization_config | |
298 | |
299 # Symbol setup. | |
300 if (is_clang && (is_linux || is_android)) { | |
301 # Clang creates chubby debug information, which makes linking very slow. | |
302 # For now, don't create debug information with clang. | |
303 # See http://crbug.com/70000 | |
304 # TODO(brettw) This just copies GYP. Why not do this on Mac as well? | |
305 default_symbols_config = "//build/config/compiler:no_symbols" | |
306 } else if (symbol_level == 2) { | |
307 default_symbols_config = "//build/config/compiler:symbols" | |
308 } else if (symbol_level == 1) { | |
309 default_symbols_config = "//build/config/compiler:minimal_symbols" | |
310 } else if (symbol_level == 0) { | |
311 default_symbols_config = "//build/config/compiler:no_symbols" | |
312 } else { | |
313 assert(false, "Bad value for symbol_level.") | |
314 } | |
315 native_compiler_configs += default_symbols_config | |
316 | |
317 # Windows linker setup for EXEs and DLLs. | |
318 if (is_win) { | |
319 if (is_debug) { | |
320 default_incremental_linking_config = | |
321 "//build/config/win:incremental_linking" | |
322 } else { | |
323 default_incremental_linking_config = | |
324 "//build/config/win:no_incremental_linking" | |
325 } | |
326 windows_linker_configs = [ | |
327 default_incremental_linking_config, | |
328 "//build/config/win:sdk_link", | |
329 "//build/config/win:common_linker_setup", | |
330 # Default to console-mode apps. Most of our targets are tests and such | |
331 # that shouldn't use the windows subsystem. | |
332 "//build/config/win:console", | |
333 ] | |
334 } | |
335 | |
336 set_defaults("executable") { | |
337 configs = native_compiler_configs | |
338 if (is_win) { | |
339 configs += windows_linker_configs | |
340 } else if (is_mac) { | |
341 configs += "//build/config/mac:mac_dynamic_flags" | |
342 } else if (is_linux) { | |
343 configs += "//build/config/linux:executable_ldconfig" | |
344 } | |
345 } | |
346 | |
347 set_defaults("static_library") { | |
348 configs = native_compiler_configs | |
349 } | |
350 | |
351 set_defaults("shared_library") { | |
352 configs = native_compiler_configs | |
353 if (is_win) { | |
354 configs += windows_linker_configs | |
355 } else if (is_mac) { | |
356 configs += "//build/config/mac:mac_dynamic_flags" | |
357 } | |
358 } | |
359 | |
360 set_defaults("source_set") { | |
361 configs = native_compiler_configs | |
362 } | |
363 | |
364 # ============================================================================== | |
365 # TOOLCHAIN SETUP | |
366 # ============================================================================== | |
367 # | |
368 # Here we set the default toolchain, as well as the variable host_toolchain | |
369 # which will identify the toolchain corresponding to the local system when | |
370 # doing cross-compiles. When not cross-compiling, this will be the same as the | |
371 # default toolchain. | |
372 | |
373 if (is_win) { | |
374 host_toolchain = "//build/toolchain/win:32" | |
375 set_default_toolchain(host_toolchain) | |
376 } else if (is_linux) { | |
377 host_toolchain = "//build/toolchain/linux:host" | |
378 if (cpu_arch == "arm" && build_cpu_arch != "arm") { | |
379 # Special toolchain for ARM cross-compiling. | |
380 set_default_toolchain("//build/toolchain/linux:arm-cross-compile") | |
381 } else { | |
382 # Use whatever GCC is on the current platform. | |
383 set_default_toolchain(host_toolchain) | |
384 } | |
385 } else if (is_mac) { | |
386 host_toolchain = "//build/toolchain/mac:clang" | |
387 set_default_toolchain(host_toolchain) | |
388 } | |
OLD | NEW |