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

Side by Side Diff: build/config/BUILDCONFIG.gn

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 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 | « build/config/BUILD.gn ('k') | build/config/allocator.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 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
20 if (target_os == "") { 5 if (target_os == "") {
21 target_os = host_os 6 target_os = host_os
22 } 7 }
23 8
24 if (target_cpu == "") { 9 if (target_cpu == "") {
25 if (target_os == "android") { 10 if (target_os == "android") {
26 # If we're building for Android, we should assume that we want to 11 # If we're building for Android, we should assume that we want to
27 # build for ARM by default, not the host_cpu (which is likely x64). 12 # build for ARM by default, not the host_cpu (which is likely x64).
28 # This allows us to not have to specify both target_os and target_cpu 13 # This allows us to not have to specify both target_os and target_cpu
29 # on the command line. 14 # on the command line.
30 target_cpu = "arm" 15 target_cpu = "arm"
31 } else { 16 } else {
32 target_cpu = host_cpu 17 target_cpu = host_cpu
33 } 18 }
34 } 19 }
35 20
36 if (current_cpu == "") { 21 if (current_cpu == "") {
37 current_cpu = target_cpu 22 current_cpu = target_cpu
38 } 23 }
39 if (current_os == "") { 24 if (current_os == "") {
40 current_os = target_os 25 current_os = target_os
41 } 26 }
42 27
28 # =============================================================================
29 # BUILD FLAGS
30 # =============================================================================
31 #
32 # This block lists input arguments to the build, along with their default
33 # values.
34 #
35 # If a value is specified on the command line, it will overwrite the defaults
36 # given in a declare_args block, otherwise the default will be used.
37 #
38 # YOU SHOULD ALMOST NEVER NEED TO ADD FLAGS TO THIS FILE. GN allows any file in
39 # the build to declare build flags. If you need a flag for a single component,
40 # you can just declare it in the corresponding BUILD.gn file. If you need a
41 # flag in multiple components, there are a few options:
42 #
43 # - If your feature is a single target, say //components/foo, and the targets
44 # depending on foo need to have some define set if foo is enabled: (1) Write
45 # a declare_args block in foo's BUILD.gn file listing your enable_foo build
46 # flag. (2) Write a config in that file listing the define, and list that
47 # config in foo's public_configs. This will propagate that define to all the
48 # targets depending on foo. (3) When foo is not enabled, just make it expand
49 # to an empty group (or whatever's appropriate for the "off" state of your
50 # feature.
51 #
52 # - If a semi-random set of targets need to know about a define: (1) In the
53 # lowest level of the build that knows about this feature, add a declare_args
54 # block in the build file for your enable flag. (2) Write a config that adds
55 # a define conditionally based on that build flags. (3) Manually add that
56 # config to the "configs" applying to the targets that need the define.
57 #
58 # - If a semi-random set of targets need to know about the build flag (to do
59 # file inclusion or exclusion, more than just defines): (1) Write a .gni file
60 # in the lowest-level directory that knows about the feature. (2) Put the
61 # declare_args block with your build flag in that .gni file. (3) Import that
62 # .gni file from the BUILD.gn files that need the flag.
63 #
64 # Other advice:
65 #
66 # - Use boolean values when possible. If you need a default value that expands
67 # to some complex thing in the default case (like the location of the
68 # compiler which would be computed by a script), use a default value of -1 or
69 # the empty string. Outside of the declare_args block, conditionally expand
70 # the default value as necessary.
71 #
72 # - Use a name like "use_foo" or "is_foo" (whatever is more appropriate for
73 # your feature) rather than just "foo".
74 #
75 # - Write good comments directly above the declaration with no blank line.
76 # These comments will appear as documentation in "gn args --list".
77 #
78 # - Don't call exec_script inside declare_args. This will execute the script
79 # even if the value is overridden, which is wasteful. See first bullet.
80
43 declare_args() { 81 declare_args() {
44 # How many symbols to include in the build. This affects the performance of 82 # How many symbols to include in the build. This affects the performance of
45 # the build since the symbols are large and dealing with them is slow. 83 # the build since the symbols are large and dealing with them is slow.
46 # 2 means regular build with symbols. 84 # 2 means regular build with symbols.
47 # 1 means minimal symbols, usually enough for backtraces only. 85 # 1 means minimal symbols, usually enough for backtraces only.
48 # 0 means no symbols. 86 # 0 means no symbols.
49 # -1 means auto-set (off in release, regular in debug). 87 # -1 means auto-set (off in release, regular in debug).
50 symbol_level = -1 88 symbol_level = -1
51 89
52 # Component build. 90 # Component build.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 124
87 # Compile for Thread Sanitizer to find threading bugs. 125 # Compile for Thread Sanitizer to find threading bugs.
88 is_tsan = false 126 is_tsan = false
89 127
90 if (current_os == "chromeos") { 128 if (current_os == "chromeos") {
91 # Allows the target toolchain to be injected as arguments. This is needed 129 # Allows the target toolchain to be injected as arguments. This is needed
92 # to support the CrOS build system which supports per-build-configuration 130 # to support the CrOS build system which supports per-build-configuration
93 # toolchains. 131 # toolchains.
94 cros_use_custom_toolchain = false 132 cros_use_custom_toolchain = false
95 } 133 }
134
135 # DON'T ADD MORE FLAGS HERE. Read the comment above.
96 } 136 }
97 137
98 # ============================================================================= 138 # =============================================================================
99 # OS DEFINITIONS 139 # OS DEFINITIONS
100 # ============================================================================= 140 # =============================================================================
101 # 141 #
102 # We set these various is_FOO booleans for convenience in writing OS-based 142 # We set these various is_FOO booleans for convenience in writing OS-based
103 # conditions. 143 # conditions.
104 # 144 #
105 # - is_android, is_chromeos, is_ios, and is_win should be obvious. 145 # - is_android, is_chromeos, is_ios, and is_win should be obvious.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 "*_posix_unittest.cc", 246 "*_posix_unittest.cc",
207 "*\bposix/*", 247 "*\bposix/*",
208 ] 248 ]
209 } 249 }
210 if (!is_win) { 250 if (!is_win) {
211 sources_assignment_filter += [ 251 sources_assignment_filter += [
212 "*_win.cc", 252 "*_win.cc",
213 "*_win.h", 253 "*_win.h",
214 "*_win_unittest.cc", 254 "*_win_unittest.cc",
215 "*\bwin/*", 255 "*\bwin/*",
256 "*.def",
216 "*.rc", 257 "*.rc",
217 ] 258 ]
218 } 259 }
219 if (!is_mac) { 260 if (!is_mac) {
220 sources_assignment_filter += [ 261 sources_assignment_filter += [
221 "*_mac.h", 262 "*_mac.h",
222 "*_mac.cc", 263 "*_mac.cc",
223 "*_mac.mm", 264 "*_mac.mm",
224 "*_mac_unittest.h", 265 "*_mac_unittest.h",
225 "*_mac_unittest.cc", 266 "*_mac_unittest.cc",
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 # here as needed. 354 # here as needed.
314 355
315 # Holds all configs used for making native executables and libraries, to avoid 356 # Holds all configs used for making native executables and libraries, to avoid
316 # duplication in each target below. 357 # duplication in each target below.
317 _native_compiler_configs = [ 358 _native_compiler_configs = [
318 "//build/config:feature_flags", 359 "//build/config:feature_flags",
319 "//build/config/compiler:compiler", 360 "//build/config/compiler:compiler",
320 "//build/config/compiler:compiler_arm_fpu", 361 "//build/config/compiler:compiler_arm_fpu",
321 "//build/config/compiler:chromium_code", 362 "//build/config/compiler:chromium_code",
322 "//build/config/compiler:default_include_dirs", 363 "//build/config/compiler:default_include_dirs",
323 "//build/config/compiler:default_warnings",
324 "//build/config/compiler:no_rtti", 364 "//build/config/compiler:no_rtti",
325 "//build/config/compiler:runtime_library", 365 "//build/config/compiler:runtime_library",
326 ] 366 ]
327 if (is_win) { 367 if (is_win) {
328 _native_compiler_configs += [ 368 _native_compiler_configs += [
329 "//build/config/win:lean_and_mean", 369 "//build/config/win:lean_and_mean",
330 "//build/config/win:nominmax", 370 "//build/config/win:nominmax",
331 "//build/config/win:sdk", 371 "//build/config/win:sdk",
332 "//build/config/win:unicode", 372 "//build/config/win:unicode",
333 "//build/config/win:winver", 373 "//build/config/win:winver",
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 _default_optimization_config = "//build/config/compiler:optimize" 406 _default_optimization_config = "//build/config/compiler:optimize"
367 } 407 }
368 _native_compiler_configs += [ _default_optimization_config ] 408 _native_compiler_configs += [ _default_optimization_config ]
369 409
370 # If it wasn't manually set, set to an appropriate default. 410 # If it wasn't manually set, set to an appropriate default.
371 if (symbol_level == -1) { 411 if (symbol_level == -1) {
372 # Linux is slowed by having symbols as part of the target binary, whereas 412 # Linux is slowed by having symbols as part of the target binary, whereas
373 # Mac and Windows have them separate, so in Release Linux, default them off. 413 # Mac and Windows have them separate, so in Release Linux, default them off.
374 if (is_debug || !is_linux) { 414 if (is_debug || !is_linux) {
375 symbol_level = 2 415 symbol_level = 2
416 } else if (is_asan || is_lsan || is_tsan || is_msan) {
417 # Sanitizers require symbols for filename suppressions to work.
418 symbol_level = 1
376 } else { 419 } else {
377 symbol_level = 0 420 symbol_level = 0
378 } 421 }
379 } 422 }
380 423
381 # Symbol setup. 424 # Symbol setup.
382 if (symbol_level == 2) { 425 if (symbol_level == 2) {
383 _default_symbols_config = "//build/config/compiler:symbols" 426 _default_symbols_config = "//build/config/compiler:symbols"
384 } else if (symbol_level == 1) { 427 } else if (symbol_level == 1) {
385 _default_symbols_config = "//build/config/compiler:minimal_symbols" 428 _default_symbols_config = "//build/config/compiler:minimal_symbols"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 # TOOLCHAIN SETUP 516 # TOOLCHAIN SETUP
474 # ============================================================================== 517 # ==============================================================================
475 # 518 #
476 # Here we set the default toolchain, as well as the variable host_toolchain 519 # Here we set the default toolchain, as well as the variable host_toolchain
477 # which will identify the toolchain corresponding to the local system when 520 # which will identify the toolchain corresponding to the local system when
478 # doing cross-compiles. When not cross-compiling, this will be the same as the 521 # doing cross-compiles. When not cross-compiling, this will be the same as the
479 # default toolchain. 522 # default toolchain.
480 523
481 if (is_win) { 524 if (is_win) {
482 # On windows we use the same toolchain for host and target by default. 525 # On windows we use the same toolchain for host and target by default.
483 # TODO(dpranke): rename the toolchains to x64 and x86 to match current_cpu. 526 if (is_clang) {
484 if (current_cpu == "x64") { 527 host_toolchain = "//build/toolchain/win:clang_$current_cpu"
485 host_toolchain = "//build/toolchain/win:64" 528 } else {
486 } else if (current_cpu == "x86") { 529 host_toolchain = "//build/toolchain/win:$current_cpu"
487 host_toolchain = "//build/toolchain/win:32"
488 } 530 }
489 set_default_toolchain("$host_toolchain") 531 set_default_toolchain("$host_toolchain")
490 } else if (is_android) { 532 } else if (is_android) {
491 if (host_os == "linux") { 533 if (host_os == "linux") {
492 # Use clang for the x86/64 Linux host builds. 534 # Use clang for the x86/64 Linux host builds.
493 if (host_cpu == "x86" || host_cpu == "x64") { 535 if (host_cpu == "x86" || host_cpu == "x64") {
494 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" 536 host_toolchain = "//build/toolchain/linux:clang_$host_cpu"
495 } else { 537 } else {
496 host_toolchain = "//build/toolchain/linux:$host_cpu" 538 host_toolchain = "//build/toolchain/linux:$host_cpu"
497 } 539 }
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 768 }
727 if (defined(invoker.testonly)) { 769 if (defined(invoker.testonly)) {
728 testonly = invoker.testonly 770 testonly = invoker.testonly
729 } 771 }
730 if (defined(invoker.visibility)) { 772 if (defined(invoker.visibility)) {
731 visibility = invoker.visibility 773 visibility = invoker.visibility
732 } 774 }
733 } 775 }
734 } 776 }
735 } 777 }
OLDNEW
« no previous file with comments | « build/config/BUILD.gn ('k') | build/config/allocator.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698