Chromium Code Reviews| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 # If we're building for Android, we should assume that we want to | 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). | 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 | 45 # This allows us to not have to specify both target_os and target_cpu |
| 46 # on the command line. | 46 # on the command line. |
| 47 target_cpu = "arm" | 47 target_cpu = "arm" |
| 48 } else { | 48 } else { |
| 49 target_cpu = host_cpu | 49 target_cpu = host_cpu |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 # The current_cpu and current_os variables are empty on the first | |
| 54 # run through this file. When this file is evaluated again in a | |
| 55 # specific toolchain context, the toolchain_args() block will have | |
| 56 # set these explicitly. So them being empty is the best available | |
| 57 # proxy for a "is this the first time through" predicate. | |
| 58 buildconfig_in_default_toolchain = current_cpu == "" && current_os == "" | |
|
brettw
2015/12/01 22:08:19
I'm not super fond of this hack and I'd prefer to
Roland McGrath
2015/12/01 22:12:18
My concern is that when it goes wrong the failure
| |
| 59 | |
| 53 if (current_cpu == "") { | 60 if (current_cpu == "") { |
| 54 current_cpu = target_cpu | 61 current_cpu = target_cpu |
| 55 } | 62 } |
| 56 if (current_os == "") { | 63 if (current_os == "") { |
| 57 current_os = target_os | 64 current_os = target_os |
| 58 } | 65 } |
| 59 | 66 |
| 60 # ============================================================================= | 67 # ============================================================================= |
| 61 # BUILD FLAGS | 68 # BUILD FLAGS |
| 62 # ============================================================================= | 69 # ============================================================================= |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 | 129 |
| 123 # Set to true when compiling with the Clang compiler. Typically this is used | 130 # Set to true when compiling with the Clang compiler. Typically this is used |
| 124 # to configure warnings. | 131 # to configure warnings. |
| 125 is_clang = current_os == "mac" || current_os == "ios" || | 132 is_clang = current_os == "mac" || current_os == "ios" || |
| 126 current_os == "linux" || current_os == "chromeos" | 133 current_os == "linux" || current_os == "chromeos" |
| 127 | 134 |
| 128 # Allows the path to a custom target toolchain to be injected as a single | 135 # Allows the path to a custom target toolchain to be injected as a single |
| 129 # argument, and set as the default toolchain. | 136 # argument, and set as the default toolchain. |
| 130 custom_toolchain = "" | 137 custom_toolchain = "" |
| 131 | 138 |
| 139 # This should not normally be set as a build argument. It's here so that | |
| 140 # every toolchain can pass through the "global" value via toolchain_args(). | |
| 141 host_toolchain = "" | |
| 142 | |
| 132 # DON'T ADD MORE FLAGS HERE. Read the comment above. | 143 # DON'T ADD MORE FLAGS HERE. Read the comment above. |
| 133 } | 144 } |
| 134 | 145 |
| 135 # ============================================================================== | 146 # ============================================================================== |
| 136 # TOOLCHAIN SETUP | 147 # TOOLCHAIN SETUP |
| 137 # ============================================================================== | 148 # ============================================================================== |
| 138 # | 149 # |
| 139 # Here we set the default toolchain, as well as the variable host_toolchain | 150 # Here we set the default toolchain, as well as the variable host_toolchain |
| 140 # which will identify the toolchain corresponding to the local system when | 151 # which will identify the toolchain corresponding to the local system when |
| 141 # doing cross-compiles. When not cross-compiling, this will be the same as the | 152 # doing cross-compiles. When not cross-compiling, this will be the same as the |
| 142 # default toolchain. | 153 # default toolchain. |
| 143 # | 154 # |
| 144 # We do this before anything else to make sure we complain about any | 155 # We do this before anything else to make sure we complain about any |
| 145 # unsupported os/cpu combinations as early as possible. | 156 # unsupported os/cpu combinations as early as possible. |
| 146 | 157 |
| 147 if (host_os == "linux") { | 158 if (host_toolchain == "") { |
| 148 if (target_os != "linux") { | 159 # This should only happen in the top-level context. |
| 149 # TODO(dpranke) - is_clang normally applies only to the target | 160 # In a specific toolchain context, the toolchain_args() |
| 150 # build, and there is no way to indicate that you want to override | 161 # block should have propagated a value down. |
| 151 # it for both the target build *and* the host build. Do we need to | 162 assert(buildconfig_in_default_toolchain, |
| 152 # support this? | 163 "All toolchains must plumb through host_toolchain in toolchain_args()") |
| 153 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" | 164 |
| 154 } else if (is_clang) { | 165 if (host_os == "linux") { |
| 155 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" | 166 if (is_clang) { |
| 167 host_toolchain = "//build/toolchain/linux:clang_$host_cpu" | |
| 168 } else { | |
| 169 host_toolchain = "//build/toolchain/linux:$host_cpu" | |
| 170 } | |
| 171 } else if (host_os == "mac") { | |
| 172 host_toolchain = "//build/toolchain/mac:clang_$host_cpu" | |
| 173 } else if (host_os == "win") { | |
| 174 # TODO(crbug.com/467159): win cross-compiles don't actually work yet, so | |
| 175 # use the target_cpu instead of the host_cpu. | |
| 176 if (is_clang) { | |
| 177 host_toolchain = "//build/toolchain/win:clang_$target_cpu" | |
| 178 } else { | |
| 179 host_toolchain = "//build/toolchain/win:$target_cpu" | |
| 180 } | |
| 156 } else { | 181 } else { |
| 157 host_toolchain = "//build/toolchain/linux:$host_cpu" | 182 assert(false, "Unsupported host_os: $host_os") |
| 158 } | 183 } |
| 159 } else if (host_os == "mac") { | |
| 160 host_toolchain = "//build/toolchain/mac:clang_$host_cpu" | |
| 161 } else if (host_os == "win") { | |
| 162 # TODO(crbug.com/467159): win cross-compiles don't actually work yet, so | |
| 163 # use the target_cpu instead of the host_cpu. | |
| 164 if (is_clang) { | |
| 165 host_toolchain = "//build/toolchain/win:clang_$target_cpu" | |
| 166 } else { | |
| 167 host_toolchain = "//build/toolchain/win:$target_cpu" | |
| 168 } | |
| 169 } else { | |
| 170 assert(false, "Unsupported host_os: $host_os") | |
| 171 } | 184 } |
| 172 | 185 |
| 173 _default_toolchain = "" | 186 _default_toolchain = "" |
| 174 | 187 |
| 175 if (target_os == "android") { | 188 if (target_os == "android") { |
| 176 assert(host_os == "linux" || host_os == "mac", | 189 assert(host_os == "linux" || host_os == "mac", |
| 177 "Android builds are only supported on Linux and Mac hosts.") | 190 "Android builds are only supported on Linux and Mac hosts.") |
| 178 if (is_clang) { | 191 if (is_clang) { |
| 179 _default_toolchain = "//build/toolchain/android:clang_$target_cpu" | 192 _default_toolchain = "//build/toolchain/android:clang_$target_cpu" |
| 180 } else { | 193 } else { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 193 } else if (target_os == "linux") { | 206 } else if (target_os == "linux") { |
| 194 if (is_clang) { | 207 if (is_clang) { |
| 195 _default_toolchain = "//build/toolchain/linux:clang_$target_cpu" | 208 _default_toolchain = "//build/toolchain/linux:clang_$target_cpu" |
| 196 } else { | 209 } else { |
| 197 _default_toolchain = "//build/toolchain/linux:$target_cpu" | 210 _default_toolchain = "//build/toolchain/linux:$target_cpu" |
| 198 } | 211 } |
| 199 } else if (target_os == "mac") { | 212 } else if (target_os == "mac") { |
| 200 assert(host_os == "mac", "Mac cross-compiles are unsupported.") | 213 assert(host_os == "mac", "Mac cross-compiles are unsupported.") |
| 201 _default_toolchain = host_toolchain | 214 _default_toolchain = host_toolchain |
| 202 } else if (target_os == "win") { | 215 } else if (target_os == "win") { |
| 203 # On windows we use the same toolchain for host and target by default. | 216 # On Windows we use the same toolchain for host and target by default. |
| 204 assert(target_os == host_os, "Win cross-compiles only work on win hosts.") | 217 assert(target_os == host_os, "Win cross-compiles only work on win hosts.") |
| 205 if (is_clang) { | 218 if (is_clang) { |
| 206 _default_toolchain = "//build/toolchain/win:clang_$target_cpu" | 219 _default_toolchain = "//build/toolchain/win:clang_$target_cpu" |
| 207 } else { | 220 } else { |
| 208 _default_toolchain = "//build/toolchain/win:$target_cpu" | 221 _default_toolchain = "//build/toolchain/win:$target_cpu" |
| 209 } | 222 } |
| 210 } else if (target_os == "winrt_81" || target_os == "winrt_81_phone" || | 223 } else if (target_os == "winrt_81" || target_os == "winrt_81_phone" || |
| 211 target_os == "winrt_10") { | 224 target_os == "winrt_10") { |
| 212 _default_toolchain = "//build/toolchain/win:winrt_$target_cpu" | 225 _default_toolchain = "//build/toolchain/win:winrt_$target_cpu" |
| 213 } else { | 226 } else { |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 forward_variables_from(invoker, "*") | 594 forward_variables_from(invoker, "*") |
| 582 | 595 |
| 583 # All shared libraries must have the sanitizer deps to properly link in | 596 # All shared libraries must have the sanitizer deps to properly link in |
| 584 # asan mode (this target will be empty in other cases). | 597 # asan mode (this target will be empty in other cases). |
| 585 if (!defined(deps)) { | 598 if (!defined(deps)) { |
| 586 deps = [] | 599 deps = [] |
| 587 } | 600 } |
| 588 deps += [ "//build/config/sanitizers:deps" ] | 601 deps += [ "//build/config/sanitizers:deps" ] |
| 589 } | 602 } |
| 590 } | 603 } |
| OLD | NEW |