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.
5 # =============================================================================
7 # =============================================================================
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.
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.
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.
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.
28 is_component_build = false
32 # Set to true when compiling with the Clang compiler. Typically this is used
33 # to configure warnings.
37 # TODO(brettw) this should be moved out of the main build config file.
40 # TODO(brettw) this should be moved out of the main build config file.
43 # TODO(brettw) this should be moved out of the main build config file.
46 # Forces a 64-bit build on Windows. Does nothing on other platforms. Normally
47 # we build 32-bit on Windows regardless of the current host OS bit depth.
48 # Setting this flag will override this logic and generate 64-bit toolchains.
50 # Normally this would get set automatically when you specify a target using
51 # the 64-bit toolchain. You can also set this on the command line to convert
52 # the default toolchain to 64-bit.
55 # Set to true on the command line when invoked by GYP. Build files can key
56 # off of this to make any GYP-output-specific changes to the build.
59 # Selects the desired build flavor. Official builds get additional
60 # processing to prepare for release. Normally you will want to develop and
61 # test with this flag off.
62 is_official_build = false
64 # Select the desired branding flavor. False means normal Chromium branding,
65 # true means official Google Chrome branding (requires extra Google-internal
67 is_chrome_branded = false
69 # Compile for Address Sanitizer to find memory bugs.
72 # Compile for Leak Sanitizer to find leaks.
75 # Compile for Memory Sanitizer to find uninitialized reads.
78 # Compile for Thread Sanitizer to find threading bugs.
81 # When running in gyp-generating mode, this is the root of the build tree.
82 gyp_output_dir = "out"
85 # =============================================================================
87 # =============================================================================
89 # We set these various is_FOO booleans for convenience in writing OS-based
92 # - is_android, is_chromeos, is_ios, and is_win should be obvious.
93 # - is_mac is set only for desktop Mac. It is not set on iOS.
94 # - is_posix is true for mac and any Unix-like system (basically everything
96 # - is_linux is true for any Linux variant including Android and ChromeOS.
98 # Do not add more is_* variants here for random lesser-used Unix systems like
99 # aix or one of the BSDs. If you need to check these, just check the os value
112 # Windows currelty implies Aura.
114 } else if (os == "mac") {
124 is_clang = true # Always use clang on Mac.
126 } else if (os == "android") {
135 } else if (os == "chromeos") {
144 } else if (os == "nacl") {
145 # os == "nacl" will be passed by the nacl toolchain definition. It is not
146 # set by default or on the command line. We treat is as a Posix variant.
155 } else if (os == "ios") {
165 # Always use clang on iOS when using ninja
166 # (which is always true when using GN).
169 } else if (os == "linux") {
180 # =============================================================================
182 # =============================================================================
185 # Always use 32-bit on Windows, even when compiling on a 64-bit host OS,
186 # unless the override flag is specified.
194 # =============================================================================
196 # =============================================================================
198 # These patterns filter out platform-specific files when assigning to the
199 # sources variable. The magic variable |sources_assignment_filter| is applied
200 # to each assignment or appending to the sources variable and matches are
201 # automatcally removed.
203 # We define lists of filters for each platform for all builds so they can
204 # be used by individual targets if necessary (a target can always change
205 # sources_assignment_filter on itself if it needs something more specific).
207 # Note that the patterns are NOT regular expressions. Only "*" and "\b" (path
208 # boundary = end of string or slash) are supported, and the entire string
209 # muct match the pattern (so you need "*.cc" to match all .cc files, for
212 windows_sources_filters = [
218 mac_sources_filters = [
229 "*_cocoa_unittest.h",
230 "*_cocoa_unittest.cc",
231 "*_cocoa_unittest.mm",
234 ios_sources_filters = [
243 objective_c_sources_filters = [
246 linux_sources_filters = [
249 "*_linux_unittest.h",
250 "*_linux_unittest.cc",
255 android_sources_filters = [
258 "*_android_unittest.h",
259 "*_android_unittest.cc",
262 posix_sources_filters = [
265 "*_posix_unittest.h",
266 "*_posix_unittest.cc",
270 # Construct the full list of sources we're using for this platform.
271 sources_assignment_filter = []
273 sources_assignment_filter += posix_sources_filters
275 sources_assignment_filter += windows_sources_filters
278 sources_assignment_filter += mac_sources_filters
281 sources_assignment_filter += ios_sources_filters
283 if (!is_mac && !is_ios) {
284 sources_assignment_filter += objective_c_sources_filters
287 sources_assignment_filter += linux_sources_filters
290 sources_assignment_filter += android_sources_filters
293 # This is the actual set.
294 set_sources_assignment_filter(sources_assignment_filter)
296 # =============================================================================
298 # =============================================================================
300 if (is_component_build) {
301 component_mode = "shared_library"
303 component_mode = "static_library"
306 # These Sanitizers all imply using the Clang compiler. On Windows they either
307 # don't work or work differently.
308 if (!is_clang && (is_asan || is_lsan || is_tsan || is_msan)) {
312 toolkit_uses_gtk = is_linux
314 # =============================================================================
316 # =============================================================================
318 # Set up the default configuration for every build target of the given type.
319 # The values configured here will be automatically set on the scope of the
320 # corresponding target. Target definitions can add or remove to the settings
323 # Holds all configs used for making native executables and libraries, to avoid
324 # duplication in each target below.
325 native_compiler_configs = [
326 "//build/config:my_msvs", # TODO(brettw) eraseme
328 "//build/config/compiler:compiler",
329 "//build/config/compiler:chromium_code",
330 "//build/config/compiler:default_warnings",
331 "//build/config/compiler:no_rtti",
332 "//build/config/compiler:runtime_library",
335 native_compiler_configs += [
336 "//build/config/win:sdk",
338 } else if (is_clang) {
339 native_compiler_configs += [ "//build/config/clang:find_bad_constructs" ]
342 # Optimizations and debug checking.
344 native_compiler_configs += [ "//build/config:debug" ]
345 default_optimization_config = "//build/config/compiler:no_optimize"
347 native_compiler_configs += [ "//build/config:release" ]
348 default_optimization_config = "//build/config/compiler:optimize"
350 native_compiler_configs += [ default_optimization_config ]
353 if (is_clang && (is_linux || is_android)) {
354 # Clang creates chubby debug information, which makes linking very slow.
355 # For now, don't create debug information with clang.
356 # See http://crbug.com/70000
357 # TODO(brettw) This just copies GYP. Why not do this on Mac as well?
358 default_symbols_config = "//build/config/compiler:no_symbols"
359 } else if (symbol_level == 2) {
360 default_symbols_config = "//build/config/compiler:symbols"
361 } else if (symbol_level == 1) {
362 default_symbols_config = "//build/config/compiler:minimal_symbols"
363 } else if (symbol_level == 0) {
364 default_symbols_config = "//build/config/compiler:no_symbols"
366 assert(false, "Bad value for symbol_level.")
368 native_compiler_configs += [ default_symbols_config ]
370 # Windows linker setup for EXEs and DLLs.
373 default_incremental_linking_config =
374 "//build/config/win:incremental_linking"
376 default_incremental_linking_config =
377 "//build/config/win:no_incremental_linking"
379 windows_linker_configs = [
380 default_incremental_linking_config,
381 "//build/config/win:sdk_link",
382 "//build/config/win:common_linker_setup",
383 # Default to console-mode apps. Most of our targets are tests and such
384 # that shouldn't use the windows subsystem.
385 "//build/config/win:console",
389 set_defaults("executable") {
390 configs = native_compiler_configs
392 configs += windows_linker_configs
394 configs += [ "//build/config/mac:mac_dynamic_flags" ]
395 } else if (is_linux) {
396 configs += [ "//build/config/linux:executable_ldconfig" ]
400 set_defaults("static_library") {
401 configs = native_compiler_configs
404 set_defaults("shared_library") {
405 configs = native_compiler_configs
407 configs += windows_linker_configs
409 configs += [ "//build/config/mac:mac_dynamic_flags" ]
413 set_defaults("source_set") {
414 configs = native_compiler_configs
417 # ==============================================================================
419 # ==============================================================================
421 # Here we set the default toolchain, as well as the variable host_toolchain
422 # which will identify the toolchain corresponding to the local system when
423 # doing cross-compiles. When not cross-compiling, this will be the same as the
427 # TODO(brettw) name the toolchains the same as cpu_arch as with Linux below
428 # to eliminate these conditionals.
429 if (build_cpu_arch == "x64") {
430 host_toolchain = "//build/toolchain/win:64"
431 } else if (build_cpu_arch == "x86") {
432 host_toolchain = "//build/toolchain/win:32"
435 if (cpu_arch == "x64") {
436 set_default_toolchain("//build/toolchain/win:64")
437 } else if (cpu_arch == "x86") {
438 set_default_toolchain("//build/toolchain/win:32")
440 } else if (is_android) {
441 host_toolchain = "//build/toolchain/linux:$build_cpu_arch"
442 set_default_toolchain("//build/toolchain/android:$cpu_arch")
443 } else if (is_linux) {
444 host_toolchain = "//build/toolchain/linux:$build_cpu_arch"
445 set_default_toolchain("//build/toolchain/linux:$cpu_arch")
446 } else if (is_mac || is_ios) {
447 host_toolchain = "//build/toolchain/mac:clang"
448 set_default_toolchain(host_toolchain)