OLD | NEW |
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 # ============================================================================= | 5 # ============================================================================= |
6 # BUILD FLAGS | 6 # BUILD FLAGS |
7 # ============================================================================= | 7 # ============================================================================= |
8 # | 8 # |
9 # This block lists input arguments to the build, along with their default | 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 | 10 # values. GN requires listing them explicitly so it can validate input and have |
11 # a central place to manage the build flags. | 11 # a central place to manage the build flags. |
12 # | 12 # |
13 # If a value is specified on the command line, it will overwrite the defaults | 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. | 14 # given here, otherwise the default will be injected into the root scope. |
15 # | 15 # |
16 # KEEP IN ALPHABETICAL ORDER and write a good description for everything. | 16 # KEEP IN ALPHABETICAL ORDER and write a good description for everything. |
17 # Use "is_*" names for intrinsic platform descriptions and build modes, and | 17 # Use "is_*" names for intrinsic platform descriptions and build modes, and |
18 # "use_*" names for optional features libraries, and configurations. | 18 # "use_*" names for optional features libraries, and configurations. |
| 19 |
| 20 # TODO(dpranke): The os and cpu_arch variables exist for backwards |
| 21 # compatibility and should be deleted once all of the build files and |
| 22 # bots have been updated to use current_cpu/target_cpu and |
| 23 # current_os/target_os instead. |
| 24 |
| 25 if (target_os == "") { |
| 26 if (defined(os)) { |
| 27 # If os is defined, it was set in an args file and needs to be |
| 28 # used for backwards-compatibility. |
| 29 target_os = os |
| 30 } else { |
| 31 target_os = host_os |
| 32 } |
| 33 } |
| 34 |
| 35 if (target_cpu == "") { |
| 36 if (defined(cpu_arch)) { |
| 37 # If cpu_arch is defined, it was set in an args file and needs to be |
| 38 # used for backwards-compatibility. |
| 39 target_cpu = cpu_arch |
| 40 } else if (target_os == "android") { |
| 41 # If we're building for Android, we should assume that we want to |
| 42 # build for ARM by default, not the host_cpu (which is likely x64). |
| 43 # This allows us to not have to specify both target_os and target_cpu |
| 44 # on the command line. |
| 45 target_cpu = "arm" |
| 46 } else { |
| 47 target_cpu = host_cpu |
| 48 } |
| 49 } |
| 50 |
| 51 if (current_cpu == "") { |
| 52 current_cpu = target_cpu |
| 53 } |
| 54 if (current_os == "") { |
| 55 current_os = target_os |
| 56 } |
| 57 |
19 declare_args() { | 58 declare_args() { |
| 59 # TODO(dpranke): These values are here for backwards compatibility and |
| 60 # should be deleted when all of the builders and configs have been updated. |
| 61 cpu_arch = target_cpu |
| 62 os = target_os |
| 63 build_cpu_arch = host_cpu |
| 64 build_os = host_os |
| 65 |
20 # How many symbols to include in the build. This affects the performance of | 66 # 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. | 67 # the build since the symbols are large and dealing with them is slow. |
22 # 2 means regular build with symbols. | 68 # 2 means regular build with symbols. |
23 # 1 means minimal symbols, usually enough for backtraces only. | 69 # 1 means minimal symbols, usually enough for backtraces only. |
24 # 0 means no symbols. | 70 # 0 means no symbols. |
25 # -1 means auto-set (off in release, regular in debug). | 71 # -1 means auto-set (off in release, regular in debug). |
26 symbol_level = -1 | 72 symbol_level = -1 |
27 | 73 |
28 # Component build. | 74 # Component build. |
29 is_component_build = false | 75 is_component_build = false |
30 | 76 |
31 # Debug build. | 77 # Debug build. |
32 is_debug = true | 78 is_debug = true |
33 | 79 |
34 # Whether we're a traditional desktop unix. | 80 # Whether we're a traditional desktop unix. |
35 is_desktop_linux = os == "linux" && os != "chromeos" | 81 is_desktop_linux = current_os == "linux" && current_os != "chromeos" |
36 | 82 |
37 # Set to true when compiling with the Clang compiler. Typically this is used | 83 # Set to true when compiling with the Clang compiler. Typically this is used |
38 # to configure warnings. | 84 # to configure warnings. |
39 is_clang = os == "mac" || os == "ios" || os == "linux" || os == "chromeos" | 85 is_clang = current_os == "mac" || current_os == "ios" || |
| 86 current_os == "linux" || current_os == "chromeos" |
40 | 87 |
41 # Selects the desired build flavor. Official builds get additional | 88 # Selects the desired build flavor. Official builds get additional |
42 # processing to prepare for release. Normally you will want to develop and | 89 # processing to prepare for release. Normally you will want to develop and |
43 # test with this flag off. | 90 # test with this flag off. |
44 is_official_build = false | 91 is_official_build = false |
45 | 92 |
46 # Select the desired branding flavor. False means normal Chromium branding, | 93 # Select the desired branding flavor. False means normal Chromium branding, |
47 # true means official Google Chrome branding (requires extra Google-internal | 94 # true means official Google Chrome branding (requires extra Google-internal |
48 # resources). | 95 # resources). |
49 is_chrome_branded = false | 96 is_chrome_branded = false |
50 | 97 |
51 # Compile for Address Sanitizer to find memory bugs. | 98 # Compile for Address Sanitizer to find memory bugs. |
52 is_asan = false | 99 is_asan = false |
53 | 100 |
54 # Compile for Leak Sanitizer to find leaks. | 101 # Compile for Leak Sanitizer to find leaks. |
55 is_lsan = false | 102 is_lsan = false |
56 | 103 |
57 # Compile for Memory Sanitizer to find uninitialized reads. | 104 # Compile for Memory Sanitizer to find uninitialized reads. |
58 is_msan = false | 105 is_msan = false |
59 | 106 |
60 # Compile for Thread Sanitizer to find threading bugs. | 107 # Compile for Thread Sanitizer to find threading bugs. |
61 is_tsan = false | 108 is_tsan = false |
62 | 109 |
63 if (os == "chromeos") { | 110 if (current_os == "chromeos") { |
64 # Allows the target toolchain to be injected as arguments. This is needed | 111 # Allows the target toolchain to be injected as arguments. This is needed |
65 # to support the CrOS build system which supports per-build-configuration | 112 # to support the CrOS build system which supports per-build-configuration |
66 # toolchains. | 113 # toolchains. |
67 cros_use_custom_toolchain = false | 114 cros_use_custom_toolchain = false |
68 } | 115 } |
69 | 116 |
70 # TODO(cjhopman): Make target_arch work for all platforms. | |
71 | |
72 # Architecture of the target device. For Android builds, this will be equal to | |
73 # the cpu_arch of the default toolchain. When checking the CPU architecture | |
74 # for source files and build dependencies you should almost alway use cpu_arch | |
75 # instead. cpu_arch is the architecture of the current toolchain and allows | |
76 # cross-compiles (compiling the same target for multiple toolchains in the | |
77 # same build) to work. | |
78 target_arch = "arm" | |
79 | |
80 # TODO(brettw) remove this flag (and therefore enable linking all targets) on | 117 # TODO(brettw) remove this flag (and therefore enable linking all targets) on |
81 # Windows when we have sufficient bot capacity. In the meantime, you can | 118 # Windows when we have sufficient bot capacity. In the meantime, you can |
82 # enable linking for local compiles. | 119 # enable linking for local compiles. |
83 link_chrome_on_windows = true | 120 link_chrome_on_windows = true |
84 } | 121 } |
85 | 122 |
| 123 # TODO(dpranke): Remove these asserts when os and cpu_arch are removed. |
| 124 assert(current_os == os) |
| 125 |
86 # ============================================================================= | 126 # ============================================================================= |
87 # OS DEFINITIONS | 127 # OS DEFINITIONS |
88 # ============================================================================= | 128 # ============================================================================= |
89 # | 129 # |
90 # We set these various is_FOO booleans for convenience in writing OS-based | 130 # We set these various is_FOO booleans for convenience in writing OS-based |
91 # conditions. | 131 # conditions. |
92 # | 132 # |
93 # - is_android, is_chromeos, is_ios, and is_win should be obvious. | 133 # - is_android, is_chromeos, is_ios, and is_win should be obvious. |
94 # - is_mac is set only for desktop Mac. It is not set on iOS. | 134 # - is_mac is set only for desktop Mac. It is not set on iOS. |
95 # - is_posix is true for mac and any Unix-like system (basically everything | 135 # - is_posix is true for mac and any Unix-like system (basically everything |
96 # except Windows). | 136 # except Windows). |
97 # - is_linux is true for desktop Linux and ChromeOS, but not Android (which is | 137 # - is_linux is true for desktop Linux and ChromeOS, but not Android (which is |
98 # generally too different despite being based on the Linux kernel). | 138 # generally too different despite being based on the Linux kernel). |
99 # | 139 # |
100 # Do not add more is_* variants here for random lesser-used Unix systems like | 140 # Do not add more is_* variants here for random lesser-used Unix systems like |
101 # aix or one of the BSDs. If you need to check these, just check the os value | 141 # aix or one of the BSDs. If you need to check these, just check the |
102 # directly. | 142 # current_os value directly. |
103 | 143 |
104 if (os == "win") { | 144 if (current_os == "win") { |
105 is_android = false | 145 is_android = false |
106 is_chromeos = false | 146 is_chromeos = false |
107 is_ios = false | 147 is_ios = false |
108 is_linux = false | 148 is_linux = false |
109 is_mac = false | 149 is_mac = false |
110 is_nacl = false | 150 is_nacl = false |
111 is_posix = false | 151 is_posix = false |
112 is_win = true | 152 is_win = true |
113 } else if (os == "mac") { | 153 } else if (current_os == "mac") { |
114 is_android = false | 154 is_android = false |
115 is_chromeos = false | 155 is_chromeos = false |
116 is_ios = false | 156 is_ios = false |
117 is_linux = false | 157 is_linux = false |
118 is_mac = true | 158 is_mac = true |
119 is_nacl = false | 159 is_nacl = false |
120 is_posix = true | 160 is_posix = true |
121 is_win = false | 161 is_win = false |
122 } else if (os == "android") { | 162 } else if (current_os == "android") { |
123 is_android = true | 163 is_android = true |
124 is_chromeos = false | 164 is_chromeos = false |
125 is_ios = false | 165 is_ios = false |
126 is_linux = false | 166 is_linux = false |
127 is_mac = false | 167 is_mac = false |
128 is_nacl = false | 168 is_nacl = false |
129 is_posix = true | 169 is_posix = true |
130 is_win = false | 170 is_win = false |
131 } else if (os == "chromeos") { | 171 } else if (current_os == "chromeos") { |
132 is_android = false | 172 is_android = false |
133 is_chromeos = true | 173 is_chromeos = true |
134 is_ios = false | 174 is_ios = false |
135 is_linux = true | 175 is_linux = true |
136 is_mac = false | 176 is_mac = false |
137 is_nacl = false | 177 is_nacl = false |
138 is_posix = true | 178 is_posix = true |
139 is_win = false | 179 is_win = false |
140 } else if (os == "nacl") { | 180 } else if (current_os == "nacl") { |
141 # os == "nacl" will be passed by the nacl toolchain definition. It is not | 181 # current_os == "nacl" will be passed by the nacl toolchain definition. |
142 # set by default or on the command line. We treat is as a Posix variant. | 182 # It is not set by default or on the command line. We treat is as a |
| 183 # Posix variant. |
143 is_android = false | 184 is_android = false |
144 is_chromeos = false | 185 is_chromeos = false |
145 is_ios = false | 186 is_ios = false |
146 is_linux = false | 187 is_linux = false |
147 is_mac = false | 188 is_mac = false |
148 is_nacl = true | 189 is_nacl = true |
149 is_posix = true | 190 is_posix = true |
150 is_win = false | 191 is_win = false |
151 } else if (os == "ios") { | 192 } else if (current_os == "ios") { |
152 is_android = false | 193 is_android = false |
153 is_chromeos = false | 194 is_chromeos = false |
154 is_ios = true | 195 is_ios = true |
155 is_linux = false | 196 is_linux = false |
156 is_mac = false | 197 is_mac = false |
157 is_nacl = false | 198 is_nacl = false |
158 is_posix = true | 199 is_posix = true |
159 is_win = false | 200 is_win = false |
160 } else if (os == "linux") { | 201 } else if (current_os == "linux") { |
161 is_android = false | 202 is_android = false |
162 is_chromeos = false | 203 is_chromeos = false |
163 is_ios = false | 204 is_ios = false |
164 is_linux = true | 205 is_linux = true |
165 is_mac = false | 206 is_mac = false |
166 is_nacl = false | 207 is_nacl = false |
167 is_posix = true | 208 is_posix = true |
168 is_win = false | 209 is_win = false |
169 } | 210 } |
170 | 211 |
171 # ============================================================================= | 212 # ============================================================================= |
172 # CPU ARCHITECTURE | |
173 # ============================================================================= | |
174 | |
175 if (is_android) { | |
176 # TODO(cjhopman): enable this assert once bots are updated to not set | |
177 # cpu_arch. | |
178 #assert(cpu_arch == build_cpu_arch, "Android device target architecture should | |
179 # be set with 'target_arch', not 'cpu_arch'") | |
180 cpu_arch = target_arch | |
181 } | |
182 | |
183 # ============================================================================= | |
184 # SOURCES FILTERS | 213 # SOURCES FILTERS |
185 # ============================================================================= | 214 # ============================================================================= |
186 # | 215 # |
187 # These patterns filter out platform-specific files when assigning to the | 216 # These patterns filter out platform-specific files when assigning to the |
188 # sources variable. The magic variable |sources_assignment_filter| is applied | 217 # sources variable. The magic variable |sources_assignment_filter| is applied |
189 # to each assignment or appending to the sources variable and matches are | 218 # to each assignment or appending to the sources variable and matches are |
190 # automatcally removed. | 219 # automatcally removed. |
191 # | 220 # |
192 # Note that the patterns are NOT regular expressions. Only "*" and "\b" (path | 221 # Note that the patterns are NOT regular expressions. Only "*" and "\b" (path |
193 # boundary = end of string or slash) are supported, and the entire string | 222 # boundary = end of string or slash) are supported, and the entire string |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 configs = _native_compiler_configs | 463 configs = _native_compiler_configs |
435 } | 464 } |
436 | 465 |
437 # Shared library defaults (also for components in component mode). | 466 # Shared library defaults (also for components in component mode). |
438 _shared_library_configs = | 467 _shared_library_configs = |
439 _native_compiler_configs + [ "//build/config:default_libs" ] | 468 _native_compiler_configs + [ "//build/config:default_libs" ] |
440 if (is_win) { | 469 if (is_win) { |
441 _shared_library_configs += _windows_linker_configs | 470 _shared_library_configs += _windows_linker_configs |
442 } else if (is_mac) { | 471 } else if (is_mac) { |
443 _shared_library_configs += [ "//build/config/mac:mac_dynamic_flags" ] | 472 _shared_library_configs += [ "//build/config/mac:mac_dynamic_flags" ] |
| 473 } else if (is_android) { |
| 474 # Strip native JNI exports from shared libraries by default. Binaries that |
| 475 # want this can remove this config. |
| 476 _shared_library_configs += |
| 477 [ "//build/config/android:hide_native_jni_exports" ] |
444 } | 478 } |
445 set_defaults("shared_library") { | 479 set_defaults("shared_library") { |
446 configs = _shared_library_configs | 480 configs = _shared_library_configs |
447 } | 481 } |
448 if (is_component_build) { | 482 if (is_component_build) { |
449 set_defaults("component") { | 483 set_defaults("component") { |
450 configs = _shared_library_configs | 484 configs = _shared_library_configs |
451 } | 485 } |
452 } | 486 } |
453 | 487 |
(...skipping 20 matching lines...) Expand all Loading... |
474 # TOOLCHAIN SETUP | 508 # TOOLCHAIN SETUP |
475 # ============================================================================== | 509 # ============================================================================== |
476 # | 510 # |
477 # Here we set the default toolchain, as well as the variable host_toolchain | 511 # Here we set the default toolchain, as well as the variable host_toolchain |
478 # which will identify the toolchain corresponding to the local system when | 512 # which will identify the toolchain corresponding to the local system when |
479 # doing cross-compiles. When not cross-compiling, this will be the same as the | 513 # doing cross-compiles. When not cross-compiling, this will be the same as the |
480 # default toolchain. | 514 # default toolchain. |
481 | 515 |
482 if (is_win) { | 516 if (is_win) { |
483 # On windows we use the same toolchain for host and target by default. | 517 # On windows we use the same toolchain for host and target by default. |
484 # TODO(dpranke): rename the toolchains to x64 and x86 to match cpu_arch. | 518 # TODO(dpranke): rename the toolchains to x64 and x86 to match current_cpu. |
485 if (cpu_arch == "x64") { | 519 if (current_cpu == "x64") { |
486 host_toolchain = "//build/toolchain/win:64" | 520 host_toolchain = "//build/toolchain/win:64" |
487 } else if (cpu_arch == "x86") { | 521 } else if (current_cpu == "x86") { |
488 host_toolchain = "//build/toolchain/win:32" | 522 host_toolchain = "//build/toolchain/win:32" |
489 } | 523 } |
490 set_default_toolchain("$host_toolchain") | 524 set_default_toolchain("$host_toolchain") |
491 } else if (is_android) { | 525 } else if (is_android) { |
492 # Use clang for the x86/64 Linux host builds. | 526 # Use clang for the x86/64 Linux host builds. |
493 if (build_cpu_arch == "x86" || build_cpu_arch == "x64") { | 527 if (host_cpu == "x86" || host_cpu == "x64") { |
494 host_toolchain = "//build/toolchain/linux:clang_$build_cpu_arch" | 528 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" |
495 } else { | 529 } else { |
496 host_toolchain = "//build/toolchain/linux:$build_cpu_arch" | 530 host_toolchain = "//build/toolchain/linux:$host_cpu" |
497 } | 531 } |
498 set_default_toolchain("//build/toolchain/android:$cpu_arch") | 532 set_default_toolchain("//build/toolchain/android:$current_cpu") |
499 } else if (is_linux) { | 533 } else if (is_linux) { |
500 if (is_clang) { | 534 if (is_clang) { |
501 host_toolchain = "//build/toolchain/linux:clang_$build_cpu_arch" | 535 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" |
502 set_default_toolchain("//build/toolchain/linux:clang_$cpu_arch") | 536 set_default_toolchain("//build/toolchain/linux:clang_$current_cpu") |
503 } else { | 537 } else { |
504 host_toolchain = "//build/toolchain/linux:$build_cpu_arch" | 538 host_toolchain = "//build/toolchain/linux:$host_cpu" |
505 set_default_toolchain("//build/toolchain/linux:$cpu_arch") | 539 set_default_toolchain("//build/toolchain/linux:$current_cpu") |
506 } | 540 } |
507 if (is_chromeos && cros_use_custom_toolchain) { | 541 if (is_chromeos && cros_use_custom_toolchain) { |
508 set_default_toolchain("//build/toolchain/cros:target") | 542 set_default_toolchain("//build/toolchain/cros:target") |
509 } | 543 } |
510 } else if (is_mac) { | 544 } else if (is_mac) { |
511 host_toolchain = "//build/toolchain/mac:clang" | 545 host_toolchain = "//build/toolchain/mac:clang" |
512 set_default_toolchain(host_toolchain) | 546 set_default_toolchain(host_toolchain) |
513 } else if (is_ios) { | 547 } else if (is_ios) { |
514 host_toolchain = "//build/toolchain/mac:host_clang" | 548 host_toolchain = "//build/toolchain/mac:host_clang" |
515 set_default_toolchain("//build/toolchain/mac:clang") | 549 set_default_toolchain("//build/toolchain/mac:clang") |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 } | 749 } |
716 if (defined(invoker.testonly)) { | 750 if (defined(invoker.testonly)) { |
717 testonly = invoker.testonly | 751 testonly = invoker.testonly |
718 } | 752 } |
719 if (defined(invoker.visibility)) { | 753 if (defined(invoker.visibility)) { |
720 visibility = invoker.visibility | 754 visibility = invoker.visibility |
721 } | 755 } |
722 } | 756 } |
723 } | 757 } |
724 } | 758 } |
OLD | NEW |