2016-07-01 18:09:28 +00:00
|
|
|
# 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") # Imports android/config.gni.
|
|
|
|
import("//build/toolchain/ccache.gni")
|
|
|
|
import("//build/toolchain/gcc_toolchain.gni")
|
2020-03-10 21:56:11 +00:00
|
|
|
import("//build/toolchain/goma.gni")
|
2023-10-24 14:36:19 +00:00
|
|
|
import("//build/toolchain/rbe.gni")
|
2016-07-01 18:09:28 +00:00
|
|
|
|
|
|
|
# The Android GCC toolchains share most of the same parameters, so we have this
|
|
|
|
# wrapper around gcc_toolchain to avoid duplication of logic.
|
|
|
|
#
|
|
|
|
# Parameters:
|
|
|
|
# - android_ndk_lib_dir
|
2023-05-16 16:32:58 +00:00
|
|
|
# Libraries for this architecture
|
2016-07-01 18:09:28 +00:00
|
|
|
# - tool_prefix
|
|
|
|
# Prefix to be added to the tool names.
|
|
|
|
# - toolchain_cpu
|
|
|
|
# Same as gcc_toolchain
|
2023-10-18 22:38:23 +00:00
|
|
|
template("android_toolchain") {
|
2016-07-01 18:09:28 +00:00
|
|
|
gcc_toolchain(target_name) {
|
|
|
|
if (use_goma) {
|
|
|
|
assert(!use_ccache, "Goma and ccache can't be used together.")
|
2023-10-24 14:36:19 +00:00
|
|
|
assembler_prefix = "$goma_dir/gomacc "
|
2016-07-01 18:09:28 +00:00
|
|
|
compiler_prefix = "$goma_dir/gomacc "
|
2023-10-24 14:36:19 +00:00
|
|
|
link_prefix = "$goma_dir/gomacc "
|
2023-11-24 14:02:27 +00:00
|
|
|
} else if (use_rbe) {
|
|
|
|
compiler_args =
|
2024-01-10 11:38:43 +00:00
|
|
|
rewrapper_args + [ "--labels=type=compile,compiler=clang,lang=cpp" ]
|
2024-01-10 14:56:18 +00:00
|
|
|
|
|
|
|
# TODO: Unfortunately I see no way to get build_arch reliably.
|
|
|
|
if (rbe_os != host_os) {
|
2024-01-10 11:38:43 +00:00
|
|
|
compiler_args += [
|
|
|
|
"--inputs=build/rbe,buildtools/$rbe_os-$rbe_cpu/clang/bin/llvm",
|
|
|
|
"--remote_wrapper=../../build/rbe/llvm.sh",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
assembler_prefix = ""
|
|
|
|
compiler_prefix = string_join(" ", compiler_args) + " "
|
|
|
|
link_prefix = ""
|
2016-07-01 18:09:28 +00:00
|
|
|
} else if (use_ccache) {
|
2023-10-24 14:36:19 +00:00
|
|
|
assembler_prefix = "ccache "
|
2016-07-01 18:09:28 +00:00
|
|
|
compiler_prefix = "ccache "
|
2023-10-24 14:36:19 +00:00
|
|
|
link_prefix = "ccache "
|
2016-07-01 18:09:28 +00:00
|
|
|
} else {
|
2023-10-24 14:36:19 +00:00
|
|
|
assembler_prefix = ""
|
2016-07-01 18:09:28 +00:00
|
|
|
compiler_prefix = ""
|
2023-10-24 14:36:19 +00:00
|
|
|
link_prefix = ""
|
2016-07-01 18:09:28 +00:00
|
|
|
}
|
|
|
|
|
2023-10-18 22:38:23 +00:00
|
|
|
is_clang = true
|
|
|
|
prefix = rebase_path(
|
|
|
|
"${android_ndk_root}/toolchains/llvm/prebuilt/${android_host_os}-${android_host_arch}/bin",
|
|
|
|
root_build_dir)
|
|
|
|
|
2023-10-24 14:36:19 +00:00
|
|
|
cc = "${compiler_prefix}${prefix}/clang"
|
|
|
|
cxx = "${compiler_prefix}${prefix}/clang++"
|
|
|
|
asm = "${assembler_prefix}${prefix}/clang"
|
2023-10-18 22:38:23 +00:00
|
|
|
ar = prefix + "/llvm-ar"
|
2023-10-24 14:36:19 +00:00
|
|
|
ld = "${link_prefix}${prefix}/clang++"
|
2023-10-18 22:38:23 +00:00
|
|
|
readelf = prefix + "/llvm-readelf"
|
|
|
|
nm = prefix + "/llvm-nm"
|
|
|
|
android_strip = prefix + "/llvm-strip"
|
2016-07-01 18:09:28 +00:00
|
|
|
|
|
|
|
toolchain_os = "android"
|
|
|
|
toolchain_cpu = invoker.toolchain_cpu
|
|
|
|
|
|
|
|
# We make the assumption that the gcc_toolchain will produce a soname with
|
|
|
|
# the following definition.
|
|
|
|
soname = "{{target_output_name}}{{output_extension}}"
|
|
|
|
|
|
|
|
stripped_soname = "lib.stripped/${soname}"
|
|
|
|
temp_stripped_soname = "${stripped_soname}.tmp"
|
|
|
|
|
|
|
|
strip_command =
|
|
|
|
"$android_strip --strip-unneeded -o $temp_stripped_soname $soname"
|
|
|
|
replace_command = "if ! cmp -s $temp_stripped_soname $stripped_soname; then mv $temp_stripped_soname $stripped_soname; fi"
|
|
|
|
postsolink = "$strip_command && $replace_command"
|
|
|
|
solink_outputs = [ stripped_soname ]
|
|
|
|
default_output_extension = android_product_extension
|
|
|
|
|
|
|
|
# We make the assumption that the gcc_toolchain will produce an exe with
|
|
|
|
# the following definition.
|
|
|
|
exe = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
|
|
|
|
stripped_exe = "exe.stripped/$exe"
|
|
|
|
postlink = "$android_strip --strip-unneeded -o $stripped_exe $exe"
|
|
|
|
link_outputs = [ stripped_exe ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-18 22:38:23 +00:00
|
|
|
android_toolchain("clang_x86") {
|
2016-07-01 18:09:28 +00:00
|
|
|
toolchain_cpu = "x86"
|
|
|
|
}
|
|
|
|
|
2023-10-18 22:38:23 +00:00
|
|
|
android_toolchain("clang_arm") {
|
2016-07-01 18:09:28 +00:00
|
|
|
toolchain_cpu = "arm"
|
|
|
|
}
|
|
|
|
|
2023-10-18 22:38:23 +00:00
|
|
|
android_toolchain("clang_x64") {
|
2016-07-01 18:09:28 +00:00
|
|
|
toolchain_cpu = "x86_64"
|
|
|
|
}
|
|
|
|
|
2023-10-18 22:38:23 +00:00
|
|
|
android_toolchain("clang_arm64") {
|
2016-07-01 18:09:28 +00:00
|
|
|
toolchain_cpu = "aarch64"
|
|
|
|
}
|
2023-10-17 16:34:27 +00:00
|
|
|
|
2023-10-18 22:38:23 +00:00
|
|
|
android_toolchain("clang_riscv64") {
|
2023-10-17 16:34:27 +00:00
|
|
|
toolchain_cpu = "riscv64"
|
|
|
|
}
|