Home | History | Annotate | Download | only in android
      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 
      7 if (is_android) {
      8   declare_args() {
      9     # Absolute directory containing the Android source code.
     10     android_src = ""
     11 
     12     android_sdk_root = "//third_party/android_tools/sdk"
     13     android_sdk_version = "20"
     14 
     15     # This is set when building the Android WebView inside the Android build
     16     # system, using the 'android' gyp backend. The WebView code is still built
     17     # when this is unset, but builds using the normal chromium build system.
     18     is_android_webview_build = false
     19 
     20     android_default_keystore_path = "//build/android/ant/chromium-debug.keystore"
     21     android_default_keystore_name = "chromiumdebugkey"
     22     android_default_keystore_password = "chromium"
     23 
     24     # This is a unique identifier for a given build. It's used for
     25     # identifying various build artifacts corresponding to a particular build of
     26     # chrome (e.g. where to find archived symbols).
     27     android_chrome_build_id = "\"\""
     28   }
     29 
     30   if (is_android_webview_build) {
     31     assert(android_src != "",
     32            "You must specify android_src for an Android WebView build.")
     33   }
     34 
     35 
     36   # Host stuff -----------------------------------------------------------------
     37 
     38   # Defines the name the Android build gives to the current host CPU
     39   # architecture, which is different than the names GN uses.
     40   if (build_cpu_arch == "x64") {
     41     android_host_arch = "x86_64"
     42   } else if (build_cpu_arch == "x86") {
     43     android_host_arch = "x86"
     44   } else {
     45     assert(false, "Need Android toolchain support for your build CPU arch.")
     46   }
     47 
     48   # Defines the name the Android build gives to the current host CPU
     49   # architecture, which is different than the names GN uses.
     50   if (build_os == "linux") {
     51     android_host_os = "linux"
     52   } else {
     53     assert(false, "Need Android toolchain support for your build OS.")
     54   }
     55 
     56   # Directories and files ------------------------------------------------------
     57   #
     58   # We define may of the dirs strings here for each output architecture (rather
     59   # than just the current one) since these are needed by the Android toolchain
     60   # file to define toolchains for all possible targets in one pass.
     61 
     62   android_sdk = "${android_sdk_root}/platforms/android-${android_sdk_version}"
     63 
     64   # Path to the Android NDK and SDK.
     65   android_ndk_root = "//third_party/android_tools/ndk"
     66 
     67   android_sdk = "${android_sdk_root}/platforms/android-${android_sdk_version}"
     68 
     69   android_sdk_tools = "${android_sdk_root}/tools"
     70   android_sdk_build_tools = "${android_sdk_root}/build-tools/20.0.0"
     71 
     72   # Path to the SDK's android.jar
     73   android_sdk_jar = "$android_sdk/android.jar"
     74 
     75   zipalign_path = "$android_sdk_build_tools/zipalign"
     76 
     77   # Subdirectories inside android_ndk_root that contain the sysroot for the
     78   # associated platform.
     79   _android_api_level = 14
     80   x86_android_sysroot_subdir = "platforms/android-${_android_api_level}/arch-x86"
     81   arm_android_sysroot_subdir = "platforms/android-${_android_api_level}/arch-arm"
     82   mips_android_sysroot_subdir = "platforms/android-${_android_api_level}/arch-mips"
     83 
     84   # Toolchain root directory for each build. The actual binaries are inside
     85   # a "bin" directory inside of these.
     86   _android_toolchain_version = "4.9"
     87   x86_android_toolchain_root = "$android_ndk_root/toolchains/x86-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
     88   arm_android_toolchain_root = "$android_ndk_root/toolchains/arm-linux-androideabi-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
     89   mips_android_toolchain_root = "$android_ndk_root/toolchains/mipsel-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
     90 
     91   # Location of libgcc. This is only needed for the current GN toolchain, so we
     92   # only need to define the current one, rather than one for every platform
     93   # like the toolchain roots.
     94   if (cpu_arch == "x86") {
     95     android_prebuilt_arch = "android-x86"
     96     _binary_prefix = "i686-linux-android"
     97     android_toolchain_root = "$x86_android_toolchain_root"
     98     android_libgcc_file =
     99       "$android_toolchain_root/lib/gcc/i686-linux-android/${_android_toolchain_version}/libgcc.a"
    100   } else if (cpu_arch == "arm") {
    101     android_prebuilt_arch = "android-arm"
    102     _binary_prefix = "arm-linux-androideabi"
    103     android_toolchain_root = "$arm_android_toolchain_root"
    104     android_libgcc_file =
    105       "$android_toolchain_root/lib/gcc/arm-linux-androideabi/${_android_toolchain_version}/libgcc.a"
    106   } else if (cpu_arch == "mipsel") {
    107     android_prebuilt_arch = "android-mips"
    108     _binary_prefix = "mipsel-linux-android"
    109     android_toolchain_root = "$mips_android_toolchain_root"
    110     android_libgcc_file =
    111       "$android_toolchain_root/lib/gcc/mipsel-linux-android/${_android_toolchain_version}/libgcc.a"
    112   } else {
    113     assert(false, "Need android libgcc support for your target arch.")
    114   }
    115 
    116   android_readelf = "$android_toolchain_root/bin/$_binary_prefix-readelf"
    117   android_gdbserver = "$android_ndk_root/prebuilt/$android_prebuilt_arch/gdbserver/gdbserver"
    118 
    119   # stlport stuff --------------------------------------------------------------
    120 
    121   use_system_stlport = is_android_webview_build
    122 
    123   if (use_system_stlport) {
    124     android_stlport_library = "stlport"
    125   } else if (component_mode == "shared_library") {
    126     android_stlport_library = "stlport_shared"
    127   } else {
    128     android_stlport_library = "stlport_static"
    129   }
    130 
    131   # ABI ------------------------------------------------------------------------
    132 
    133   if (cpu_arch == "x86") {
    134     android_app_abi = "x86"
    135   } else if (cpu_arch == "arm") {
    136     import("//build/config/arm.gni")
    137     if (arm_version < 7) {
    138       android_app_abi = "armeabi"
    139     } else {
    140       android_app_abi = "armeabi-v7a"
    141     }
    142   } else if (cpu_arch == "mipsel") {
    143     android_app_abi = "mips"
    144   } else {
    145     assert(false, "Unknown Android ABI: " + cpu_arch)
    146   }
    147 } else {
    148   if (!defined(is_android_webview_build)) {
    149     is_android_webview_build = false
    150   }
    151   use_system_stlport = false
    152 }
    153