| # Copyright 2016 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/toolchain/clang_toolchain.gni") |
| import("//build/config/fuchsia/config.gni") |
| |
| template("fuchsia_toolchain") { |
| clang_toolchain(target_name) { |
| forward_variables_from(invoker, "*") |
| |
| if (host_cpu == "arm64") { |
| clang_cpu = "aarch64" |
| } else if (host_cpu == "x64") { |
| clang_cpu = "x86_64" |
| } else { |
| assert(false, "Host CPU not supported") |
| } |
| |
| if (host_os == "linux") { |
| clang_os = "linux" |
| } else if (host_os == "mac") { |
| clang_os = "darwin" |
| } else { |
| assert(false, "Host OS not supported") |
| } |
| |
| clang_name = "clang+llvm-$clang_cpu-$clang_os" |
| clang_path = "$fuchsia_sdk/toolchain/$clang_name" |
| prefix = rebase_path("$clang_path/bin/", root_build_dir) |
| |
| cc = "${prefix}clang" |
| cxx = "${prefix}clang++" |
| ld = cxx |
| ar = "${prefix}llvm-ar" |
| strip = "${prefix}strip" |
| |
| toolchain_cpu = target_cpu |
| toolchain_os = target_os |
| } |
| } |
| |
| # The fuchsia toolchains require an assembled sysroot in order to do anything, |
| # so we need to create a dependency edge between all targets using the fuchsia |
| # toolchain and the sysroot assembly step. The cleanest way to do this in GN is |
| # by creating a toolchain dependency from the fuchsia toolchains to the |
| # assembly step. Since all targets in GN exist within a toolchain, and all |
| # targets inside the fuchsia toolchain need to depend on the sysroot assembly |
| # step, we need to create another toolchain to contain the sysroot assembly |
| # target. |
| fuchsia_toolchain("${target_cpu}-sysroot") { |
| } |
| |
| fuchsia_toolchain(target_cpu) { |
| deps = [ |
| "//build/sysroot(//build/toolchain/fuchsia:${target_cpu}-sysroot)", |
| ] |
| } |
| fuchsia_toolchain("${target_cpu}-shared") { |
| is_pic_default = true |
| deps = [ |
| "//build/sysroot(//build/toolchain/fuchsia:${target_cpu}-sysroot)", |
| ] |
| } |