blob: 62e727817a5c29699738ee8e221dd795a6fd3a01 [file] [log] [blame]
# Copyright 2013 The Chromium 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/sysroot.gni")
import("//build/toolchain/clang.gni")
import("//build/toolchain/gcc_toolchain.gni")
import("//build/toolchain/goma.gni")
if (is_gyp) {
# Set the compilers for GYP to use. This logic is only relevant to GYP where
# there is "a" target compiler. In native GN builds, we have separate
# compilers for the toolchains below, any or all of which could be active in
# any given build.
if (is_clang) {
# Set the GYP header for all toolchains when running under Clang.
make_global_settings = make_clang_global_settings
} else {
if (cpu_arch == "mipsel") {
make_global_settings =
"['CC', '$sysroot/../bin/mipsel-linux-gnu-gcc']," +
"['CXX', '$sysroot/../bin/mipsel-linux-gnu-g++']," +
"['CC.host', '/usr/bin/gcc']," +
"['CXX.host', '/usr/bin/g++'],"
} else {
make_global_settings = ""
}
}
if (use_goma) {
# There is a TODO(yyanagisawa) in common.gypi about the make generator not
# supporting CC_wrapper without CC. As a result, we must add a condition
# when on the generator when we're not explicitly setting the variables
# above (which happens when gyp_header is empty at this point).
#
# GYP will interpret the file once for each generator, so we have to write
# this condition into the GYP file since the user could have more than one
# generator set.
gyp_header =
"'conditions':" +
"[['\"<(GENERATOR)\"==\"ninja\"', { 'make_global_settings': [" +
make_global_settings +
make_goma_global_settings +
"]}]],"
} else {
gyp_header = "'make_global_settings': [" + make_global_settings + "],"
}
}
gcc_toolchain("arm") {
cc = "arm-linux-gnueabi-gcc"
cxx = "arm-linux-gnueabi-g++"
ar = "arm-linux-gnueabi-ar"
ld = cxx
toolchain_cpu_arch = "arm"
toolchain_os = "linux"
}
gcc_toolchain("x86") {
if (is_clang) {
if (use_clang_type_profiler) {
prefix = rebase_path("//third_party/llvm-allocated-type/Linux_ia32/bin",
root_build_dir)
} else {
prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin",
root_build_dir)
}
cc = "$prefix/clang"
cxx = "$prefix/clang++"
} else {
cc = "gcc"
cxx = "g++"
}
ar = "ar"
ld = cxx
toolchain_cpu_arch = "x86"
toolchain_os = "linux"
}
gcc_toolchain("x64") {
if (is_clang) {
if (use_clang_type_profiler) {
prefix = rebase_path("//third_party/llvm-allocated-type/Linux_x64/bin",
root_build_dir)
} else {
prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin",
root_build_dir)
}
cc = "$prefix/clang"
cxx = "$prefix/clang++"
} else {
cc = "gcc"
cxx = "g++"
}
ar = "ar"
ld = cxx
toolchain_cpu_arch = "x64"
toolchain_os = "linux"
}
gcc_toolchain("mipsel") {
cc = "mipsel-linux-gnu-gcc"
cxx = "mipsel-linux-gnu-g++"
ar = "mipsel-linux-gnu-ar"
ld = cxx
toolchain_cpu_arch = "mipsel"
toolchain_os = "linux"
}