summaryrefslogtreecommitdiffstats
path: root/build/config/android/config.gni
blob: f28165beba05c17c9aa11e6ea17136175089f32c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This file contains common system config stuff for the Android build.

if (is_android) {
  declare_args() {
    # Absolute directory containing the Android source code.
    android_src = ""

    # This is set when building the Android WebView inside the Android build
    # system, using the 'android' gyp backend. The WebView code is still built
    # when this is unset, but builds using the normal chromium build system.
    is_android_webview_build = false
  }

  if (is_android_webview_build) {
    assert(android_src != "",
           "You must specify android_src for an Android WebView build.")
  }

  # Host stuff -----------------------------------------------------------------

  # Defines the name the Android build gives to the current host CPU
  # architecture, which is different than the names GN uses.
  if (build_cpu_arch == "x64") {
    android_host_arch = "x86_64"
  } else if (build_cpu_arch == "x86") {
    android_host_arch = "x86"
  } else {
    assert(false, "Need Android toolchain support for your build CPU arch.")
  }

  # Defines the name the Android build gives to the current host CPU
  # architecture, which is different than the names GN uses.
  if (build_os == "linux") {
    android_host_os = "linux"
  } else {
    assert(false, "Need Android toolchain support for your build OS.")
  }

  # Directories and files ------------------------------------------------------
  #
  # We define may of the dirs strings here for each output architecture (rather
  # than just the current one) since these are needed by the Android toolchain
  # file to define toolchains for all possible targets in one pass.

  # Path to the Android NDK.
  android_ndk_root = "//third_party/android_tools/ndk"

  # Subdirectories inside android_ndk_root that contain the sysroot for the
  # associated platform.
  _android_api_level = 14
  x86_android_sysroot_subdir = "platforms/android-${_android_api_level}/arch-x86"
  arm_android_sysroot_subdir = "platforms/android-${_android_api_level}/arch-arm"
  mips_android_sysroot_subdir = "platforms/android-${_android_api_level}/arch-mips"

  # Toolchain root directory for each build. The actual binaries are inside
  # a "bin" directory inside of these.
  _android_toolchain_version = "4.8"
  x86_android_toolchain_root = "$android_ndk_root/toolchains/x86-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
  arm_android_toolchain_root = "$android_ndk_root/toolchains/arm-linux-androideabi-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
  mips_android_toolchain_root = "$android_ndk_root/toolchains/mipsel-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"

  # Location of libgcc. This is only needed for the current GN toolchain, so we
  # only need to define the current one, rather than one for every platform
  # like the toolchain roots.
  if (cpu_arch == "x86") {
    android_libgcc_file =
      "$x86_android_toolchain_root/lib/gcc/i686-linux-android/${_android_toolchain_version}/libgcc.a"
  } else if (cpu_arch == "arm") {
    android_libgcc_file =
      "$arm_android_toolchain_root/lib/gcc/arm-linux-androideabi/${_android_toolchain_version}/libgcc.a"
  } else if (cpu_arch == "mips") {
    android_libgcc_file =
      "$mips_android_toolchain_root/lib/gcc/mipsel-linux-android/${_android_toolchain_version}/libgcc.a"
  } else {
    assert(false, "Need android libgcc support for your target arch.")
  }

  # stlport stuff --------------------------------------------------------------

  use_system_stlport = is_android_webview_build

  if (use_system_stlport) {
    android_stlport_library = "stlport"
  } else if (component_mode == "shared_library") {
    android_stlport_library = "stlport_shared"
  } else {
    android_stlport_library = "stlport_static"
  }

  # ABI ------------------------------------------------------------------------

  if (cpu_arch == "x86") {
    android_app_abi = "x86"
  } else if (cpu_arch == "arm") {
    import("//build/config/arm.gni")
    if (arm_version < 7) {
      android_app_abi = "armeabi"
    } else {
      android_app_abi = "armeabi-v7a"
    }
  } else if (cpu_arch == "mipsel") {
    android_app_abi = "mips"
  } else {
    assert(false, "Unknown Android ABI: " + cpu_arch)
  }
} else {
  if (!defined(is_android_webview_build)) {
    is_android_webview_build = false
  }
  use_system_stlport = false
}