Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / build / toolchain / android / BUILD.gn
blob53ad5060ae1010e55a526267d49cc0c11f149393
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/clang.gni")
8 import("//build/toolchain/goma.gni")
9 import("//build/toolchain/gcc_toolchain.gni")
11 # The Android GCC toolchains share most of the same parameters, so we have this
12 # wrapper around gcc_toolchain to avoid duplication of logic.
14 # Parameters:
15 #  - android_ndk_sysroot
16 #      Sysroot for this architecture.
17 #  - android_ndk_lib_dir
18 #      Subdirectory inside of android_ndk_sysroot where libs go.
19 #  - tool_prefix
20 #      Prefix to be added to the tool names.
21 #  - toolchain_cpu
22 #      Same as gcc_toolchain
23 template("android_gcc_toolchain") {
24   gcc_toolchain(target_name) {
25     # Make our manually injected libs relative to the build dir.
26     android_ndk_lib = rebase_path(
27             invoker.android_ndk_sysroot + "/" + invoker.android_ndk_lib_dir,
28             root_build_dir)
30     libs_section_prefix = "$android_ndk_lib/crtbegin_dynamic.o"
31     libs_section_postfix = "$android_ndk_lib/crtend_android.o"
33     solink_libs_section_prefix = "$android_ndk_lib/crtbegin_so.o"
34     solink_libs_section_postfix = "$android_ndk_lib/crtend_so.o"
36     # The tools should be run relative to the build dir.
37     tool_prefix = rebase_path(invoker.tool_prefix, root_build_dir)
39     if (use_goma) {
40       assert(!use_ccache, "Goma and ccache can't be used together.")
41       compiler_prefix = "$goma_dir/gomacc "
42     } else if (use_ccache) {
43       compiler_prefix = "ccache "
44     } else {
45       compiler_prefix = ""
46     }
48     cc = compiler_prefix + tool_prefix + "gcc"
49     cxx = compiler_prefix + tool_prefix + "g++"
50     ar = tool_prefix + "ar"
51     ld = cxx
53     toolchain_os = "android"
54     toolchain_cpu = invoker.toolchain_cpu
56     # We make the assumption that the gcc_toolchain will produce a soname with
57     # the following definition.
58     soname = "{{target_output_name}}{{output_extension}}"
60     stripped_soname = "lib.stripped/${soname}"
61     temp_stripped_soname = "${stripped_soname}.tmp"
63     android_strip = "${tool_prefix}strip"
65     mkdir_command = "mkdir -p lib.stripped"
66     strip_command =
67         "$android_strip --strip-unneeded -o $temp_stripped_soname $soname"
68     replace_command = "if ! cmp -s $temp_stripped_soname $stripped_soname; then mv $temp_stripped_soname $stripped_soname; fi"
69     postsolink = "$mkdir_command && $strip_command && $replace_command"
70     solink_outputs = [ stripped_soname ]
72     # We make the assumption that the gcc_toolchain will produce an exe with
73     # the following definition.
74     exe = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
75     stripped_exe = "exe.stripped/$exe"
76     mkdir_command = "mkdir -p exe.stripped"
77     strip_command = "$android_strip --strip-unneeded -o $stripped_exe $exe"
78     postlink = "$mkdir_command && $strip_command"
79     link_outputs = [ stripped_exe ]
80   }
83 android_gcc_toolchain("x86") {
84   android_ndk_sysroot = "$android_ndk_root/$x86_android_sysroot_subdir"
85   android_ndk_lib_dir = "usr/lib"
87   tool_prefix = "$x86_android_toolchain_root/bin/i686-linux-android-"
88   toolchain_cpu = "x86"
91 android_gcc_toolchain("arm") {
92   android_ndk_sysroot = "$android_ndk_root/$arm_android_sysroot_subdir"
93   android_ndk_lib_dir = "usr/lib"
95   tool_prefix = "$arm_android_toolchain_root/bin/arm-linux-androideabi-"
96   toolchain_cpu = "arm"
99 android_gcc_toolchain("mipsel") {
100   android_ndk_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir"
101   android_ndk_lib_dir = "usr/lib"
103   tool_prefix = "$mips_android_toolchain_root/bin/mipsel-linux-android-"
104   toolchain_cpu = "mipsel"
107 android_gcc_toolchain("x64") {
108   android_ndk_sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir"
109   android_ndk_lib_dir = "usr/lib64"
111   tool_prefix = "$x86_64_android_toolchain_root/bin/x86_64-linux-android-"
112   toolchain_cpu = "x86_64"
115 android_gcc_toolchain("arm64") {
116   android_ndk_sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir"
117   android_ndk_lib_dir = "usr/lib"
119   tool_prefix = "$arm64_android_toolchain_root/bin/arm-linux-androideabi-"
120   toolchain_cpu = "aarch64"
123 android_gcc_toolchain("mips64el") {
124   android_ndk_sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir"
125   android_ndk_lib_dir = "usr/lib64"
127   tool_prefix = "$mips64_android_toolchain_root/bin/mipsel-linux-android-"
128   toolchain_cpu = "mipsel64el"