| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/config/sysroot.gni") # Imports android/config.gni. | 5 import("//build/config/sysroot.gni") # Imports android/config.gni. |
| 6 import("//build/toolchain/ccache.gni") |
| 6 import("//build/toolchain/clang.gni") | 7 import("//build/toolchain/clang.gni") |
| 7 import("//build/toolchain/goma.gni") | 8 import("//build/toolchain/goma.gni") |
| 8 import("//build/toolchain/gcc_toolchain.gni") | 9 import("//build/toolchain/gcc_toolchain.gni") |
| 9 | 10 |
| 10 # The Android GCC toolchains share most of the same parameters, so we have this | 11 # The Android GCC toolchains share most of the same parameters, so we have this |
| 11 # wrapper around gcc_toolchain to avoid duplication of logic. | 12 # wrapper around gcc_toolchain to avoid duplication of logic. |
| 12 # | 13 # |
| 13 # Parameters: | 14 # Parameters: |
| 14 # - android_ndk_sysroot | 15 # - android_ndk_sysroot |
| 15 # Sysroot for this architecture. | 16 # Sysroot for this architecture. |
| 16 # - android_ndk_lib_dir | 17 # - android_ndk_lib_dir |
| 17 # Subdirectory inside of android_ndk_sysroot where libs go. | 18 # Subdirectory inside of android_ndk_sysroot where libs go. |
| 18 # - tool_prefix | 19 # - tool_prefix |
| 19 # Prefix to be added to the tool names. | 20 # Prefix to be added to the tool names. |
| 20 # - toolchain_cpu_arch | 21 # - toolchain_cpu_arch |
| 21 # Same as gcc_toolchain | 22 # Same as gcc_toolchain |
| 22 template("android_gcc_toolchain") { | 23 template("android_gcc_toolchain") { |
| 23 gcc_toolchain(target_name) { | 24 gcc_toolchain(target_name) { |
| 24 # Make our manually injected libs relative to the build dir. | 25 # Make our manually injected libs relative to the build dir. |
| 25 android_ndk_lib = rebase_path( | 26 android_ndk_lib = rebase_path( |
| 26 invoker.android_ndk_sysroot + "/" + invoker.android_ndk_lib_dir, | 27 invoker.android_ndk_sysroot + "/" + invoker.android_ndk_lib_dir, |
| 27 root_build_dir) | 28 root_build_dir) |
| 28 | 29 |
| 29 libs_section_prefix = "$android_ndk_lib/crtbegin_dynamic.o" | 30 libs_section_prefix = "$android_ndk_lib/crtbegin_dynamic.o" |
| 30 libs_section_postfix = "$android_ndk_lib/crtend_android.o" | 31 libs_section_postfix = "$android_ndk_lib/crtend_android.o" |
| 31 | 32 |
| 32 solink_libs_section_prefix = "$android_ndk_lib/crtbegin_so.o" | 33 solink_libs_section_prefix = "$android_ndk_lib/crtbegin_so.o" |
| 33 solink_libs_section_postfix = "$android_ndk_lib/crtend_so.o" | 34 solink_libs_section_postfix = "$android_ndk_lib/crtend_so.o" |
| 34 | 35 |
| 35 # The tools should be run relative to the build dir. | 36 # The tools should be run relative to the build dir. |
| 36 tool_prefix = rebase_path(invoker.tool_prefix, root_build_dir) | 37 tool_prefix = rebase_path(invoker.tool_prefix, root_build_dir) |
| 37 | 38 |
| 38 if (use_goma) { | 39 if (use_goma) { |
| 39 goma_prefix = "$goma_dir/gomacc " | 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 " |
| 40 } else { | 44 } else { |
| 41 goma_prefix = "" | 45 compiler_prefix = "" |
| 42 } | 46 } |
| 43 | 47 |
| 44 cc = goma_prefix + tool_prefix + "gcc" | 48 cc = compiler_prefix + tool_prefix + "gcc" |
| 45 cxx = goma_prefix + tool_prefix + "g++" | 49 cxx = compiler_prefix + tool_prefix + "g++" |
| 46 ar = tool_prefix + "ar" | 50 ar = tool_prefix + "ar" |
| 47 ld = cxx | 51 ld = cxx |
| 48 | 52 |
| 49 toolchain_os = "android" | 53 toolchain_os = "android" |
| 50 toolchain_cpu_arch = invoker.toolchain_cpu_arch | 54 toolchain_cpu_arch = invoker.toolchain_cpu_arch |
| 51 | 55 |
| 52 # We make the assumption that the gcc_toolchain will produce a soname with | 56 # We make the assumption that the gcc_toolchain will produce a soname with |
| 53 # the following definition. | 57 # the following definition. |
| 54 soname = "{{target_output_name}}{{output_extension}}" | 58 soname = "{{target_output_name}}{{output_extension}}" |
| 55 | 59 |
| 56 stripped_soname = "lib.stripped/${soname}" | 60 stripped_soname = "lib.stripped/${soname}" |
| 57 temp_stripped_soname = "${stripped_soname}.tmp" | 61 temp_stripped_soname = "${stripped_soname}.tmp" |
| 58 | 62 |
| 59 android_strip = "${tool_prefix}strip" | 63 android_strip = "${tool_prefix}strip" |
| 60 | 64 |
| 61 mkdir_command = "mkdir -p lib.stripped" | 65 mkdir_command = "mkdir -p lib.stripped" |
| 62 strip_command = "$android_strip --strip-unneeded -o $temp_stripped_soname $s
oname" | 66 strip_command = |
| 63 replace_command = "if ! cmp -s $temp_stripped_soname $stripped_soname; then
mv $temp_stripped_soname $stripped_soname; fi" | 67 "$android_strip --strip-unneeded -o $temp_stripped_soname $soname" |
| 68 replace_command = |
| 69 "if ! cmp -s $temp_stripped_soname $stripped_soname; then mv $temp_strip
ped_soname $stripped_soname; fi" |
| 64 postsolink = "$mkdir_command && $strip_command && $replace_command" | 70 postsolink = "$mkdir_command && $strip_command && $replace_command" |
| 65 solink_outputs = [ stripped_soname ] | 71 solink_outputs = [ stripped_soname ] |
| 66 | 72 |
| 67 # We make the assumption that the gcc_toolchain will produce an exe with | 73 # We make the assumption that the gcc_toolchain will produce an exe with |
| 68 # the following definition. | 74 # the following definition. |
| 69 exe = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" | 75 exe = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
| 70 stripped_exe = "exe.stripped/$exe" | 76 stripped_exe = "exe.stripped/$exe" |
| 71 mkdir_command = "mkdir -p exe.stripped" | 77 mkdir_command = "mkdir -p exe.stripped" |
| 72 strip_command = "$android_strip --strip-unneeded -o $stripped_exe $exe" | 78 strip_command = "$android_strip --strip-unneeded -o $stripped_exe $exe" |
| 73 postlink = "$mkdir_command && $strip_command" | 79 postlink = "$mkdir_command && $strip_command" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 91 toolchain_cpu_arch = "arm" | 97 toolchain_cpu_arch = "arm" |
| 92 } | 98 } |
| 93 | 99 |
| 94 android_gcc_toolchain("mipsel") { | 100 android_gcc_toolchain("mipsel") { |
| 95 android_ndk_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir" | 101 android_ndk_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir" |
| 96 android_ndk_lib_dir = "usr/lib" | 102 android_ndk_lib_dir = "usr/lib" |
| 97 | 103 |
| 98 tool_prefix = "$mips_android_toolchain_root/bin/mipsel-linux-android-" | 104 tool_prefix = "$mips_android_toolchain_root/bin/mipsel-linux-android-" |
| 99 toolchain_cpu_arch = "mipsel" | 105 toolchain_cpu_arch = "mipsel" |
| 100 } | 106 } |
| OLD | NEW |