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