dart-sdk/build/toolchain/android/BUILD.gn
Jonas Termansen c348fd0865 Fix RBE llvm wrapper setting the world on fire.
I don't want to set the world on fire.

Change-Id: Icef12a8398eee6cf78b8852ccba73a318c8c5563
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345542
Reviewed-by: Jonas Jensen <jonasfj@google.com>
2024-01-10 14:56:18 +00:00

111 lines
3.5 KiB
Plaintext

# 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")
import("//build/toolchain/goma.gni")
import("//build/toolchain/rbe.gni")
# 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
# Libraries for this architecture
# - tool_prefix
# Prefix to be added to the tool names.
# - toolchain_cpu
# Same as gcc_toolchain
template("android_toolchain") {
gcc_toolchain(target_name) {
if (use_goma) {
assert(!use_ccache, "Goma and ccache can't be used together.")
assembler_prefix = "$goma_dir/gomacc "
compiler_prefix = "$goma_dir/gomacc "
link_prefix = "$goma_dir/gomacc "
} else if (use_rbe) {
compiler_args =
rewrapper_args + [ "--labels=type=compile,compiler=clang,lang=cpp" ]
# TODO: Unfortunately I see no way to get build_arch reliably.
if (rbe_os != host_os) {
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 = ""
} else if (use_ccache) {
assembler_prefix = "ccache "
compiler_prefix = "ccache "
link_prefix = "ccache "
} else {
assembler_prefix = ""
compiler_prefix = ""
link_prefix = ""
}
is_clang = true
prefix = rebase_path(
"${android_ndk_root}/toolchains/llvm/prebuilt/${android_host_os}-${android_host_arch}/bin",
root_build_dir)
cc = "${compiler_prefix}${prefix}/clang"
cxx = "${compiler_prefix}${prefix}/clang++"
asm = "${assembler_prefix}${prefix}/clang"
ar = prefix + "/llvm-ar"
ld = "${link_prefix}${prefix}/clang++"
readelf = prefix + "/llvm-readelf"
nm = prefix + "/llvm-nm"
android_strip = prefix + "/llvm-strip"
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 ]
}
}
android_toolchain("clang_x86") {
toolchain_cpu = "x86"
}
android_toolchain("clang_arm") {
toolchain_cpu = "arm"
}
android_toolchain("clang_x64") {
toolchain_cpu = "x86_64"
}
android_toolchain("clang_arm64") {
toolchain_cpu = "aarch64"
}
android_toolchain("clang_riscv64") {
toolchain_cpu = "riscv64"
}