| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 is_debug = true | 118 is_debug = true |
| 119 | 119 |
| 120 # Whether we're a traditional desktop unix. | 120 # Whether we're a traditional desktop unix. |
| 121 is_desktop_linux = current_os == "linux" && current_os != "chromeos" | 121 is_desktop_linux = current_os == "linux" && current_os != "chromeos" |
| 122 | 122 |
| 123 # Set to true when compiling with the Clang compiler. Typically this is used | 123 # Set to true when compiling with the Clang compiler. Typically this is used |
| 124 # to configure warnings. | 124 # to configure warnings. |
| 125 is_clang = current_os == "mac" || current_os == "ios" || | 125 is_clang = current_os == "mac" || current_os == "ios" || |
| 126 current_os == "linux" || current_os == "chromeos" | 126 current_os == "linux" || current_os == "chromeos" |
| 127 | 127 |
| 128 if (current_os == "chromeos") { | 128 # Allows the path to a custom target toolchain to be injected as a single |
| 129 # Allows the target toolchain to be injected as arguments. This is needed | 129 # argument, and set as the default toolchain. |
| 130 # to support the CrOS build system which supports per-build-configuration | 130 custom_toolchain = "" |
| 131 # toolchains. | |
| 132 cros_use_custom_toolchain = false | |
| 133 } | |
| 134 | 131 |
| 135 # DON'T ADD MORE FLAGS HERE. Read the comment above. | 132 # DON'T ADD MORE FLAGS HERE. Read the comment above. |
| 136 } | 133 } |
| 137 | 134 |
| 138 # ============================================================================= | 135 # ============================================================================= |
| 139 # OS DEFINITIONS | 136 # OS DEFINITIONS |
| 140 # ============================================================================= | 137 # ============================================================================= |
| 141 # | 138 # |
| 142 # 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 |
| 143 # conditions. | 140 # conditions. |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 | 479 |
| 483 # ============================================================================== | 480 # ============================================================================== |
| 484 # TOOLCHAIN SETUP | 481 # TOOLCHAIN SETUP |
| 485 # ============================================================================== | 482 # ============================================================================== |
| 486 # | 483 # |
| 487 # Here we set the default toolchain, as well as the variable host_toolchain | 484 # Here we set the default toolchain, as well as the variable host_toolchain |
| 488 # which will identify the toolchain corresponding to the local system when | 485 # which will identify the toolchain corresponding to the local system when |
| 489 # doing cross-compiles. When not cross-compiling, this will be the same as the | 486 # doing cross-compiles. When not cross-compiling, this will be the same as the |
| 490 # default toolchain. | 487 # default toolchain. |
| 491 | 488 |
| 489 _default_toolchain = "" |
| 492 if (is_win) { | 490 if (is_win) { |
| 493 # On windows we use the same toolchain for host and target by default. | 491 # On windows we use the same toolchain for host and target by default. |
| 494 if (is_clang) { | 492 if (is_clang) { |
| 495 host_toolchain = "//build/toolchain/win:clang_$current_cpu" | 493 host_toolchain = "//build/toolchain/win:clang_$current_cpu" |
| 496 } else { | 494 } else { |
| 497 host_toolchain = "//build/toolchain/win:$current_cpu" | 495 host_toolchain = "//build/toolchain/win:$current_cpu" |
| 498 } | 496 } |
| 499 | 497 |
| 500 if (current_os == "win") { | 498 if (current_os == "win") { |
| 501 set_default_toolchain("$host_toolchain") | 499 _default_toolchain = host_toolchain |
| 502 } else if (current_cpu == "x64") { # WinRT x64 | 500 } else if (current_cpu == "x64") { # WinRT x64 |
| 503 set_default_toolchain("//build/toolchain/win:winrt_x64") | 501 _default_toolchain = "//build/toolchain/win:winrt_x64" |
| 504 } else if (current_cpu == "x86") { # WinRT x86 | 502 } else if (current_cpu == "x86") { # WinRT x86 |
| 505 set_default_toolchain("//build/toolchain/win:winrt_x86") | 503 _default_toolchain = "//build/toolchain/win:winrt_x86" |
| 506 } | 504 } |
| 507 } else if (is_android) { | 505 } else if (is_android) { |
| 508 if (host_os == "linux") { | 506 if (host_os == "linux") { |
| 509 # Use clang for the x86/64 Linux host builds. | 507 # Use clang for the x86/64 Linux host builds. |
| 510 if (host_cpu == "x86" || host_cpu == "x64") { | 508 if (host_cpu == "x86" || host_cpu == "x64") { |
| 511 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" | 509 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" |
| 512 } else { | 510 } else { |
| 513 host_toolchain = "//build/toolchain/linux:$host_cpu" | 511 host_toolchain = "//build/toolchain/linux:$host_cpu" |
| 514 } | 512 } |
| 515 } else if (host_os == "mac") { | 513 } else if (host_os == "mac") { |
| 516 host_toolchain = "//build/toolchain/mac:clang_$host_cpu" | 514 host_toolchain = "//build/toolchain/mac:clang_$host_cpu" |
| 517 } else { | 515 } else { |
| 518 assert(false, "Unknown host for android cross compile") | 516 assert(false, "Unknown host for android cross compile") |
| 519 } | 517 } |
| 520 if (is_clang) { | 518 if (is_clang) { |
| 521 set_default_toolchain("//build/toolchain/android:clang_$current_cpu") | 519 _default_toolchain = "//build/toolchain/android:clang_$current_cpu" |
| 522 } else { | 520 } else { |
| 523 set_default_toolchain("//build/toolchain/android:$current_cpu") | 521 _default_toolchain = "//build/toolchain/android:$current_cpu" |
| 524 } | 522 } |
| 525 } else if (is_linux) { | 523 } else if (is_linux) { |
| 526 if (is_clang) { | 524 if (is_clang) { |
| 527 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" | 525 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" |
| 528 set_default_toolchain("//build/toolchain/linux:clang_$current_cpu") | 526 _default_toolchain = "//build/toolchain/linux:clang_$current_cpu" |
| 529 } else { | 527 } else { |
| 530 host_toolchain = "//build/toolchain/linux:$host_cpu" | 528 host_toolchain = "//build/toolchain/linux:$host_cpu" |
| 531 set_default_toolchain("//build/toolchain/linux:$current_cpu") | 529 _default_toolchain = "//build/toolchain/linux:$current_cpu" |
| 532 } | |
| 533 if (is_chromeos && cros_use_custom_toolchain) { | |
| 534 set_default_toolchain("//build/toolchain/cros:target") | |
| 535 } | 530 } |
| 536 } else if (is_mac) { | 531 } else if (is_mac) { |
| 537 host_toolchain = "//build/toolchain/mac:clang_x64" | 532 host_toolchain = "//build/toolchain/mac:clang_x64" |
| 538 set_default_toolchain(host_toolchain) | 533 _default_toolchain = host_toolchain |
| 539 } else if (is_ios) { | 534 } else if (is_ios) { |
| 540 host_toolchain = "//build/toolchain/mac:clang_x64" | 535 host_toolchain = "//build/toolchain/mac:clang_x64" |
| 541 set_default_toolchain("//build/toolchain/mac:ios_clang_arm") | 536 _default_toolchain = "//build/toolchain/mac:ios_clang_arm" |
| 542 } else if (is_nacl) { | 537 } else if (is_nacl) { |
| 543 # TODO(GYP): This will need to change when we get NaCl working | 538 # TODO(GYP): This will need to change when we get NaCl working |
| 544 # on multiple platforms, but this whole block of code (how we define | 539 # on multiple platforms, but this whole block of code (how we define |
| 545 # host_toolchain) needs to be reworked regardless to key off of host_os | 540 # host_toolchain) needs to be reworked regardless to key off of host_os |
| 546 # and host_cpu rather than the is_* variables. | 541 # and host_cpu rather than the is_* variables. |
| 547 host_toolchain = "//build/toolchain/linux:clang_x64" | 542 host_toolchain = "//build/toolchain/linux:clang_x64" |
| 548 } | 543 } |
| 549 | 544 |
| 545 # If a custom toolchain has been set in the args, set it as default. Otherwise, |
| 546 # set the default toolchain for the platform (if any). |
| 547 if (custom_toolchain != "") { |
| 548 set_default_toolchain(custom_toolchain) |
| 549 } else if (_default_toolchain != "") { |
| 550 set_default_toolchain(_default_toolchain) |
| 551 } |
| 552 |
| 550 # ============================================================================== | 553 # ============================================================================== |
| 551 # COMPONENT SETUP | 554 # COMPONENT SETUP |
| 552 # ============================================================================== | 555 # ============================================================================== |
| 553 | 556 |
| 554 if (is_component_build) { | 557 if (is_component_build) { |
| 555 _component_mode = "shared_library" | 558 _component_mode = "shared_library" |
| 556 } else { | 559 } else { |
| 557 _component_mode = "source_set" | 560 _component_mode = "source_set" |
| 558 } | 561 } |
| 559 template("component") { | 562 template("component") { |
| 560 target(_component_mode, target_name) { | 563 target(_component_mode, target_name) { |
| 561 forward_variables_from(invoker, "*") | 564 forward_variables_from(invoker, "*") |
| 562 | 565 |
| 563 # All shared libraries must have the sanitizer deps to properly link in | 566 # All shared libraries must have the sanitizer deps to properly link in |
| 564 # asan mode (this target will be empty in other cases). | 567 # asan mode (this target will be empty in other cases). |
| 565 if (!defined(deps)) { | 568 if (!defined(deps)) { |
| 566 deps = [] | 569 deps = [] |
| 567 } | 570 } |
| 568 deps += [ "//build/config/sanitizers:deps" ] | 571 deps += [ "//build/config/sanitizers:deps" ] |
| 569 } | 572 } |
| 570 } | 573 } |
| OLD | NEW |