| # Copyright 2020 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/config/clang/clang.gni") |
| |
| # Define a number of global variables that are normally defined by the Zircon |
| # build system. This should only be used when processing Zircon-specific target |
| # rules under //zircon/ which invoke zx_library() or zx_host_tool() |
| |
| # `toolchain` is a scope used by the Zircon build to describe the current toolchain. |
| # Its layout is very different from `toolchain_variant` so try to mimic it here. |
| toolchain = { |
| # The `environment` key corresponds to the runtime environment that the |
| # binaries generated by the current toolchain will run in. |
| if (zircon_toolchain != false) { |
| environment = zircon_toolchain.environment |
| } else if (is_fuchsia) { |
| environment = "user" |
| } else if (is_host) { |
| environment = "host" |
| } else { |
| environment = "unknown" |
| } |
| |
| base_environment = get_path_info(environment, "name") |
| |
| # The `shlib` key is defined when there is a companion toolchain that |
| # generates shared-library binaries for the current toolchain. It is not |
| # defined otherwise. |
| if (!toolchain_variant.with_shared) { |
| shlib = shlib_toolchain |
| } |
| |
| # The `target_tuple` is the Clang-specific target tuple matching the |
| # binaries generated by the current toolchain, even if it uses GCC |
| # instead of Clang. |
| target_tuple = clang_target |
| |
| # The `cpu` value is the Clang-specific CPU name. Used by Musl C library. |
| if (current_cpu == "x64") { |
| cpu = "x86_64" |
| } else if (current_cpu == "arm64") { |
| cpu = "aarch64" |
| } else { |
| cpu = current_cpu |
| } |
| |
| # The `tags` value is the list of tags that applies to the current |
| # toolchain instance. |
| tags = toolchain_variant.tags |
| } |
| |
| # This is the name for $current_cpu that's used in Zircon file names. |
| if (current_cpu == "x64") { |
| zircon_cpu = "x86" |
| } else if (current_cpu != "") { |
| zircon_cpu = current_cpu |
| } |