1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/sysroot.gni") # Imports android/config.gni.
6 import("//build/toolchain/ccache.gni")
7 import("//build/toolchain/goma.gni")
8 import("//build/toolchain/gcc_toolchain.gni")
10 # The Android GCC toolchains share most of the same parameters, so we have this
11 # wrapper around gcc_toolchain to avoid duplication of logic.
14 # - android_ndk_sysroot
15 # Sysroot for this architecture.
16 # - android_ndk_lib_dir
17 # Subdirectory inside of android_ndk_sysroot where libs go.
19 # Prefix to be added to the tool names.
21 # Same as gcc_toolchain
22 template("android_gcc_toolchain") {
23 gcc_toolchain(target_name) {
24 # Make our manually injected libs relative to the build dir.
25 android_ndk_lib = rebase_path(
26 invoker.android_ndk_sysroot + "/" + invoker.android_ndk_lib_dir,
29 libs_section_prefix = "$android_ndk_lib/crtbegin_dynamic.o"
30 libs_section_postfix = "$android_ndk_lib/crtend_android.o"
32 solink_libs_section_prefix = "$android_ndk_lib/crtbegin_so.o"
33 solink_libs_section_postfix = "$android_ndk_lib/crtend_so.o"
35 # The tools should be run relative to the build dir.
36 tool_prefix = rebase_path(invoker.tool_prefix, root_build_dir)
39 assert(!use_ccache, "Goma and ccache can't be used together.")
40 compiler_prefix = "$goma_dir/gomacc "
41 } else if (use_ccache) {
42 compiler_prefix = "ccache "
47 is_clang = invoker.is_clang
49 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin",
51 cc = "${compiler_prefix}$prefix/clang"
52 cxx = "${compiler_prefix}$prefix/clang++"
54 cc = "${compiler_prefix}${tool_prefix}gcc"
55 cxx = "${compiler_prefix}${tool_prefix}g++"
57 ar = tool_prefix + "ar"
59 readelf = compiler_prefix + tool_prefix + "readelf"
60 nm = compiler_prefix + tool_prefix + "nm"
61 strip = "${tool_prefix}strip"
63 toolchain_os = "android"
64 toolchain_cpu = invoker.toolchain_cpu
68 template("android_gcc_toolchains_helper") {
69 android_gcc_toolchain(target_name) {
70 android_ndk_sysroot = invoker.android_ndk_sysroot
71 android_ndk_lib_dir = invoker.android_ndk_lib_dir
72 tool_prefix = invoker.tool_prefix
73 toolchain_cpu = invoker.toolchain_cpu
76 android_gcc_toolchain("clang_$target_name") {
77 android_ndk_sysroot = invoker.android_ndk_sysroot
78 android_ndk_lib_dir = invoker.android_ndk_lib_dir
79 tool_prefix = invoker.tool_prefix
80 toolchain_cpu = invoker.toolchain_cpu
85 android_gcc_toolchains_helper("x86") {
86 android_ndk_sysroot = "$android_ndk_root/$x86_android_sysroot_subdir"
87 android_ndk_lib_dir = "usr/lib"
89 tool_prefix = "$x86_android_toolchain_root/bin/i686-linux-android-"
93 android_gcc_toolchains_helper("arm") {
94 android_ndk_sysroot = "$android_ndk_root/$arm_android_sysroot_subdir"
95 android_ndk_lib_dir = "usr/lib"
97 tool_prefix = "$arm_android_toolchain_root/bin/arm-linux-androideabi-"
101 android_gcc_toolchains_helper("mipsel") {
102 android_ndk_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir"
103 android_ndk_lib_dir = "usr/lib"
105 tool_prefix = "$mips_android_toolchain_root/bin/mipsel-linux-android-"
106 toolchain_cpu = "mipsel"
109 android_gcc_toolchains_helper("x64") {
110 android_ndk_sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir"
111 android_ndk_lib_dir = "usr/lib64"
113 tool_prefix = "$x86_64_android_toolchain_root/bin/x86_64-linux-android-"
114 toolchain_cpu = "x86_64"
117 android_gcc_toolchains_helper("arm64") {
118 android_ndk_sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir"
119 android_ndk_lib_dir = "usr/lib"
121 tool_prefix = "$arm64_android_toolchain_root/bin/arm-linux-androideabi-"
122 toolchain_cpu = "aarch64"
125 android_gcc_toolchains_helper("mips64el") {
126 android_ndk_sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir"
127 android_ndk_lib_dir = "usr/lib64"
129 tool_prefix = "$mips64_android_toolchain_root/bin/mipsel-linux-android-"
130 toolchain_cpu = "mipsel64el"