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