OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 # ============================================================================= |
| 6 # PLATFORM SELECTION |
| 7 # ============================================================================= |
| 8 # |
| 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. |
| 11 # |
| 12 # Users typically only set the variables "target_os" and "target_cpu" in "gn |
| 13 # args", the rest are set up by our build and internal to GN. |
| 14 # |
| 15 # There are three different types of each of these things: The "host" |
| 16 # represents the computer doing the compile and never changes. The "target" |
| 17 # represents the main thing we're trying to build. The "current" represents |
| 18 # which configuration is currently being defined, which can be either the |
| 19 # host, the target, or something completely different (like nacl). GN will |
| 20 # run the same build file multiple times for the different required |
| 21 # configuration in the same build. |
| 22 # |
| 23 # This gives the following variables: |
| 24 # - host_os, host_cpu, host_toolchain |
| 25 # - target_os, target_cpu, default_toolchain |
| 26 # - current_os, current_cpu, current_toolchain. |
| 27 # |
| 28 # Note the default_toolchain isn't symmetrical (you would expect |
| 29 # target_toolchain). This is because the "default" toolchain is a GN built-in |
| 30 # concept, and "target" is something our build sets up that's symmetrical with |
| 31 # its GYP counterpart. Potentially the built-in default_toolchain variable |
| 32 # could be renamed in the future. |
| 33 # |
| 34 # When writing build files, to do something only for the host: |
| 35 # if (current_toolchain == host_toolchain) { ... |
| 36 |
| 37 if (target_os == "") { |
| 38 target_os = host_os |
| 39 } |
| 40 |
| 41 if (target_cpu == "") { |
| 42 if (target_os == "android") { |
| 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 |
| 53 if (current_cpu == "") { |
| 54 current_cpu = target_cpu |
| 55 } |
| 56 if (current_os == "") { |
| 57 current_os = target_os |
| 58 } |
| 59 |
| 60 # ============================================================================= |
| 61 # BUILD FLAGS |
| 62 # ============================================================================= |
| 63 # |
| 64 # This block lists input arguments to the build, along with their default |
| 65 # values. |
| 66 # |
| 67 # If a value is specified on the command line, it will overwrite the defaults |
| 68 # given in a declare_args block, otherwise the default will be used. |
| 69 # |
| 70 # YOU SHOULD ALMOST NEVER NEED TO ADD FLAGS TO THIS FILE. GN allows any file in |
| 71 # the build to declare build flags. If you need a flag for a single component, |
| 72 # you can just declare it in the corresponding BUILD.gn file. If you need a |
| 73 # flag in multiple components, there are a few options: |
| 74 # |
| 75 # - If your feature is a single target, say //components/foo, and the targets |
| 76 # depending on foo need to have some define set if foo is enabled: (1) Write |
| 77 # a declare_args block in foo's BUILD.gn file listing your enable_foo build |
| 78 # flag. (2) Write a config in that file listing the define, and list that |
| 79 # config in foo's public_configs. This will propagate that define to all the |
| 80 # targets depending on foo. (3) When foo is not enabled, just make it expand |
| 81 # to an empty group (or whatever's appropriate for the "off" state of your |
| 82 # feature. |
| 83 # |
| 84 # - If a semi-random set of targets need to know about a define: (1) In the |
| 85 # lowest level of the build that knows about this feature, add a declare_args |
| 86 # block in the build file for your enable flag. (2) Write a config that adds |
| 87 # a define conditionally based on that build flags. (3) Manually add that |
| 88 # config to the "configs" applying to the targets that need the define. |
| 89 # |
| 90 # - If a semi-random set of targets need to know about the build flag (to do |
| 91 # file inclusion or exclusion, more than just defines): (1) Write a .gni file |
| 92 # in the lowest-level directory that knows about the feature. (2) Put the |
| 93 # declare_args block with your build flag in that .gni file. (3) Import that |
| 94 # .gni file from the BUILD.gn files that need the flag. |
| 95 # |
| 96 # Other advice: |
| 97 # |
| 98 # - Use boolean values when possible. If you need a default value that expands |
| 99 # to some complex thing in the default case (like the location of the |
| 100 # compiler which would be computed by a script), use a default value of -1 or |
| 101 # the empty string. Outside of the declare_args block, conditionally expand |
| 102 # the default value as necessary. |
| 103 # |
| 104 # - Use a name like "use_foo" or "is_foo" (whatever is more appropriate for |
| 105 # your feature) rather than just "foo". |
| 106 # |
| 107 # - Write good comments directly above the declaration with no blank line. |
| 108 # These comments will appear as documentation in "gn args --list". |
| 109 # |
| 110 # - 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. |
| 112 |
| 113 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. |
| 126 is_debug = true |
| 127 |
| 128 # Whether we're a traditional desktop unix. |
| 129 is_desktop_linux = current_os == "linux" && current_os != "chromeos" |
| 130 |
| 131 # Set to true when compiling with the Clang compiler. Typically this is used |
| 132 # to configure warnings. |
| 133 is_clang = current_os == "mac" || current_os == "ios" || |
| 134 current_os == "linux" || current_os == "chromeos" |
| 135 |
| 136 # Compile for Address Sanitizer to find memory bugs. |
| 137 is_asan = false |
| 138 |
| 139 # Compile for Leak Sanitizer to find leaks. |
| 140 is_lsan = false |
| 141 |
| 142 # Compile for Memory Sanitizer to find uninitialized reads. |
| 143 is_msan = false |
| 144 |
| 145 # Compile for Thread Sanitizer to find threading bugs. |
| 146 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 } |
| 157 |
| 158 # ============================================================================= |
| 159 # OS DEFINITIONS |
| 160 # ============================================================================= |
| 161 # |
| 162 # We set these various is_FOO booleans for convenience in writing OS-based |
| 163 # conditions. |
| 164 # |
| 165 # - 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. |
| 167 # - is_posix is true for mac and any Unix-like system (basically everything |
| 168 # except Windows). |
| 169 # - 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). |
| 171 # |
| 172 # 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 |
| 174 # current_os value directly. |
| 175 |
| 176 if (current_os == "win") { |
| 177 is_android = false |
| 178 is_chromeos = false |
| 179 is_fnl = false |
| 180 is_ios = false |
| 181 is_linux = false |
| 182 is_mac = false |
| 183 is_nacl = false |
| 184 is_posix = false |
| 185 is_win = true |
| 186 } else if (current_os == "mac") { |
| 187 is_android = false |
| 188 is_chromeos = false |
| 189 is_fnl = false |
| 190 is_ios = false |
| 191 is_linux = false |
| 192 is_mac = true |
| 193 is_nacl = false |
| 194 is_posix = true |
| 195 is_win = false |
| 196 } else if (current_os == "android") { |
| 197 is_android = true |
| 198 is_chromeos = false |
| 199 is_fnl = false |
| 200 is_ios = false |
| 201 is_linux = false |
| 202 is_mac = false |
| 203 is_nacl = false |
| 204 is_posix = true |
| 205 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") { |
| 240 is_android = false |
| 241 is_chromeos = false |
| 242 is_fnl = false |
| 243 is_ios = false |
| 244 is_linux = true |
| 245 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 |
| 257 is_posix = true |
| 258 is_win = false |
| 259 } |
| 260 |
| 261 # ============================================================================= |
| 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 |
| 376 # ============================================================================= |
| 377 |
| 378 # These Sanitizers all imply using the Clang compiler. On Windows they either |
| 379 # don't work or work differently. |
| 380 if (!is_clang && (is_asan || is_lsan || is_tsan || is_msan)) { |
| 381 is_clang = true |
| 382 } |
| 383 |
| 384 # ============================================================================= |
| 385 # TARGET DEFAULTS |
| 386 # ============================================================================= |
| 387 # |
| 388 # 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 |
| 390 # corresponding target. Target definitions can add or remove to the settings |
| 391 # here as needed. |
| 392 |
| 393 # Holds all configs used for making native executables and libraries, to avoid |
| 394 # duplication in each target below. |
| 395 _native_compiler_configs = [ |
| 396 "//build/config:feature_flags", |
| 397 "//build/config/compiler:compiler", |
| 398 "//build/config/compiler:compiler_arm_fpu", |
| 399 "//build/config/compiler:chromium_code", |
| 400 "//build/config/compiler:default_include_dirs", |
| 401 "//build/config/compiler:no_rtti", |
| 402 "//build/config/compiler:runtime_library", |
| 403 ] |
| 404 if (is_win) { |
| 405 _native_compiler_configs += [ |
| 406 "//build/config/win:lean_and_mean", |
| 407 "//build/config/win:nominmax", |
| 408 "//build/config/win:sdk", |
| 409 "//build/config/win:unicode", |
| 410 "//build/config/win:winver", |
| 411 ] |
| 412 } |
| 413 if (is_posix) { |
| 414 _native_compiler_configs += [ |
| 415 "//build/config/gcc:no_exceptions", |
| 416 "//build/config/gcc:symbol_visibility_hidden", |
| 417 ] |
| 418 } |
| 419 |
| 420 if (is_fnl) { |
| 421 _native_compiler_configs += [ "//build/config/fnl:sdk" ] |
| 422 } else if (is_linux) { |
| 423 _native_compiler_configs += [ "//build/config/linux:sdk" ] |
| 424 } else if (is_mac) { |
| 425 _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) { |
| 429 _native_compiler_configs += [ "//build/config/android:sdk" ] |
| 430 } |
| 431 |
| 432 if (is_clang) { |
| 433 _native_compiler_configs += [ |
| 434 "//build/config/clang:find_bad_constructs", |
| 435 "//build/config/clang:extra_warnings", |
| 436 ] |
| 437 } |
| 438 |
| 439 # Optimizations and debug checking. |
| 440 if (is_debug) { |
| 441 _native_compiler_configs += [ "//build/config:debug" ] |
| 442 _default_optimization_config = "//build/config/compiler:no_optimize" |
| 443 } else { |
| 444 _native_compiler_configs += [ "//build/config:release" ] |
| 445 _default_optimization_config = "//build/config/compiler:optimize" |
| 446 } |
| 447 _native_compiler_configs += [ _default_optimization_config ] |
| 448 |
| 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. |
| 464 if (symbol_level == 2) { |
| 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 ] |
| 474 |
| 475 # Windows linker setup for EXEs and DLLs. |
| 476 if (is_win) { |
| 477 _windows_linker_configs = [ |
| 478 "//build/config/win:default_incremental_linking", |
| 479 "//build/config/win:sdk_link", |
| 480 "//build/config/win:common_linker_setup", |
| 481 |
| 482 # Default to console-mode apps. Most of our targets are tests and such |
| 483 # that shouldn't use the windows subsystem. |
| 484 "//build/config/win:console", |
| 485 ] |
| 486 } |
| 487 |
| 488 # Executable defaults. |
| 489 _executable_configs = |
| 490 _native_compiler_configs + [ "//build/config:default_libs" ] |
| 491 if (is_win) { |
| 492 _executable_configs += _windows_linker_configs |
| 493 } else if (is_mac) { |
| 494 _executable_configs += [ |
| 495 "//build/config/mac:mac_dynamic_flags", |
| 496 "//build/config/mac:mac_executable_flags", |
| 497 ] |
| 498 } else if (is_linux || is_android) { |
| 499 _executable_configs += [ "//build/config/gcc:executable_ldconfig" ] |
| 500 if (is_android) { |
| 501 _executable_configs += [ "//build/config/android:executable_config" ] |
| 502 } |
| 503 } |
| 504 set_defaults("executable") { |
| 505 configs = _executable_configs |
| 506 } |
| 507 |
| 508 # Static library defaults. |
| 509 set_defaults("static_library") { |
| 510 configs = _native_compiler_configs |
| 511 } |
| 512 |
| 513 # Shared library defaults (also for components in component mode). |
| 514 _shared_library_configs = |
| 515 _native_compiler_configs + [ "//build/config:default_libs" ] |
| 516 if (is_win) { |
| 517 _shared_library_configs += _windows_linker_configs |
| 518 } else if (is_mac) { |
| 519 _shared_library_configs += [ "//build/config/mac:mac_dynamic_flags" ] |
| 520 } else if (is_android) { |
| 521 # Strip native JNI exports from shared libraries by default. Binaries that |
| 522 # want this can remove this config. |
| 523 _shared_library_configs += |
| 524 [ "//build/config/android:hide_native_jni_exports" ] |
| 525 } |
| 526 set_defaults("shared_library") { |
| 527 configs = _shared_library_configs |
| 528 } |
| 529 if (is_component_build) { |
| 530 set_defaults("component") { |
| 531 configs = _shared_library_configs |
| 532 } |
| 533 } |
| 534 |
| 535 # Source set defaults (also for components in non-component mode). |
| 536 set_defaults("source_set") { |
| 537 configs = _native_compiler_configs |
| 538 } |
| 539 if (!is_component_build) { |
| 540 set_defaults("component") { |
| 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 } |
| 553 |
| 554 # ============================================================================== |
| 555 # TOOLCHAIN SETUP |
| 556 # ============================================================================== |
| 557 # |
| 558 # 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 |
| 560 # doing cross-compiles. When not cross-compiling, this will be the same as the |
| 561 # default toolchain. |
| 562 |
| 563 if (is_win) { |
| 564 # On windows we use the same toolchain for host and target by default. |
| 565 if (is_clang) { |
| 566 host_toolchain = "//build/toolchain/win:clang_$current_cpu" |
| 567 } else { |
| 568 host_toolchain = "//build/toolchain/win:$current_cpu" |
| 569 } |
| 570 set_default_toolchain("$host_toolchain") |
| 571 } else if (is_android) { |
| 572 if (host_os == "linux") { |
| 573 # Use clang for the x86/64 Linux host builds. |
| 574 if (host_cpu == "x86" || host_cpu == "x64") { |
| 575 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" |
| 576 } else { |
| 577 host_toolchain = "//build/toolchain/linux:$host_cpu" |
| 578 } |
| 579 } else if (host_os == "mac") { |
| 580 host_toolchain = "//build/toolchain/mac:clang_$host_cpu" |
| 581 } else { |
| 582 assert(false, "Unknown host for android cross compile") |
| 583 } |
| 584 if (is_clang) { |
| 585 set_default_toolchain("//build/toolchain/android:clang_$current_cpu") |
| 586 } else { |
| 587 set_default_toolchain("//build/toolchain/android:$current_cpu") |
| 588 } |
| 589 } else if (is_linux) { |
| 590 if (is_clang) { |
| 591 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" |
| 592 set_default_toolchain("//build/toolchain/linux:clang_$current_cpu") |
| 593 } else { |
| 594 host_toolchain = "//build/toolchain/linux:$host_cpu" |
| 595 set_default_toolchain("//build/toolchain/linux:$current_cpu") |
| 596 } |
| 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) { |
| 604 host_toolchain = "//build/toolchain/mac:clang_x64" |
| 605 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 } |
| 620 |
| 621 # ============================================================================== |
| 622 # COMPONENT SETUP |
| 623 # ============================================================================== |
| 624 |
| 625 # TODO(brettw) erase this once the built-in "component" function is removed. |
| 626 if (is_component_build) { |
| 627 component_mode = "shared_library" |
| 628 } else { |
| 629 component_mode = "source_set" |
| 630 } |
| 631 |
| 632 template("component") { |
| 633 if (is_component_build) { |
| 634 shared_library(target_name) { |
| 635 # Configs will always be defined since we set_defaults for a component |
| 636 # above. We want to use those rather than whatever came with the nested |
| 637 # shared/static library inside the component. |
| 638 configs = [] # Prevent list overwriting warning. |
| 639 configs = invoker.configs |
| 640 |
| 641 # The sources assignment filter will have already been applied when the |
| 642 # code was originally executed. We don't want to apply it again, since |
| 643 # the original target may have override it for some assignments. |
| 644 set_sources_assignment_filter([]) |
| 645 |
| 646 if (defined(invoker.all_dependent_configs)) { |
| 647 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 } |
| 735 } else { |
| 736 source_set(target_name) { |
| 737 # See above. |
| 738 configs = [] # Prevent list overwriting warning. |
| 739 configs = invoker.configs |
| 740 |
| 741 # See above call. |
| 742 set_sources_assignment_filter([]) |
| 743 |
| 744 if (defined(invoker.all_dependent_configs)) { |
| 745 all_dependent_configs = invoker.all_dependent_configs |
| 746 } |
| 747 if (defined(invoker.allow_circular_includes_from)) { |
| 748 allow_circular_includes_from = invoker.allow_circular_includes_from |
| 749 } |
| 750 if (defined(invoker.cflags)) { |
| 751 cflags = invoker.cflags |
| 752 } |
| 753 if (defined(invoker.cflags_c)) { |
| 754 cflags_c = invoker.cflags_c |
| 755 } |
| 756 if (defined(invoker.cflags_cc)) { |
| 757 cflags_cc = invoker.cflags_cc |
| 758 } |
| 759 if (defined(invoker.cflags_objc)) { |
| 760 cflags_objc = invoker.cflags_objc |
| 761 } |
| 762 if (defined(invoker.cflags_objcc)) { |
| 763 cflags_objcc = invoker.cflags_objcc |
| 764 } |
| 765 if (defined(invoker.check_includes)) { |
| 766 check_includes = invoker.check_includes |
| 767 } |
| 768 if (defined(invoker.data)) { |
| 769 data = invoker.data |
| 770 } |
| 771 if (defined(invoker.data_deps)) { |
| 772 data_deps = invoker.data_deps |
| 773 } |
| 774 if (defined(invoker.datadeps)) { |
| 775 datadeps = invoker.datadeps |
| 776 } |
| 777 if (defined(invoker.defines)) { |
| 778 defines = invoker.defines |
| 779 } |
| 780 if (defined(invoker.deps)) { |
| 781 deps = invoker.deps |
| 782 } |
| 783 if (defined(invoker.direct_dependent_configs)) { |
| 784 direct_dependent_configs = invoker.direct_dependent_configs |
| 785 } |
| 786 if (defined(invoker.forward_dependent_configs_from)) { |
| 787 forward_dependent_configs_from = invoker.forward_dependent_configs_from |
| 788 } |
| 789 if (defined(invoker.include_dirs)) { |
| 790 include_dirs = invoker.include_dirs |
| 791 } |
| 792 if (defined(invoker.ldflags)) { |
| 793 ldflags = invoker.ldflags |
| 794 } |
| 795 if (defined(invoker.lib_dirs)) { |
| 796 lib_dirs = invoker.lib_dirs |
| 797 } |
| 798 if (defined(invoker.libs)) { |
| 799 libs = invoker.libs |
| 800 } |
| 801 if (defined(invoker.output_extension)) { |
| 802 output_extension = invoker.output_extension |
| 803 } |
| 804 if (defined(invoker.output_name)) { |
| 805 output_name = invoker.output_name |
| 806 } |
| 807 if (defined(invoker.public)) { |
| 808 public = invoker.public |
| 809 } |
| 810 if (defined(invoker.public_configs)) { |
| 811 public_configs = invoker.public_configs |
| 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 } |
| 826 } |
| 827 } |
OLD | NEW |