blob: f7751236ade28a170d7d64c27fc11e992ca16bfe [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001# Copyright 2014 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# This file contains common system config stuff for the Android build.
6
7if (is_android) {
8 assert(rebase_path("//", root_build_dir) == "../../",
9 "Android output directory must be nested 2 levels within src/ (" +
10 "e.g.: out-gn/Debug). http://crbug.com/412935")
11 has_chrome_android_internal =
12 exec_script("//build/dir_exists.py",
13 [ rebase_path("//clank", root_build_dir) ],
14 "string") == "True"
15
16 if (has_chrome_android_internal) {
17 import("//clank/config.gni")
18 }
19
20 if (!defined(extra_chrome_shared_library_configs)) {
21 extra_chrome_shared_library_configs = []
22 }
23
24 if (!defined(default_android_sdk_root)) {
25 default_android_sdk_root = "//third_party/android_tools/sdk"
26 default_android_sdk_version = "23"
27 default_android_sdk_build_tools_version = "23.0.1"
28 }
29
30 if (!defined(default_android_keystore_path)) {
31 default_android_keystore_path =
32 "//build/android/ant/chromium-debug.keystore"
33 default_android_keystore_name = "chromiumdebugkey"
34 default_android_keystore_password = "chromium"
35 }
36
37 if (!defined(google_play_services_library)) {
38 google_play_services_library =
39 "//third_party/android_tools:google_play_services_default_java"
40 }
41
42 if (!defined(google_play_services_resources)) {
43 google_play_services_resources =
44 "//third_party/android_tools:google_play_services_default_resources"
45 }
46
47 webview_public_framework_jar =
48 "//third_party/android_platform/webview/frameworks_6.0.jar"
49 if (!defined(webview_framework_jar)) {
50 webview_framework_jar = webview_public_framework_jar
51 }
52
53 declare_args() {
54 android_sdk_root = default_android_sdk_root
55 android_sdk_version = default_android_sdk_version
56 android_sdk_build_tools_version = default_android_sdk_build_tools_version
57
58 # Libc++ library directory. Override to use a custom libc++ binary.
59 android_libcpp_lib_dir = ""
60
61 # Android versionCode for android_apk()s that don't expclitly set one.
62 android_default_version_code = "1"
63
64 # Android versionName for android_apk()s that don't expclitly set one.
65 android_default_version_name = "Developer Build"
66
67 # The path to the keystore to use for signing builds.
68 android_keystore_path = default_android_keystore_path
69
70 # The name of the keystore to use for signing builds.
71 android_keystore_name = default_android_keystore_name
72
73 # The password for the keystore to use for signing builds.
74 android_keystore_password = default_android_keystore_password
75
76 # Set to true to run findbugs on JAR targets.
77 run_findbugs = false
78
79 # Set to true to enable verbose findbugs logging. This does nothing if
80 # run_findbugs is false.
81 findbugs_verbose = false
82
83 # Enables verbose proguard output (summaries and unfiltered output).
84 proguard_verbose = false
85
86 # Set to true to enable the Errorprone compiler
87 use_errorprone_java_compiler = false
88
89 # Enables EMMA Java code coverage. Instruments classes during build to
90 # produce .ec files during runtime
91 emma_coverage = false
92
93 # EMMA filter string consisting of a list of inclusion/exclusion patterns
94 # separated with whitespace and/or comma. Only has effect if
95 # emma_coverage==true
96 emma_filter = ""
97
98 # Disables process isolation when building _incremental targets.
99 # Required for Android M+ due to SELinux policies (stronger sandboxing).
100 disable_incremental_isolated_processes = false
101
102 # Speed up incremental compiles by compiling only changed files.
103 enable_incremental_javac = false
104
105 # Speed up dexing using dx --incremental.
106 enable_incremental_dx = is_debug
107
108 # Neither of these should ever be used for release builds since they are
109 # somewhat experimental and dx --incremental is known to not produce
110 # byte-for-byte identical output.
111 assert(!(enable_incremental_dx && !is_debug))
112 assert(!(enable_incremental_javac && !is_debug))
113
114 # Adds intrumentation to each function. Writes a file with the order that
115 # functions are called at startup.
116 use_order_profiling = false
117 }
118
119 # Host stuff -----------------------------------------------------------------
120
121 # Defines the name the Android build gives to the current host CPU
122 # architecture, which is different than the names GN uses.
123 if (host_cpu == "x64") {
124 android_host_arch = "x86_64"
125 } else if (host_cpu == "x86") {
126 android_host_arch = "x86"
127 } else {
128 assert(false, "Need Android toolchain support for your build CPU arch.")
129 }
130
131 # Defines the name the Android build gives to the current host CPU
132 # architecture, which is different than the names GN uses.
133 if (host_os == "linux") {
134 android_host_os = "linux"
135 } else if (host_os == "mac") {
136 android_host_os = "darwin"
137 } else {
138 assert(false, "Need Android toolchain support for your build OS.")
139 }
140
141 # Directories and files ------------------------------------------------------
142 #
143 # We define may of the dirs strings here for each output architecture (rather
144 # than just the current one) since these are needed by the Android toolchain
145 # file to define toolchains for all possible targets in one pass.
146
147 android_sdk = "${android_sdk_root}/platforms/android-${android_sdk_version}"
148
149 # Path to the Android NDK and SDK.
150 android_ndk_root = "//third_party/android_tools/ndk"
151 android_ndk_include_dir = "$android_ndk_root/usr/include"
152
153 android_sdk_tools = "${android_sdk_root}/tools"
154 android_sdk_build_tools =
155 "${android_sdk_root}/build-tools/$android_sdk_build_tools_version"
156
157 # Path to the SDK's android.jar
158 android_sdk_jar = "$android_sdk/android.jar"
159
160 zipalign_path = "$android_sdk_build_tools/zipalign"
161
162 # Subdirectories inside android_ndk_root that contain the sysroot for the
163 # associated platform.
164 _android_api_level = 16
165 x86_android_sysroot_subdir =
166 "platforms/android-${_android_api_level}/arch-x86"
167 arm_android_sysroot_subdir =
168 "platforms/android-${_android_api_level}/arch-arm"
169 mips_android_sysroot_subdir =
170 "platforms/android-${_android_api_level}/arch-mips"
171 _android64_api_level = 21
172 x86_64_android_sysroot_subdir =
173 "platforms/android-${_android64_api_level}/arch-x86_64"
174 arm64_android_sysroot_subdir =
175 "platforms/android-${_android64_api_level}/arch-arm64"
176 mips64_android_sysroot_subdir =
177 "platforms/android-${_android64_api_level}/arch-mips64"
178
179 # Toolchain root directory for each build. The actual binaries are inside
180 # a "bin" directory inside of these.
181 _android_toolchain_version = "4.9"
182 x86_android_toolchain_root = "$android_ndk_root/toolchains/x86-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
183 arm_android_toolchain_root = "$android_ndk_root/toolchains/arm-linux-androideabi-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
184 mips_android_toolchain_root = "$android_ndk_root/toolchains/mipsel-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
185 x86_64_android_toolchain_root = "$android_ndk_root/toolchains/x86_64-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
186 arm64_android_toolchain_root = "$android_ndk_root/toolchains/aarch64-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
187 mips64_android_toolchain_root = "$android_ndk_root/toolchains/mips64el-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
188
189 # Location of libgcc. This is only needed for the current GN toolchain, so we
190 # only need to define the current one, rather than one for every platform
191 # like the toolchain roots.
192 if (current_cpu == "x86") {
193 android_prebuilt_arch = "android-x86"
194 _binary_prefix = "i686-linux-android"
195 android_toolchain_root = "$x86_android_toolchain_root"
196 android_libgcc_file = "$android_toolchain_root/lib/gcc/i686-linux-android/${_android_toolchain_version}/libgcc.a"
197 } else if (current_cpu == "arm") {
198 android_prebuilt_arch = "android-arm"
199 _binary_prefix = "arm-linux-androideabi"
200 android_toolchain_root = "$arm_android_toolchain_root"
201 android_libgcc_file = "$android_toolchain_root/lib/gcc/arm-linux-androideabi/${_android_toolchain_version}/libgcc.a"
202 } else if (current_cpu == "mipsel") {
203 android_prebuilt_arch = "android-mips"
204 _binary_prefix = "mipsel-linux-android"
205 android_toolchain_root = "$mips_android_toolchain_root"
206 android_libgcc_file = "$android_toolchain_root/lib/gcc/mipsel-linux-android/${_android_toolchain_version}/libgcc.a"
207 } else if (current_cpu == "x64") {
208 android_prebuilt_arch = "android-x86_64"
209 _binary_prefix = "x86_64-linux-android"
210 android_toolchain_root = "$x86_64_android_toolchain_root"
211 android_libgcc_file = "$android_toolchain_root/lib/gcc/x86_64-linux-android/${_android_toolchain_version}/libgcc.a"
212 } else if (current_cpu == "arm64") {
213 android_prebuilt_arch = "android-arm64"
214 _binary_prefix = "aarch64-linux-android"
215 android_toolchain_root = "$arm64_android_toolchain_root"
216 android_libgcc_file = "$android_toolchain_root/lib/gcc/aarch64-linux-android/${_android_toolchain_version}/libgcc.a"
217 } else if (current_cpu == "mips64el") {
218 android_prebuilt_arch = "android-mips64"
219 _binary_prefix = "mips64el-linux-android"
220 android_toolchain_root = "$mips64_android_toolchain_root"
221 android_libgcc_file = "$android_toolchain_root/lib/gcc/mips64el-linux-android/${_android_toolchain_version}/libgcc.a"
222 } else {
223 assert(false, "Need android libgcc support for your target arch.")
224 }
225
226 android_tool_prefix = "$android_toolchain_root/bin/$_binary_prefix-"
227 android_readelf = "${android_tool_prefix}readelf"
228 android_objcopy = "${android_tool_prefix}objcopy"
229 android_gdbserver =
230 "$android_ndk_root/prebuilt/$android_prebuilt_arch/gdbserver/gdbserver"
231
232 # Toolchain stuff ------------------------------------------------------------
233
234 android_libcpp_root = "$android_ndk_root/sources/cxx-stl/llvm-libc++"
235
236 # ABI ------------------------------------------------------------------------
237
238 # Intentionally do not define android_app_secondary_abi for 64-bit
239 # android_app_abi, since they are not used.
240 if (current_cpu == "x86") {
241 android_app_abi = "x86"
242 android_app_secondary_abi = "x86_64"
243 } else if (current_cpu == "arm") {
244 import("//build/config/arm.gni")
245 if (arm_version < 7) {
246 android_app_abi = "armeabi"
247 } else {
248 android_app_abi = "armeabi-v7a"
249 }
250 android_app_secondary_abi = "arm64-v8a"
251 } else if (current_cpu == "mipsel") {
252 android_app_abi = "mips"
253 android_app_secondary_abi = "mips64"
254 } else if (current_cpu == "x64") {
255 android_app_abi = "x86_64"
256 } else if (current_cpu == "arm64") {
257 android_app_abi = "arm64-v8a"
258 } else if (current_cpu == "mips64el") {
259 android_app_abi = "mips64"
260 } else {
261 assert(false, "Unknown Android ABI: " + current_cpu)
262 }
263
264 if (android_libcpp_lib_dir == "") {
265 android_libcpp_lib_dir = "${android_libcpp_root}/libs/${android_app_abi}"
266 }
267}