OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 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") |
| 10 |
| 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. |
| 13 # |
| 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) |
| 29 |
| 30 libs_section_prefix = "$android_ndk_lib/crtbegin_dynamic.o" |
| 31 libs_section_postfix = "$android_ndk_lib/crtend_android.o" |
| 32 |
| 33 solink_libs_section_prefix = "$android_ndk_lib/crtbegin_so.o" |
| 34 solink_libs_section_postfix = "$android_ndk_lib/crtend_so.o" |
| 35 |
| 36 # The tools should be run relative to the build dir. |
| 37 tool_prefix = rebase_path(invoker.tool_prefix, root_build_dir) |
| 38 |
| 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 } |
| 47 |
| 48 is_clang = invoker.is_clang |
| 49 if (is_clang) { |
| 50 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", |
| 51 root_build_dir) |
| 52 |
| 53 cc = compiler_prefix + prefix + "/clang" |
| 54 cxx = compiler_prefix + prefix + "/clang++" |
| 55 } else { |
| 56 cc = compiler_prefix + tool_prefix + "gcc" |
| 57 cxx = compiler_prefix + tool_prefix + "g++" |
| 58 } |
| 59 |
| 60 ar = tool_prefix + "ar" |
| 61 ld = cxx |
| 62 readelf = compiler_prefix + tool_prefix + "readelf" |
| 63 nm = compiler_prefix + tool_prefix + "nm" |
| 64 |
| 65 toolchain_os = "android" |
| 66 toolchain_cpu = invoker.toolchain_cpu |
| 67 |
| 68 # We make the assumption that the gcc_toolchain will produce a soname with |
| 69 # the following definition. |
| 70 soname = "{{target_output_name}}{{output_extension}}" |
| 71 |
| 72 stripped_soname = "lib.stripped/${soname}" |
| 73 temp_stripped_soname = "${stripped_soname}.tmp" |
| 74 |
| 75 android_strip = "${tool_prefix}strip" |
| 76 |
| 77 strip_command = |
| 78 "$android_strip --strip-unneeded -o $temp_stripped_soname $soname" |
| 79 replace_command = "if ! cmp -s $temp_stripped_soname $stripped_soname; then
mv $temp_stripped_soname $stripped_soname; fi" |
| 80 postsolink = "$strip_command && $replace_command" |
| 81 solink_outputs = [ stripped_soname ] |
| 82 default_output_extension = android_product_extension |
| 83 |
| 84 # We make the assumption that the gcc_toolchain will produce an exe with |
| 85 # the following definition. |
| 86 exe = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
| 87 stripped_exe = "exe.stripped/$exe" |
| 88 postlink = "$android_strip --strip-unneeded -o $stripped_exe $exe" |
| 89 link_outputs = [ stripped_exe ] |
| 90 } |
| 91 } |
| 92 |
| 93 template("android_gcc_toolchains_helper") { |
| 94 android_gcc_toolchain(target_name) { |
| 95 android_ndk_sysroot = invoker.android_ndk_sysroot |
| 96 android_ndk_lib_dir = invoker.android_ndk_lib_dir |
| 97 tool_prefix = invoker.tool_prefix |
| 98 toolchain_cpu = invoker.toolchain_cpu |
| 99 } |
| 100 android_gcc_toolchain("clang_$target_name") { |
| 101 android_ndk_sysroot = invoker.android_ndk_sysroot |
| 102 android_ndk_lib_dir = invoker.android_ndk_lib_dir |
| 103 tool_prefix = invoker.tool_prefix |
| 104 toolchain_cpu = invoker.toolchain_cpu |
| 105 is_clang = true |
| 106 } |
| 107 } |
| 108 |
| 109 android_gcc_toolchains_helper("x86") { |
| 110 android_ndk_sysroot = "$android_ndk_root/$x86_android_sysroot_subdir" |
| 111 android_ndk_lib_dir = "usr/lib" |
| 112 |
| 113 tool_prefix = "$x86_android_toolchain_root/bin/i686-linux-android-" |
| 114 toolchain_cpu = "x86" |
| 115 } |
| 116 |
| 117 android_gcc_toolchains_helper("arm") { |
| 118 android_ndk_sysroot = "$android_ndk_root/$arm_android_sysroot_subdir" |
| 119 android_ndk_lib_dir = "usr/lib" |
| 120 |
| 121 tool_prefix = "$arm_android_toolchain_root/bin/arm-linux-androideabi-" |
| 122 toolchain_cpu = "arm" |
| 123 } |
| 124 |
| 125 android_gcc_toolchains_helper("mipsel") { |
| 126 android_ndk_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir" |
| 127 android_ndk_lib_dir = "usr/lib" |
| 128 |
| 129 tool_prefix = "$mips_android_toolchain_root/bin/mipsel-linux-android-" |
| 130 toolchain_cpu = "mipsel" |
| 131 } |
| 132 |
| 133 android_gcc_toolchains_helper("x64") { |
| 134 android_ndk_sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir" |
| 135 android_ndk_lib_dir = "usr/lib64" |
| 136 |
| 137 tool_prefix = "$x86_64_android_toolchain_root/bin/x86_64-linux-android-" |
| 138 toolchain_cpu = "x86_64" |
| 139 } |
| 140 |
| 141 android_gcc_toolchains_helper("arm64") { |
| 142 android_ndk_sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir" |
| 143 android_ndk_lib_dir = "usr/lib" |
| 144 |
| 145 tool_prefix = "$arm64_android_toolchain_root/bin/arm-linux-androideabi-" |
| 146 toolchain_cpu = "aarch64" |
| 147 } |
| 148 |
| 149 android_gcc_toolchains_helper("mips64el") { |
| 150 android_ndk_sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir" |
| 151 android_ndk_lib_dir = "usr/lib64" |
| 152 |
| 153 tool_prefix = "$mips64_android_toolchain_root/bin/mipsel-linux-android-" |
| 154 toolchain_cpu = "mipsel64el" |
| 155 } |
OLD | NEW |