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/gcc_toolchain.gni") | 6 import("//build/toolchain/gcc_toolchain.gni") |
7 | 7 |
8 # The Android GCC toolchains share most of the same parameters, so we have this | 8 # The Android GCC toolchains share most of the same parameters, so we have this |
9 # wrapper around gcc_toolchain to avoid duplication of logic. | 9 # wrapper around gcc_toolchain to avoid duplication of logic. |
10 # | 10 # |
11 # Parameters: | 11 # Parameters: |
12 # - android_ndk_sysroot | 12 # - toolchain_cpu |
| 13 # Same as gcc_toolchain. |
| 14 # - toolchain_root |
| 15 # Path to cpu-specific toolchain within the ndk. |
| 16 # - sysroot |
13 # Sysroot for this architecture. | 17 # Sysroot for this architecture. |
14 # - android_ndk_lib_dir | 18 # - lib_dir |
15 # Subdirectory inside of android_ndk_sysroot where libs go. | 19 # Subdirectory inside of sysroot where libs go. |
16 # - toolchain_cpu | 20 # - binary_prefix |
17 # Same as gcc_toolchain | 21 # Prefix of compiler executables. |
18 template("android_gcc_toolchain") { | 22 template("android_gcc_toolchain") { |
19 gcc_toolchain(target_name) { | 23 gcc_toolchain(target_name) { |
| 24 is_clang = invoker.is_clang |
| 25 toolchain_cpu = invoker.toolchain_cpu |
| 26 toolchain_os = "android" |
| 27 |
20 # Make our manually injected libs relative to the build dir. | 28 # Make our manually injected libs relative to the build dir. |
21 android_ndk_lib = rebase_path( | 29 _ndk_lib = |
22 invoker.android_ndk_sysroot + "/" + invoker.android_ndk_lib_dir, | 30 rebase_path(invoker.sysroot + "/" + invoker.lib_dir, root_build_dir) |
23 root_build_dir) | |
24 | 31 |
25 libs_section_prefix = "$android_ndk_lib/crtbegin_dynamic.o" | 32 libs_section_prefix = "$_ndk_lib/crtbegin_dynamic.o" |
26 libs_section_postfix = "$android_ndk_lib/crtend_android.o" | 33 libs_section_postfix = "$_ndk_lib/crtend_android.o" |
27 | 34 |
28 solink_libs_section_prefix = "$android_ndk_lib/crtbegin_so.o" | 35 solink_libs_section_prefix = "$_ndk_lib/crtbegin_so.o" |
29 solink_libs_section_postfix = "$android_ndk_lib/crtend_so.o" | 36 solink_libs_section_postfix = "$_ndk_lib/crtend_so.o" |
| 37 |
| 38 _android_tool_prefix = |
| 39 "${invoker.toolchain_root}/bin/${invoker.binary_prefix}-" |
30 | 40 |
31 # The tools should be run relative to the build dir. | 41 # The tools should be run relative to the build dir. |
32 tool_prefix = rebase_path("$android_tool_prefix", root_build_dir) | 42 _tool_prefix = rebase_path("$_android_tool_prefix", root_build_dir) |
33 | 43 |
34 is_clang = invoker.is_clang | |
35 if (is_clang) { | 44 if (is_clang) { |
36 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", | 45 _prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", |
37 root_build_dir) | 46 root_build_dir) |
38 cc = "$prefix/clang" | 47 cc = "$_prefix/clang" |
39 cxx = "$prefix/clang++" | 48 cxx = "$_prefix/clang++" |
40 } else { | 49 } else { |
41 cc = "${tool_prefix}gcc" | 50 cc = "${_tool_prefix}gcc" |
42 cxx = "${tool_prefix}g++" | 51 cxx = "${_tool_prefix}g++" |
43 } | 52 } |
44 ar = tool_prefix + "ar" | 53 ar = _tool_prefix + "ar" |
45 ld = cxx | 54 ld = cxx |
46 readelf = tool_prefix + "readelf" | 55 readelf = _tool_prefix + "readelf" |
47 nm = tool_prefix + "nm" | 56 nm = _tool_prefix + "nm" |
48 strip = "${tool_prefix}strip" | 57 strip = "${_tool_prefix}strip" |
49 | 58 |
50 # Don't use .cr.so for loadable_modules since they are always loaded via | 59 # Don't use .cr.so for loadable_modules since they are always loaded via |
51 # absolute path. | 60 # absolute path. |
52 loadable_module_extension = ".so" | 61 loadable_module_extension = ".so" |
53 | |
54 toolchain_os = "android" | |
55 toolchain_cpu = invoker.toolchain_cpu | |
56 } | 62 } |
57 } | 63 } |
58 | 64 |
59 template("android_gcc_toolchains_helper") { | 65 template("android_gcc_toolchains_helper") { |
60 android_gcc_toolchain(target_name) { | 66 android_gcc_toolchain(target_name) { |
61 android_ndk_sysroot = invoker.android_ndk_sysroot | 67 forward_variables_from(invoker, "*") |
62 android_ndk_lib_dir = invoker.android_ndk_lib_dir | |
63 toolchain_cpu = invoker.toolchain_cpu | |
64 } | 68 } |
65 | 69 |
66 android_gcc_toolchain("clang_$target_name") { | 70 android_gcc_toolchain("clang_$target_name") { |
67 android_ndk_sysroot = invoker.android_ndk_sysroot | 71 forward_variables_from(invoker, "*") |
68 android_ndk_lib_dir = invoker.android_ndk_lib_dir | |
69 toolchain_cpu = invoker.toolchain_cpu | |
70 is_clang = true | 72 is_clang = true |
71 } | 73 } |
72 } | 74 } |
73 | 75 |
74 android_gcc_toolchains_helper("x86") { | 76 android_gcc_toolchains_helper("x86") { |
75 android_ndk_sysroot = "$android_ndk_root/$x86_android_sysroot_subdir" | |
76 android_ndk_lib_dir = "usr/lib" | |
77 | |
78 toolchain_cpu = "x86" | 77 toolchain_cpu = "x86" |
| 78 toolchain_root = x86_android_toolchain_root |
| 79 sysroot = "$android_ndk_root/$x86_android_sysroot_subdir" |
| 80 lib_dir = "usr/lib" |
| 81 binary_prefix = "i686-linux-android" |
79 } | 82 } |
80 | 83 |
81 android_gcc_toolchains_helper("arm") { | 84 android_gcc_toolchains_helper("arm") { |
82 android_ndk_sysroot = "$android_ndk_root/$arm_android_sysroot_subdir" | |
83 android_ndk_lib_dir = "usr/lib" | |
84 | |
85 toolchain_cpu = "arm" | 85 toolchain_cpu = "arm" |
| 86 toolchain_root = arm_android_toolchain_root |
| 87 sysroot = "$android_ndk_root/$arm_android_sysroot_subdir" |
| 88 lib_dir = "usr/lib" |
| 89 binary_prefix = "arm-linux-androideabi" |
86 } | 90 } |
87 | 91 |
88 android_gcc_toolchains_helper("mipsel") { | 92 android_gcc_toolchains_helper("mipsel") { |
89 android_ndk_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir" | |
90 android_ndk_lib_dir = "usr/lib" | |
91 | |
92 toolchain_cpu = "mipsel" | 93 toolchain_cpu = "mipsel" |
| 94 toolchain_root = mips_android_toolchain_root |
| 95 sysroot = "$android_ndk_root/$mips_android_sysroot_subdir" |
| 96 lib_dir = "usr/lib" |
| 97 binary_prefix = "mipsel-linux-android" |
93 } | 98 } |
94 | 99 |
95 android_gcc_toolchains_helper("x64") { | 100 android_gcc_toolchains_helper("x64") { |
96 android_ndk_sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir" | |
97 android_ndk_lib_dir = "usr/lib64" | |
98 | |
99 toolchain_cpu = "x86_64" | 101 toolchain_cpu = "x86_64" |
| 102 toolchain_root = x86_64_android_toolchain_root |
| 103 sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir" |
| 104 lib_dir = "usr/lib64" |
| 105 binary_prefix = "x86_64-linux-android" |
100 } | 106 } |
101 | 107 |
102 android_gcc_toolchains_helper("arm64") { | 108 android_gcc_toolchains_helper("arm64") { |
103 android_ndk_sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir" | 109 toolchain_cpu = "arm64" |
104 android_ndk_lib_dir = "usr/lib" | 110 toolchain_root = arm64_android_toolchain_root |
105 | 111 sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir" |
106 toolchain_cpu = "aarch64" | 112 lib_dir = "usr/lib" |
| 113 binary_prefix = "aarch64-linux-android" |
107 } | 114 } |
108 | 115 |
109 android_gcc_toolchains_helper("mips64el") { | 116 android_gcc_toolchains_helper("mips64el") { |
110 android_ndk_sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir" | |
111 android_ndk_lib_dir = "usr/lib64" | |
112 | |
113 toolchain_cpu = "mips64el" | 117 toolchain_cpu = "mips64el" |
| 118 toolchain_root = mips64_android_toolchain_root |
| 119 sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir" |
| 120 lib_dir = "usr/lib64" |
| 121 binary_prefix = "mips64el-linux-android" |
114 } | 122 } |
OLD | NEW |