| 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 # PLATFORM SELECTION | 6 # PLATFORM SELECTION |
| 7 # ============================================================================= | 7 # ============================================================================= |
| 8 # | 8 # |
| 9 # There are two main things to set: "os" and "cpu". The "toolchain" is the name | 9 # There are two main things to set: "os" and "cpu". The "toolchain" is the name |
| 10 # of the GN thing that encodes combinations of these things. | 10 # of the GN thing that encodes combinations of these things. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 # its GYP counterpart. Potentially the built-in default_toolchain variable | 31 # its GYP counterpart. Potentially the built-in default_toolchain variable |
| 32 # could be renamed in the future. | 32 # could be renamed in the future. |
| 33 # | 33 # |
| 34 # When writing build files, to do something only for the host: | 34 # When writing build files, to do something only for the host: |
| 35 # if (current_toolchain == host_toolchain) { ... | 35 # if (current_toolchain == host_toolchain) { ... |
| 36 | 36 |
| 37 if (target_os == "") { | 37 if (target_os == "") { |
| 38 target_os = host_os | 38 target_os = host_os |
| 39 } | 39 } |
| 40 | 40 |
| 41 if (target_cpu == "") { | 41 assert(host_cpu != "") |
| 42 if (target_os == "android") { | 42 assert(target_cpu != "") |
| 43 # If we're building for Android, we should assume that we want to | |
| 44 # build for ARM by default, not the host_cpu (which is likely x64). | |
| 45 # This allows us to not have to specify both target_os and target_cpu | |
| 46 # on the command line. | |
| 47 target_cpu = "arm" | |
| 48 } else { | |
| 49 target_cpu = host_cpu | |
| 50 } | |
| 51 } | |
| 52 | 43 |
| 53 if (current_cpu == "") { | 44 if (current_cpu == "") { |
| 54 current_cpu = target_cpu | 45 current_cpu = target_cpu |
| 55 } | 46 } |
| 56 if (current_os == "") { | 47 if (current_os == "") { |
| 57 current_os = target_os | 48 current_os = target_os |
| 58 } | 49 } |
| 59 | 50 |
| 60 # ============================================================================= | 51 # ============================================================================= |
| 61 # BUILD FLAGS | 52 # BUILD FLAGS |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 # | 94 # |
| 104 # - Use a name like "use_foo" or "is_foo" (whatever is more appropriate for | 95 # - Use a name like "use_foo" or "is_foo" (whatever is more appropriate for |
| 105 # your feature) rather than just "foo". | 96 # your feature) rather than just "foo". |
| 106 # | 97 # |
| 107 # - Write good comments directly above the declaration with no blank line. | 98 # - Write good comments directly above the declaration with no blank line. |
| 108 # These comments will appear as documentation in "gn args --list". | 99 # These comments will appear as documentation in "gn args --list". |
| 109 # | 100 # |
| 110 # - Don't call exec_script inside declare_args. This will execute the script | 101 # - Don't call exec_script inside declare_args. This will execute the script |
| 111 # even if the value is overridden, which is wasteful. See first bullet. | 102 # even if the value is overridden, which is wasteful. See first bullet. |
| 112 | 103 |
| 104 # There is no component build for the Dart VM, but build files in some |
| 105 # dependencies check this. |
| 106 is_component_build = false |
| 107 |
| 113 declare_args() { | 108 declare_args() { |
| 114 # How many symbols to include in the build. This affects the performance of | |
| 115 # the build since the symbols are large and dealing with them is slow. | |
| 116 # 2 means regular build with symbols. | |
| 117 # 1 means minimal symbols, usually enough for backtraces only. | |
| 118 # 0 means no symbols. | |
| 119 # -1 means auto-set (off in release, regular in debug). | |
| 120 symbol_level = -1 | |
| 121 | |
| 122 # Component build. | |
| 123 is_component_build = false | |
| 124 | |
| 125 # Debug build. | 109 # Debug build. |
| 126 is_debug = true | 110 is_debug = true |
| 127 | 111 |
| 128 # Whether we're a traditional desktop unix. | 112 # Release build. |
| 129 is_desktop_linux = current_os == "linux" && current_os != "chromeos" | 113 is_release = false |
| 114 |
| 115 # Product build. |
| 116 is_product = false |
| 130 | 117 |
| 131 # Set to true when compiling with the Clang compiler. Typically this is used | 118 # Set to true when compiling with the Clang compiler. Typically this is used |
| 132 # to configure warnings. | 119 # to configure warnings. |
| 133 is_clang = current_os == "mac" || current_os == "ios" || | 120 is_clang = current_os == "mac" || current_os == "linux" |
| 134 current_os == "linux" || current_os == "chromeos" | |
| 135 | 121 |
| 136 # Compile for Address Sanitizer to find memory bugs. | 122 # Compile for Address Sanitizer to find memory bugs. |
| 137 is_asan = false | 123 is_asan = false |
| 138 | 124 |
| 139 # Compile for Leak Sanitizer to find leaks. | 125 # Compile for Leak Sanitizer to find leaks. |
| 140 is_lsan = false | 126 is_lsan = false |
| 141 | 127 |
| 142 # Compile for Memory Sanitizer to find uninitialized reads. | 128 # Compile for Memory Sanitizer to find uninitialized reads. |
| 143 is_msan = false | 129 is_msan = false |
| 144 | 130 |
| 145 # Compile for Thread Sanitizer to find threading bugs. | 131 # Compile for Thread Sanitizer to find threading bugs. |
| 146 is_tsan = false | 132 is_tsan = false |
| 147 | |
| 148 if (current_os == "chromeos") { | |
| 149 # Allows the target toolchain to be injected as arguments. This is needed | |
| 150 # to support the CrOS build system which supports per-build-configuration | |
| 151 # toolchains. | |
| 152 cros_use_custom_toolchain = false | |
| 153 } | |
| 154 | |
| 155 # DON'T ADD MORE FLAGS HERE. Read the comment above. | |
| 156 } | 133 } |
| 157 | 134 |
| 158 # ============================================================================= | 135 # ============================================================================= |
| 159 # OS DEFINITIONS | 136 # OS DEFINITIONS |
| 160 # ============================================================================= | 137 # ============================================================================= |
| 161 # | 138 # |
| 162 # We set these various is_FOO booleans for convenience in writing OS-based | 139 # We set these various is_FOO booleans for convenience in writing OS-based |
| 163 # conditions. | 140 # conditions. |
| 164 # | 141 # |
| 165 # - is_android, is_chromeos, is_ios, and is_win should be obvious. | 142 # - is_android, is_chromeos, is_ios, and is_win should be obvious. |
| 166 # - is_mac is set only for desktop Mac. It is not set on iOS. | 143 # - is_mac is set only for desktop Mac. It is not set on iOS. |
| 167 # - is_posix is true for mac and any Unix-like system (basically everything | 144 # - is_posix is true for mac and any Unix-like system (basically everything |
| 168 # except Windows). | 145 # except Windows). |
| 169 # - is_linux is true for desktop Linux and ChromeOS, but not Android (which is | 146 # - is_linux is true for desktop Linux and ChromeOS, but not Android (which is |
| 170 # generally too different despite being based on the Linux kernel). | 147 # generally too different despite being based on the Linux kernel). |
| 171 # | 148 # |
| 172 # Do not add more is_* variants here for random lesser-used Unix systems like | 149 # Do not add more is_* variants here for random lesser-used Unix systems like |
| 173 # aix or one of the BSDs. If you need to check these, just check the | 150 # aix or one of the BSDs. If you need to check these, just check the |
| 174 # current_os value directly. | 151 # current_os value directly. |
| 175 | 152 |
| 176 if (current_os == "win") { | 153 if (current_os == "win") { |
| 177 is_android = false | 154 is_android = false |
| 178 is_chromeos = false | 155 is_chromeos = false |
| 179 is_fnl = false | |
| 180 is_ios = false | 156 is_ios = false |
| 181 is_linux = false | 157 is_linux = false |
| 182 is_mac = false | 158 is_mac = false |
| 183 is_nacl = false | 159 is_nacl = false |
| 184 is_posix = false | 160 is_posix = false |
| 185 is_win = true | 161 is_win = true |
| 186 } else if (current_os == "mac") { | 162 } else if (current_os == "mac") { |
| 187 is_android = false | 163 is_android = false |
| 188 is_chromeos = false | 164 is_chromeos = false |
| 189 is_fnl = false | |
| 190 is_ios = false | 165 is_ios = false |
| 191 is_linux = false | 166 is_linux = false |
| 192 is_mac = true | 167 is_mac = true |
| 193 is_nacl = false | 168 is_nacl = false |
| 194 is_posix = true | 169 is_posix = true |
| 195 is_win = false | 170 is_win = false |
| 196 } else if (current_os == "android") { | 171 } else if (current_os == "android") { |
| 197 is_android = true | 172 is_android = true |
| 198 is_chromeos = false | 173 is_chromeos = false |
| 199 is_fnl = false | |
| 200 is_ios = false | 174 is_ios = false |
| 201 is_linux = false | 175 is_linux = false |
| 202 is_mac = false | 176 is_mac = false |
| 203 is_nacl = false | 177 is_nacl = false |
| 204 is_posix = true | 178 is_posix = true |
| 205 is_win = false | 179 is_win = false |
| 206 } else if (current_os == "chromeos") { | |
| 207 is_android = false | |
| 208 is_chromeos = true | |
| 209 is_fnl = false | |
| 210 is_ios = false | |
| 211 is_linux = true | |
| 212 is_mac = false | |
| 213 is_nacl = false | |
| 214 is_posix = true | |
| 215 is_win = false | |
| 216 } else if (current_os == "nacl") { | |
| 217 # current_os == "nacl" will be passed by the nacl toolchain definition. | |
| 218 # It is not set by default or on the command line. We treat is as a | |
| 219 # Posix variant. | |
| 220 is_android = false | |
| 221 is_chromeos = false | |
| 222 is_fnl = false | |
| 223 is_ios = false | |
| 224 is_linux = false | |
| 225 is_mac = false | |
| 226 is_nacl = true | |
| 227 is_posix = true | |
| 228 is_win = false | |
| 229 } else if (current_os == "ios") { | |
| 230 is_android = false | |
| 231 is_chromeos = false | |
| 232 is_fnl = false | |
| 233 is_ios = true | |
| 234 is_linux = false | |
| 235 is_mac = false | |
| 236 is_nacl = false | |
| 237 is_posix = true | |
| 238 is_win = false | |
| 239 } else if (current_os == "linux") { | 180 } else if (current_os == "linux") { |
| 240 is_android = false | 181 is_android = false |
| 241 is_chromeos = false | 182 is_chromeos = false |
| 242 is_fnl = false | |
| 243 is_ios = false | 183 is_ios = false |
| 244 is_linux = true | 184 is_linux = true |
| 245 is_mac = false | 185 is_mac = false |
| 246 is_nacl = false | |
| 247 is_posix = true | |
| 248 is_win = false | |
| 249 } else if (current_os == "fnl") { | |
| 250 is_android = false | |
| 251 is_chromeos = false | |
| 252 is_fnl = true | |
| 253 is_ios = false | |
| 254 is_linux = true | |
| 255 is_mac = false | |
| 256 is_nacl = false | 186 is_nacl = false |
| 257 is_posix = true | 187 is_posix = true |
| 258 is_win = false | 188 is_win = false |
| 259 } | 189 } |
| 260 | 190 |
| 261 # ============================================================================= | 191 # ============================================================================= |
| 262 # SOURCES FILTERS | |
| 263 # ============================================================================= | |
| 264 # | |
| 265 # These patterns filter out platform-specific files when assigning to the | |
| 266 # sources variable. The magic variable |sources_assignment_filter| is applied | |
| 267 # to each assignment or appending to the sources variable and matches are | |
| 268 # automatcally removed. | |
| 269 # | |
| 270 # Note that the patterns are NOT regular expressions. Only "*" and "\b" (path | |
| 271 # boundary = end of string or slash) are supported, and the entire string | |
| 272 # muct match the pattern (so you need "*.cc" to match all .cc files, for | |
| 273 # example). | |
| 274 | |
| 275 # DO NOT ADD MORE PATTERNS TO THIS LIST, see set_sources_assignment_filter call | |
| 276 # below. | |
| 277 sources_assignment_filter = [] | |
| 278 if (!is_posix) { | |
| 279 sources_assignment_filter += [ | |
| 280 "*_posix.h", | |
| 281 "*_posix.cc", | |
| 282 "*_posix_unittest.h", | |
| 283 "*_posix_unittest.cc", | |
| 284 "*\bposix/*", | |
| 285 ] | |
| 286 } | |
| 287 if (!is_win) { | |
| 288 sources_assignment_filter += [ | |
| 289 "*_win.cc", | |
| 290 "*_win.h", | |
| 291 "*_win_unittest.cc", | |
| 292 "*\bwin/*", | |
| 293 "*.def", | |
| 294 "*.rc", | |
| 295 ] | |
| 296 } | |
| 297 if (!is_mac) { | |
| 298 sources_assignment_filter += [ | |
| 299 "*_mac.h", | |
| 300 "*_mac.cc", | |
| 301 "*_mac.mm", | |
| 302 "*_mac_unittest.h", | |
| 303 "*_mac_unittest.cc", | |
| 304 "*_mac_unittest.mm", | |
| 305 "*\bmac/*", | |
| 306 "*_cocoa.h", | |
| 307 "*_cocoa.cc", | |
| 308 "*_cocoa.mm", | |
| 309 "*_cocoa_unittest.h", | |
| 310 "*_cocoa_unittest.cc", | |
| 311 "*_cocoa_unittest.mm", | |
| 312 "*\bcocoa/*", | |
| 313 ] | |
| 314 } | |
| 315 if (!is_ios) { | |
| 316 sources_assignment_filter += [ | |
| 317 "*_ios.h", | |
| 318 "*_ios.cc", | |
| 319 "*_ios.mm", | |
| 320 "*_ios_unittest.h", | |
| 321 "*_ios_unittest.cc", | |
| 322 "*_ios_unittest.mm", | |
| 323 "*\bios/*", | |
| 324 ] | |
| 325 } | |
| 326 if (!is_mac && !is_ios) { | |
| 327 sources_assignment_filter += [ "*.mm" ] | |
| 328 } | |
| 329 if (!is_linux) { | |
| 330 sources_assignment_filter += [ | |
| 331 "*_linux.h", | |
| 332 "*_linux.cc", | |
| 333 "*_linux_unittest.h", | |
| 334 "*_linux_unittest.cc", | |
| 335 "*\blinux/*", | |
| 336 ] | |
| 337 } | |
| 338 if (!is_android) { | |
| 339 sources_assignment_filter += [ | |
| 340 "*_android.h", | |
| 341 "*_android.cc", | |
| 342 "*_android_unittest.h", | |
| 343 "*_android_unittest.cc", | |
| 344 "*\bandroid/*", | |
| 345 ] | |
| 346 } | |
| 347 if (!is_chromeos) { | |
| 348 sources_assignment_filter += [ | |
| 349 "*_chromeos.h", | |
| 350 "*_chromeos.cc", | |
| 351 "*_chromeos_unittest.h", | |
| 352 "*_chromeos_unittest.cc", | |
| 353 "*\bchromeos/*", | |
| 354 ] | |
| 355 } | |
| 356 | |
| 357 # DO NOT ADD MORE PATTERNS TO THIS LIST, see set_sources_assignment_filter call | |
| 358 # below. | |
| 359 | |
| 360 # Actually save this list. | |
| 361 # | |
| 362 # These patterns are executed for every file in the source tree of every run. | |
| 363 # Therefore, adding more patterns slows down the build for everybody. We should | |
| 364 # only add automatic patterns for configurations affecting hundreds of files | |
| 365 # across many projects in the tree. | |
| 366 # | |
| 367 # Therefore, we only add rules to this list corresponding to platforms on the | |
| 368 # Chromium waterfall. This is not for non-officially-supported platforms | |
| 369 # (FreeBSD, etc.) toolkits, (X11, GTK, etc.), or features. For these cases, | |
| 370 # write a conditional in the target to remove the file(s) from the list when | |
| 371 # your platform/toolkit/feature doesn't apply. | |
| 372 set_sources_assignment_filter(sources_assignment_filter) | |
| 373 | |
| 374 # ============================================================================= | |
| 375 # BUILD OPTIONS | 192 # BUILD OPTIONS |
| 376 # ============================================================================= | 193 # ============================================================================= |
| 377 | 194 |
| 378 # These Sanitizers all imply using the Clang compiler. On Windows they either | 195 # These Sanitizers all imply using the Clang compiler. On Windows they either |
| 379 # don't work or work differently. | 196 # don't work or work differently. |
| 380 if (!is_clang && (is_asan || is_lsan || is_tsan || is_msan)) { | 197 if (!is_clang && (is_asan || is_lsan || is_tsan || is_msan)) { |
| 381 is_clang = true | 198 is_clang = true |
| 382 } | 199 } |
| 383 | 200 |
| 384 # ============================================================================= | 201 # ============================================================================= |
| 385 # TARGET DEFAULTS | 202 # TARGET DEFAULTS |
| 386 # ============================================================================= | 203 # ============================================================================= |
| 387 # | 204 # |
| 388 # Set up the default configuration for every build target of the given type. | 205 # Set up the default configuration for every build target of the given type. |
| 389 # The values configured here will be automatically set on the scope of the | 206 # The values configured here will be automatically set on the scope of the |
| 390 # corresponding target. Target definitions can add or remove to the settings | 207 # corresponding target. Target definitions can add or remove to the settings |
| 391 # here as needed. | 208 # here as needed. |
| 392 | 209 |
| 393 # Holds all configs used for making native executables and libraries, to avoid | 210 # Holds all configs used for making native executables and libraries, to avoid |
| 394 # duplication in each target below. | 211 # duplication in each target below. |
| 395 _native_compiler_configs = [ | 212 _native_compiler_configs = [ |
| 396 "//build/config:feature_flags", | |
| 397 "//build/config/compiler:compiler", | 213 "//build/config/compiler:compiler", |
| 398 "//build/config/compiler:compiler_arm_fpu", | 214 "//build/config/compiler:compiler_arm_fpu", |
| 399 "//build/config/compiler:chromium_code", | 215 "//build/config/compiler:chromium_code", |
| 400 "//build/config/compiler:default_include_dirs", | 216 "//build/config/compiler:default_include_dirs", |
| 401 "//build/config/compiler:no_rtti", | 217 "//build/config/compiler:no_rtti", |
| 402 "//build/config/compiler:runtime_library", | 218 "//build/config/compiler:runtime_library", |
| 403 ] | 219 ] |
| 404 if (is_win) { | 220 if (is_win) { |
| 405 _native_compiler_configs += [ | 221 _native_compiler_configs += [ |
| 406 "//build/config/win:lean_and_mean", | 222 "//build/config/win:lean_and_mean", |
| 407 "//build/config/win:nominmax", | 223 "//build/config/win:nominmax", |
| 408 "//build/config/win:sdk", | 224 "//build/config/win:sdk", |
| 409 "//build/config/win:unicode", | 225 "//build/config/win:unicode", |
| 410 "//build/config/win:winver", | 226 "//build/config/win:winver", |
| 411 ] | 227 ] |
| 412 } | 228 } |
| 413 if (is_posix) { | 229 if (is_posix) { |
| 414 _native_compiler_configs += [ | 230 _native_compiler_configs += [ |
| 415 "//build/config/gcc:no_exceptions", | 231 "//build/config/gcc:no_exceptions", |
| 416 "//build/config/gcc:symbol_visibility_hidden", | |
| 417 ] | 232 ] |
| 418 } | 233 } |
| 419 | 234 |
| 420 if (is_fnl) { | 235 if (is_linux) { |
| 421 _native_compiler_configs += [ "//build/config/fnl:sdk" ] | |
| 422 } else if (is_linux) { | |
| 423 _native_compiler_configs += [ "//build/config/linux:sdk" ] | 236 _native_compiler_configs += [ "//build/config/linux:sdk" ] |
| 424 } else if (is_mac) { | 237 } else if (is_mac) { |
| 425 _native_compiler_configs += [ "//build/config/mac:sdk" ] | 238 _native_compiler_configs += [ "//build/config/mac:sdk" ] |
| 426 } else if (is_ios) { | |
| 427 _native_compiler_configs += [ "//build/config/ios:sdk" ] | |
| 428 } else if (is_android) { | 239 } else if (is_android) { |
| 429 _native_compiler_configs += [ "//build/config/android:sdk" ] | 240 _native_compiler_configs += [ "//build/config/android:sdk" ] |
| 430 } | 241 } |
| 431 | 242 |
| 432 if (is_clang) { | 243 if (is_clang) { |
| 433 _native_compiler_configs += [ | 244 _native_compiler_configs += [ |
| 434 "//build/config/clang:find_bad_constructs", | 245 "//build/config/clang:find_bad_constructs", |
| 435 "//build/config/clang:extra_warnings", | 246 "//build/config/clang:extra_warnings", |
| 436 ] | 247 ] |
| 437 } | 248 } |
| 438 | 249 |
| 439 # Optimizations and debug checking. | 250 # Optimizations and debug checking. |
| 440 if (is_debug) { | 251 if (is_debug) { |
| 441 _native_compiler_configs += [ "//build/config:debug" ] | 252 _native_compiler_configs += [ "//build/config:debug" ] |
| 442 _default_optimization_config = "//build/config/compiler:no_optimize" | 253 _default_optimization_config = "//build/config/compiler:no_optimize" |
| 254 } else if (is_release) { |
| 255 _native_compiler_configs += [ "//build/config:release" ] |
| 256 _default_optimization_config = "//build/config/compiler:optimize" |
| 443 } else { | 257 } else { |
| 444 _native_compiler_configs += [ "//build/config:release" ] | 258 assert(is_product) |
| 259 _native_compiler_configs += [ "//build/config:product" ] |
| 445 _default_optimization_config = "//build/config/compiler:optimize" | 260 _default_optimization_config = "//build/config/compiler:optimize" |
| 446 } | 261 } |
| 447 _native_compiler_configs += [ _default_optimization_config ] | 262 _native_compiler_configs += [ _default_optimization_config ] |
| 448 | 263 |
| 449 # If it wasn't manually set, set to an appropriate default. | |
| 450 if (symbol_level == -1) { | |
| 451 # Linux is slowed by having symbols as part of the target binary, whereas | |
| 452 # Mac and Windows have them separate, so in Release Linux, default them off. | |
| 453 if (is_debug || !is_linux) { | |
| 454 symbol_level = 2 | |
| 455 } else if (is_asan || is_lsan || is_tsan || is_msan) { | |
| 456 # Sanitizers require symbols for filename suppressions to work. | |
| 457 symbol_level = 1 | |
| 458 } else { | |
| 459 symbol_level = 0 | |
| 460 } | |
| 461 } | |
| 462 | |
| 463 # Symbol setup. | 264 # Symbol setup. |
| 464 if (symbol_level == 2) { | 265 _default_symbols_config = "//build/config/compiler:symbols" |
| 465 _default_symbols_config = "//build/config/compiler:symbols" | |
| 466 } else if (symbol_level == 1) { | |
| 467 _default_symbols_config = "//build/config/compiler:minimal_symbols" | |
| 468 } else if (symbol_level == 0) { | |
| 469 _default_symbols_config = "//build/config/compiler:no_symbols" | |
| 470 } else { | |
| 471 assert(false, "Bad value for symbol_level.") | |
| 472 } | |
| 473 _native_compiler_configs += [ _default_symbols_config ] | 266 _native_compiler_configs += [ _default_symbols_config ] |
| 474 | 267 |
| 475 # Windows linker setup for EXEs and DLLs. | 268 # Windows linker setup for EXEs and DLLs. |
| 476 if (is_win) { | 269 if (is_win) { |
| 477 _windows_linker_configs = [ | 270 _windows_linker_configs = [ |
| 478 "//build/config/win:default_incremental_linking", | 271 "//build/config/win:default_incremental_linking", |
| 479 "//build/config/win:sdk_link", | 272 "//build/config/win:sdk_link", |
| 480 "//build/config/win:common_linker_setup", | 273 "//build/config/win:common_linker_setup", |
| 481 | 274 |
| 482 # Default to console-mode apps. Most of our targets are tests and such | 275 # Default to console-mode apps. Most of our targets are tests and such |
| 483 # that shouldn't use the windows subsystem. | 276 # that shouldn't use the windows subsystem. |
| 484 "//build/config/win:console", | 277 "//build/config/win:console", |
| 485 ] | 278 ] |
| 486 } | 279 } |
| 487 | 280 |
| 488 # Executable defaults. | 281 # Executable defaults. |
| 489 _executable_configs = | 282 _executable_configs = _native_compiler_configs |
| 490 _native_compiler_configs + [ "//build/config:default_libs" ] | |
| 491 if (is_win) { | 283 if (is_win) { |
| 492 _executable_configs += _windows_linker_configs | 284 _executable_configs += _windows_linker_configs |
| 493 } else if (is_mac) { | 285 } else if (is_mac) { |
| 494 _executable_configs += [ | 286 _executable_configs += [ |
| 495 "//build/config/mac:mac_dynamic_flags", | 287 "//build/config/mac:mac_dynamic_flags", |
| 496 "//build/config/mac:mac_executable_flags", | 288 "//build/config/mac:mac_executable_flags", |
| 497 ] | 289 ] |
| 498 } else if (is_linux || is_android) { | 290 } else if (is_linux || is_android) { |
| 499 _executable_configs += [ "//build/config/gcc:executable_ldconfig" ] | 291 _executable_configs += [ "//build/config/gcc:executable_ldconfig" ] |
| 500 if (is_android) { | 292 if (is_android) { |
| 501 _executable_configs += [ "//build/config/android:executable_config" ] | 293 _executable_configs += [ "//build/config/android:executable_config" ] |
| 502 } | 294 } |
| 503 } | 295 } |
| 504 set_defaults("executable") { | 296 set_defaults("executable") { |
| 505 configs = _executable_configs | 297 configs = _executable_configs |
| 506 } | 298 } |
| 507 | 299 |
| 508 # Static library defaults. | 300 # Static library defaults. |
| 509 set_defaults("static_library") { | 301 set_defaults("static_library") { |
| 510 configs = _native_compiler_configs | 302 configs = _native_compiler_configs |
| 511 } | 303 } |
| 512 | 304 |
| 513 # Shared library defaults (also for components in component mode). | 305 # Shared library defaults (also for components in component mode). |
| 514 _shared_library_configs = | 306 _shared_library_configs = _native_compiler_configs |
| 515 _native_compiler_configs + [ "//build/config:default_libs" ] | |
| 516 if (is_win) { | 307 if (is_win) { |
| 517 _shared_library_configs += _windows_linker_configs | 308 _shared_library_configs += _windows_linker_configs |
| 518 } else if (is_mac) { | 309 } else if (is_mac) { |
| 519 _shared_library_configs += [ "//build/config/mac:mac_dynamic_flags" ] | 310 _shared_library_configs += [ "//build/config/mac:mac_dynamic_flags" ] |
| 520 } else if (is_android) { | 311 } else if (is_android) { |
| 521 # Strip native JNI exports from shared libraries by default. Binaries that | 312 # Strip native JNI exports from shared libraries by default. Binaries that |
| 522 # want this can remove this config. | 313 # want this can remove this config. |
| 523 _shared_library_configs += | 314 _shared_library_configs += |
| 524 [ "//build/config/android:hide_native_jni_exports" ] | 315 [ "//build/config/android:hide_native_jni_exports" ] |
| 525 } | 316 } |
| 526 set_defaults("shared_library") { | 317 set_defaults("shared_library") { |
| 527 configs = _shared_library_configs | 318 configs = _shared_library_configs |
| 528 } | 319 } |
| 529 if (is_component_build) { | |
| 530 set_defaults("component") { | |
| 531 configs = _shared_library_configs | |
| 532 } | |
| 533 } | |
| 534 | 320 |
| 535 # Source set defaults (also for components in non-component mode). | 321 # Source set defaults (also for components in non-component mode). |
| 536 set_defaults("source_set") { | 322 set_defaults("source_set") { |
| 537 configs = _native_compiler_configs | 323 configs = _native_compiler_configs |
| 538 } | 324 } |
| 539 if (!is_component_build) { | 325 set_defaults("component") { |
| 540 set_defaults("component") { | 326 configs = _native_compiler_configs |
| 541 configs = _native_compiler_configs | |
| 542 } | |
| 543 } | |
| 544 | |
| 545 # Test defaults. | |
| 546 set_defaults("test") { | |
| 547 if (is_android) { | |
| 548 configs = _shared_library_configs | |
| 549 } else { | |
| 550 configs = _executable_configs | |
| 551 } | |
| 552 } | 327 } |
| 553 | 328 |
| 554 # ============================================================================== | 329 # ============================================================================== |
| 555 # TOOLCHAIN SETUP | 330 # TOOLCHAIN SETUP |
| 556 # ============================================================================== | 331 # ============================================================================== |
| 557 # | 332 # |
| 558 # Here we set the default toolchain, as well as the variable host_toolchain | 333 # Here we set the default toolchain, as well as the variable host_toolchain |
| 559 # which will identify the toolchain corresponding to the local system when | 334 # which will identify the toolchain corresponding to the local system when |
| 560 # doing cross-compiles. When not cross-compiling, this will be the same as the | 335 # doing cross-compiles. When not cross-compiling, this will be the same as the |
| 561 # default toolchain. | 336 # default toolchain. |
| 562 | 337 |
| 563 if (is_win) { | 338 if (is_win) { |
| 564 # On windows we use the same toolchain for host and target by default. | 339 # On windows we use the same toolchain for host and target by default. |
| 565 if (is_clang) { | 340 if (is_clang) { |
| 566 host_toolchain = "//build/toolchain/win:clang_$current_cpu" | 341 host_toolchain = "//build/toolchain/win:clang_$current_cpu" |
| 567 } else { | 342 } else { |
| 568 host_toolchain = "//build/toolchain/win:$current_cpu" | 343 host_toolchain = "//build/toolchain/win:$current_cpu" |
| 569 } | 344 } |
| 570 set_default_toolchain("$host_toolchain") | 345 set_default_toolchain("$host_toolchain") |
| 571 } else if (is_android) { | 346 } else if (is_android) { |
| 572 if (host_os == "linux") { | 347 if (host_os == "linux") { |
| 573 # Use clang for the x86/64 Linux host builds. | |
| 574 if (host_cpu == "x86" || host_cpu == "x64") { | 348 if (host_cpu == "x86" || host_cpu == "x64") { |
| 575 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" | 349 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" |
| 576 } else { | 350 } else { |
| 577 host_toolchain = "//build/toolchain/linux:$host_cpu" | 351 host_toolchain = "//build/toolchain/linux:$host_cpu" |
| 578 } | 352 } |
| 579 } else if (host_os == "mac") { | 353 } else if (host_os == "mac") { |
| 580 host_toolchain = "//build/toolchain/mac:clang_$host_cpu" | 354 host_toolchain = "//build/toolchain/mac:clang_$host_cpu" |
| 581 } else { | 355 } else { |
| 582 assert(false, "Unknown host for android cross compile") | 356 assert(false, "Unknown host for android cross compile") |
| 583 } | 357 } |
| 584 if (is_clang) { | 358 if (is_clang) { |
| 585 set_default_toolchain("//build/toolchain/android:clang_$current_cpu") | 359 set_default_toolchain("//build/toolchain/android:clang_$current_cpu") |
| 586 } else { | 360 } else { |
| 587 set_default_toolchain("//build/toolchain/android:$current_cpu") | 361 set_default_toolchain("//build/toolchain/android:$current_cpu") |
| 588 } | 362 } |
| 589 } else if (is_linux) { | 363 } else if (is_linux) { |
| 590 if (is_clang) { | 364 if (is_clang) { |
| 591 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" | 365 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" |
| 592 set_default_toolchain("//build/toolchain/linux:clang_$current_cpu") | 366 set_default_toolchain("//build/toolchain/linux:clang_$current_cpu") |
| 593 } else { | 367 } else { |
| 594 host_toolchain = "//build/toolchain/linux:$host_cpu" | 368 host_toolchain = "//build/toolchain/linux:$host_cpu" |
| 595 set_default_toolchain("//build/toolchain/linux:$current_cpu") | 369 set_default_toolchain("//build/toolchain/linux:$current_cpu") |
| 596 } | 370 } |
| 597 if (is_chromeos && cros_use_custom_toolchain) { | |
| 598 set_default_toolchain("//build/toolchain/cros:target") | |
| 599 } | |
| 600 if (is_fnl) { | |
| 601 set_default_toolchain("//build/toolchain/fnl:target") | |
| 602 } | |
| 603 } else if (is_mac) { | 371 } else if (is_mac) { |
| 604 host_toolchain = "//build/toolchain/mac:clang_x64" | 372 host_toolchain = "//build/toolchain/mac:clang_x64" |
| 605 set_default_toolchain(host_toolchain) | 373 set_default_toolchain(host_toolchain) |
| 606 } else if (is_ios) { | |
| 607 host_toolchain = "//build/toolchain/mac:clang_x64" | |
| 608 if (use_ios_simulator) { | |
| 609 set_default_toolchain("//build/toolchain/mac:ios_clang_x64") | |
| 610 } else { | |
| 611 set_default_toolchain("//build/toolchain/mac:ios_clang_arm") | |
| 612 } | |
| 613 } else if (is_nacl) { | |
| 614 # TODO(GYP): This will need to change when we get NaCl working | |
| 615 # on multiple platforms, but this whole block of code (how we define | |
| 616 # host_toolchain) needs to be reworked regardless to key off of host_os | |
| 617 # and host_cpu rather than the is_* variables. | |
| 618 host_toolchain = "//build/toolchain/linux:clang_x64" | |
| 619 } | 374 } |
| 620 | 375 |
| 621 # ============================================================================== | 376 # ============================================================================== |
| 622 # COMPONENT SETUP | 377 # COMPONENT SETUP |
| 623 # ============================================================================== | 378 # ============================================================================== |
| 624 | 379 |
| 625 # TODO(brettw) erase this once the built-in "component" function is removed. | 380 # Don't try to do component builds for the standalone Dart VM. |
| 626 if (is_component_build) { | 381 assert(!is_component_build) |
| 627 component_mode = "shared_library" | 382 component_mode = "source_set" |
| 628 } else { | |
| 629 component_mode = "source_set" | |
| 630 } | |
| 631 | 383 |
| 632 template("component") { | 384 template("component") { |
| 633 if (is_component_build) { | 385 source_set(target_name) { |
| 634 shared_library(target_name) { | 386 # See above. |
| 635 # Configs will always be defined since we set_defaults for a component | 387 configs = [] # Prevent list overwriting warning. |
| 636 # above. We want to use those rather than whatever came with the nested | 388 configs = invoker.configs |
| 637 # shared/static library inside the component. | |
| 638 configs = [] # Prevent list overwriting warning. | |
| 639 configs = invoker.configs | |
| 640 | 389 |
| 641 # The sources assignment filter will have already been applied when the | 390 # See above call. |
| 642 # code was originally executed. We don't want to apply it again, since | 391 set_sources_assignment_filter([]) |
| 643 # the original target may have override it for some assignments. | |
| 644 set_sources_assignment_filter([]) | |
| 645 | 392 |
| 646 if (defined(invoker.all_dependent_configs)) { | 393 if (defined(invoker.all_dependent_configs)) { |
| 647 all_dependent_configs = invoker.all_dependent_configs | 394 all_dependent_configs = invoker.all_dependent_configs |
| 648 } | |
| 649 if (defined(invoker.allow_circular_includes_from)) { | |
| 650 allow_circular_includes_from = invoker.allow_circular_includes_from | |
| 651 } | |
| 652 if (defined(invoker.cflags)) { | |
| 653 cflags = invoker.cflags | |
| 654 } | |
| 655 if (defined(invoker.cflags_c)) { | |
| 656 cflags_c = invoker.cflags_c | |
| 657 } | |
| 658 if (defined(invoker.cflags_cc)) { | |
| 659 cflags_cc = invoker.cflags_cc | |
| 660 } | |
| 661 if (defined(invoker.cflags_objc)) { | |
| 662 cflags_objc = invoker.cflags_objc | |
| 663 } | |
| 664 if (defined(invoker.cflags_objcc)) { | |
| 665 cflags_objcc = invoker.cflags_objcc | |
| 666 } | |
| 667 if (defined(invoker.check_includes)) { | |
| 668 check_includes = invoker.check_includes | |
| 669 } | |
| 670 if (defined(invoker.data)) { | |
| 671 data = invoker.data | |
| 672 } | |
| 673 if (defined(invoker.data_deps)) { | |
| 674 data_deps = invoker.data_deps | |
| 675 } | |
| 676 if (defined(invoker.datadeps)) { | |
| 677 datadeps = invoker.datadeps | |
| 678 } | |
| 679 if (defined(invoker.defines)) { | |
| 680 defines = invoker.defines | |
| 681 } | |
| 682 | |
| 683 # All shared libraries must have the sanitizer deps to properly link in | |
| 684 # asan mode (this target will be empty in other cases). | |
| 685 if (defined(invoker.deps)) { | |
| 686 deps = invoker.deps + [ "//build/config/sanitizers:deps" ] | |
| 687 } else { | |
| 688 deps = [ | |
| 689 "//build/config/sanitizers:deps", | |
| 690 ] | |
| 691 } | |
| 692 if (defined(invoker.direct_dependent_configs)) { | |
| 693 direct_dependent_configs = invoker.direct_dependent_configs | |
| 694 } | |
| 695 if (defined(invoker.forward_dependent_configs_from)) { | |
| 696 forward_dependent_configs_from = invoker.forward_dependent_configs_from | |
| 697 } | |
| 698 if (defined(invoker.include_dirs)) { | |
| 699 include_dirs = invoker.include_dirs | |
| 700 } | |
| 701 if (defined(invoker.ldflags)) { | |
| 702 ldflags = invoker.ldflags | |
| 703 } | |
| 704 if (defined(invoker.lib_dirs)) { | |
| 705 lib_dirs = invoker.lib_dirs | |
| 706 } | |
| 707 if (defined(invoker.libs)) { | |
| 708 libs = invoker.libs | |
| 709 } | |
| 710 if (defined(invoker.output_extension)) { | |
| 711 output_extension = invoker.output_extension | |
| 712 } | |
| 713 if (defined(invoker.output_name)) { | |
| 714 output_name = invoker.output_name | |
| 715 } | |
| 716 if (defined(invoker.public)) { | |
| 717 public = invoker.public | |
| 718 } | |
| 719 if (defined(invoker.public_configs)) { | |
| 720 public_configs = invoker.public_configs | |
| 721 } | |
| 722 if (defined(invoker.public_deps)) { | |
| 723 public_deps = invoker.public_deps | |
| 724 } | |
| 725 if (defined(invoker.sources)) { | |
| 726 sources = invoker.sources | |
| 727 } | |
| 728 if (defined(invoker.testonly)) { | |
| 729 testonly = invoker.testonly | |
| 730 } | |
| 731 if (defined(invoker.visibility)) { | |
| 732 visibility = invoker.visibility | |
| 733 } | |
| 734 } | 395 } |
| 735 } else { | 396 if (defined(invoker.allow_circular_includes_from)) { |
| 736 source_set(target_name) { | 397 allow_circular_includes_from = invoker.allow_circular_includes_from |
| 737 # See above. | 398 } |
| 738 configs = [] # Prevent list overwriting warning. | 399 if (defined(invoker.cflags)) { |
| 739 configs = invoker.configs | 400 cflags = invoker.cflags |
| 740 | 401 } |
| 741 # See above call. | 402 if (defined(invoker.cflags_c)) { |
| 742 set_sources_assignment_filter([]) | 403 cflags_c = invoker.cflags_c |
| 743 | 404 } |
| 744 if (defined(invoker.all_dependent_configs)) { | 405 if (defined(invoker.cflags_cc)) { |
| 745 all_dependent_configs = invoker.all_dependent_configs | 406 cflags_cc = invoker.cflags_cc |
| 746 } | 407 } |
| 747 if (defined(invoker.allow_circular_includes_from)) { | 408 if (defined(invoker.cflags_objc)) { |
| 748 allow_circular_includes_from = invoker.allow_circular_includes_from | 409 cflags_objc = invoker.cflags_objc |
| 749 } | 410 } |
| 750 if (defined(invoker.cflags)) { | 411 if (defined(invoker.cflags_objcc)) { |
| 751 cflags = invoker.cflags | 412 cflags_objcc = invoker.cflags_objcc |
| 752 } | 413 } |
| 753 if (defined(invoker.cflags_c)) { | 414 if (defined(invoker.check_includes)) { |
| 754 cflags_c = invoker.cflags_c | 415 check_includes = invoker.check_includes |
| 755 } | 416 } |
| 756 if (defined(invoker.cflags_cc)) { | 417 if (defined(invoker.data)) { |
| 757 cflags_cc = invoker.cflags_cc | 418 data = invoker.data |
| 758 } | 419 } |
| 759 if (defined(invoker.cflags_objc)) { | 420 if (defined(invoker.data_deps)) { |
| 760 cflags_objc = invoker.cflags_objc | 421 data_deps = invoker.data_deps |
| 761 } | 422 } |
| 762 if (defined(invoker.cflags_objcc)) { | 423 if (defined(invoker.datadeps)) { |
| 763 cflags_objcc = invoker.cflags_objcc | 424 datadeps = invoker.datadeps |
| 764 } | 425 } |
| 765 if (defined(invoker.check_includes)) { | 426 if (defined(invoker.defines)) { |
| 766 check_includes = invoker.check_includes | 427 defines = invoker.defines |
| 767 } | 428 } |
| 768 if (defined(invoker.data)) { | 429 if (defined(invoker.deps)) { |
| 769 data = invoker.data | 430 deps = invoker.deps |
| 770 } | 431 } |
| 771 if (defined(invoker.data_deps)) { | 432 if (defined(invoker.direct_dependent_configs)) { |
| 772 data_deps = invoker.data_deps | 433 direct_dependent_configs = invoker.direct_dependent_configs |
| 773 } | 434 } |
| 774 if (defined(invoker.datadeps)) { | 435 if (defined(invoker.forward_dependent_configs_from)) { |
| 775 datadeps = invoker.datadeps | 436 forward_dependent_configs_from = invoker.forward_dependent_configs_from |
| 776 } | 437 } |
| 777 if (defined(invoker.defines)) { | 438 if (defined(invoker.include_dirs)) { |
| 778 defines = invoker.defines | 439 include_dirs = invoker.include_dirs |
| 779 } | 440 } |
| 780 if (defined(invoker.deps)) { | 441 if (defined(invoker.ldflags)) { |
| 781 deps = invoker.deps | 442 ldflags = invoker.ldflags |
| 782 } | 443 } |
| 783 if (defined(invoker.direct_dependent_configs)) { | 444 if (defined(invoker.lib_dirs)) { |
| 784 direct_dependent_configs = invoker.direct_dependent_configs | 445 lib_dirs = invoker.lib_dirs |
| 785 } | 446 } |
| 786 if (defined(invoker.forward_dependent_configs_from)) { | 447 if (defined(invoker.libs)) { |
| 787 forward_dependent_configs_from = invoker.forward_dependent_configs_from | 448 libs = invoker.libs |
| 788 } | 449 } |
| 789 if (defined(invoker.include_dirs)) { | 450 if (defined(invoker.output_extension)) { |
| 790 include_dirs = invoker.include_dirs | 451 output_extension = invoker.output_extension |
| 791 } | 452 } |
| 792 if (defined(invoker.ldflags)) { | 453 if (defined(invoker.output_name)) { |
| 793 ldflags = invoker.ldflags | 454 output_name = invoker.output_name |
| 794 } | 455 } |
| 795 if (defined(invoker.lib_dirs)) { | 456 if (defined(invoker.public)) { |
| 796 lib_dirs = invoker.lib_dirs | 457 public = invoker.public |
| 797 } | 458 } |
| 798 if (defined(invoker.libs)) { | 459 if (defined(invoker.public_configs)) { |
| 799 libs = invoker.libs | 460 public_configs = invoker.public_configs |
| 800 } | 461 } |
| 801 if (defined(invoker.output_extension)) { | 462 if (defined(invoker.public_deps)) { |
| 802 output_extension = invoker.output_extension | 463 public_deps = invoker.public_deps |
| 803 } | 464 } |
| 804 if (defined(invoker.output_name)) { | 465 if (defined(invoker.sources)) { |
| 805 output_name = invoker.output_name | 466 sources = invoker.sources |
| 806 } | 467 } |
| 807 if (defined(invoker.public)) { | 468 if (defined(invoker.testonly)) { |
| 808 public = invoker.public | 469 testonly = invoker.testonly |
| 809 } | 470 } |
| 810 if (defined(invoker.public_configs)) { | 471 if (defined(invoker.visibility)) { |
| 811 public_configs = invoker.public_configs | 472 visibility = invoker.visibility |
| 812 } | |
| 813 if (defined(invoker.public_deps)) { | |
| 814 public_deps = invoker.public_deps | |
| 815 } | |
| 816 if (defined(invoker.sources)) { | |
| 817 sources = invoker.sources | |
| 818 } | |
| 819 if (defined(invoker.testonly)) { | |
| 820 testonly = invoker.testonly | |
| 821 } | |
| 822 if (defined(invoker.visibility)) { | |
| 823 visibility = invoker.visibility | |
| 824 } | |
| 825 } | 473 } |
| 826 } | 474 } |
| 827 } | 475 } |
| OLD | NEW |