Chromium Code Reviews| Index: build/toolchain/android/BUILD.gn |
| diff --git a/build/toolchain/android/BUILD.gn b/build/toolchain/android/BUILD.gn |
| index 52ac0a7d9880f1b82ea53f2e099c1a5261017b91..3f414fbbfba653d740e16c5334a56372ccd02066 100644 |
| --- a/build/toolchain/android/BUILD.gn |
| +++ b/build/toolchain/android/BUILD.gn |
| @@ -9,106 +9,114 @@ import("//build/toolchain/gcc_toolchain.gni") |
| # wrapper around gcc_toolchain to avoid duplication of logic. |
| # |
| # Parameters: |
| -# - android_ndk_sysroot |
| -# Sysroot for this architecture. |
| -# - android_ndk_lib_dir |
| -# Subdirectory inside of android_ndk_sysroot where libs go. |
| # - toolchain_cpu |
| -# Same as gcc_toolchain |
| +# Same as gcc_toolchain. |
| +# - toolchain_root |
| +# Path to cpu-specific toolchain within the ndk. |
| +# - sysroot |
| +# Sysroot for this architecture. |
| +# - lib_dir |
| +# Subdirectory inside of sysroot where libs go. |
| +# - binary_prefix |
| +# Prefix of compiler executables. |
| template("android_gcc_toolchain") { |
| gcc_toolchain(target_name) { |
| + is_clang = invoker.is_clang |
| + toolchain_cpu = invoker.toolchain_cpu |
| + toolchain_os = "android" |
| + |
| # Make our manually injected libs relative to the build dir. |
| - android_ndk_lib = rebase_path( |
| - invoker.android_ndk_sysroot + "/" + invoker.android_ndk_lib_dir, |
| - root_build_dir) |
| + _ndk_lib = |
| + rebase_path(invoker.sysroot + "/" + invoker.lib_dir, root_build_dir) |
| + |
| + libs_section_prefix = "$_ndk_lib/crtbegin_dynamic.o" |
| + libs_section_postfix = "$_ndk_lib/crtend_android.o" |
| - libs_section_prefix = "$android_ndk_lib/crtbegin_dynamic.o" |
| - libs_section_postfix = "$android_ndk_lib/crtend_android.o" |
| + solink_libs_section_prefix = "$_ndk_lib/crtbegin_so.o" |
| + solink_libs_section_postfix = "$_ndk_lib/crtend_so.o" |
| - solink_libs_section_prefix = "$android_ndk_lib/crtbegin_so.o" |
| - solink_libs_section_postfix = "$android_ndk_lib/crtend_so.o" |
| + _android_tool_prefix = |
| + "${invoker.toolchain_root}/bin/${invoker.binary_prefix}-" |
| # The tools should be run relative to the build dir. |
| - tool_prefix = rebase_path("$android_tool_prefix", root_build_dir) |
| + _tool_prefix = rebase_path("$_android_tool_prefix", root_build_dir) |
| - is_clang = invoker.is_clang |
| if (is_clang) { |
| - prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", |
| - root_build_dir) |
| - cc = "$prefix/clang" |
| - cxx = "$prefix/clang++" |
| + _prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", |
| + root_build_dir) |
| + cc = "$_prefix/clang" |
| + cxx = "$_prefix/clang++" |
| } else { |
| - cc = "${tool_prefix}gcc" |
| - cxx = "${tool_prefix}g++" |
| + cc = "${_tool_prefix}gcc" |
| + cxx = "${_tool_prefix}g++" |
| } |
| - ar = tool_prefix + "ar" |
| + ar = _tool_prefix + "ar" |
| ld = cxx |
| - readelf = tool_prefix + "readelf" |
| - nm = tool_prefix + "nm" |
| - strip = "${tool_prefix}strip" |
| + readelf = _tool_prefix + "readelf" |
| + nm = _tool_prefix + "nm" |
| + strip = "${_tool_prefix}strip" |
| # Don't use .cr.so for loadable_modules since they are always loaded via |
| # absolute path. |
| loadable_module_extension = ".so" |
| - |
| - toolchain_os = "android" |
| - toolchain_cpu = invoker.toolchain_cpu |
| } |
| } |
| template("android_gcc_toolchains_helper") { |
| android_gcc_toolchain(target_name) { |
| - android_ndk_sysroot = invoker.android_ndk_sysroot |
| - android_ndk_lib_dir = invoker.android_ndk_lib_dir |
| - toolchain_cpu = invoker.toolchain_cpu |
| + forward_variables_from(invoker, "*") |
| } |
| android_gcc_toolchain("clang_$target_name") { |
| - android_ndk_sysroot = invoker.android_ndk_sysroot |
| - android_ndk_lib_dir = invoker.android_ndk_lib_dir |
| - toolchain_cpu = invoker.toolchain_cpu |
| + forward_variables_from(invoker, "*") |
| is_clang = true |
| } |
| } |
| android_gcc_toolchains_helper("x86") { |
| - android_ndk_sysroot = "$android_ndk_root/$x86_android_sysroot_subdir" |
| - android_ndk_lib_dir = "usr/lib" |
| - |
| toolchain_cpu = "x86" |
| + toolchain_root = "$x86_android_toolchain_root" |
| + sysroot = "$android_ndk_root/$x86_android_sysroot_subdir" |
| + lib_dir = "usr/lib" |
| + binary_prefix = "i686-linux-android" |
| } |
| android_gcc_toolchains_helper("arm") { |
| - android_ndk_sysroot = "$android_ndk_root/$arm_android_sysroot_subdir" |
| - android_ndk_lib_dir = "usr/lib" |
| - |
| toolchain_cpu = "arm" |
| + toolchain_root = "$arm_android_toolchain_root" |
| + sysroot = "$android_ndk_root/$arm_android_sysroot_subdir" |
| + lib_dir = "usr/lib" |
| + binary_prefix = "arm-linux-androideabi" |
| } |
| android_gcc_toolchains_helper("mipsel") { |
| - android_ndk_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir" |
| - android_ndk_lib_dir = "usr/lib" |
| - |
| toolchain_cpu = "mipsel" |
| + toolchain_root = "$mips_android_toolchain_root" |
| + sysroot = "$android_ndk_root/$mips_android_sysroot_subdir" |
| + lib_dir = "usr/lib" |
| + binary_prefix = "mipsel-linux-android" |
| } |
| android_gcc_toolchains_helper("x64") { |
| - android_ndk_sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir" |
| - android_ndk_lib_dir = "usr/lib64" |
| - |
| toolchain_cpu = "x86_64" |
| + toolchain_root = "$x86_64_android_toolchain_root" |
| + sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir" |
| + lib_dir = "usr/lib64" |
| + binary_prefix = "x86_64-linux-android" |
| } |
| android_gcc_toolchains_helper("arm64") { |
| - android_ndk_sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir" |
| - android_ndk_lib_dir = "usr/lib" |
| - |
| toolchain_cpu = "aarch64" |
|
michaelbai
2016/06/03 17:52:35
toolchain_cpu is set to current_cpu in gcc_toolcha
agrieve
2016/06/03 18:08:45
aah, I gotcha. Fixed!
|
| + toolchain_root = "$arm64_android_toolchain_root" |
| + sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir" |
| + lib_dir = "usr/lib" |
| + binary_prefix = "aarch64-linux-android" |
| } |
| android_gcc_toolchains_helper("mips64el") { |
| - android_ndk_sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir" |
| - android_ndk_lib_dir = "usr/lib64" |
| - |
| toolchain_cpu = "mips64el" |
| + toolchain_root = "$mips64_android_toolchain_root" |
| + sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir" |
| + lib_dir = "usr/lib64" |
| + binary_prefix = "mips64el-linux-android" |
| } |