summaryrefslogtreecommitdiffstats
path: root/build/android/envsetup.sh
blob: 6c4c563d31e1b15ca7e7b4f0b2c86d8fa1724fcb (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash

# Copyright (c) 2012 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.

# Sets up environment for building Chromium on Android. Only Android NDK,
# Revision 6b on Linux or Mac is offically supported.
#
# To run this script, the system environment ANDROID_NDK_ROOT must be set
# to Android NDK's root path.
#
# TODO(michaelbai): Develop a standard for NDK/SDK integration.
#
# If current path isn't the Chrome's src directory, CHROME_SRC must be set
# to the Chrome's src directory.

if [ ! -d "${ANDROID_NDK_ROOT}" ]; then
  echo "ANDROID_NDK_ROOT must be set to the path of Android NDK, Revision 6b." \
    >& 2
  echo "which could be installed by" >& 2
  echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2
  return 1
fi

if [ ! -d "${ANDROID_SDK_ROOT}" ]; then
  echo "ANDROID_SDK_ROOT must be set to the path of Android SDK, Android 3.2." \
    >& 2
  echo "which could be installed by" >& 2
  echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2
  return 1
fi

host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')

case "${host_os}" in
  "linux")
    toolchain_dir="linux-x86"
    ;;
  "mac")
    toolchain_dir="darwin-x86"
    ;;
  *)
    echo "Host platform ${host_os} is not supported" >& 2
    return 1
esac

export ANDROID_TOOLCHAIN="${ANDROID_NDK_ROOT}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/${toolchain_dir}/bin/"

export ANDROID_SDK_VERSION="15"

# Add Android SDK's platform-tools to system path.
export PATH="${PATH}:${ANDROID_SDK_ROOT}/platform-tools/"

if [ ! -d "${ANDROID_TOOLCHAIN}" ]; then
  echo "Can not find Android toolchain in ${ANDROID_TOOLCHAIN}." >& 2
  echo "The NDK version might be wrong." >& 2
  return 1
fi

if [ -z "${CHROME_SRC}" ]; then
  # If $CHROME_SRC was not set, assume current directory is CHROME_SRC.
  export CHROME_SRC=$(readlink -f .)
fi

if [ ! -d "${CHROME_SRC}" ]; then
  echo "CHROME_SRC must be set to the path of Chrome source code." >& 2
  return 1
fi

# Performs a gyp_chromium run to convert gyp->Makefile for android code.
android_gyp() {
  GOMA_WRAPPER=""
  if [[ -d $GOMA_DIR ]]; then
    GOMA_WRAPPER="$GOMA_DIR/gomacc"
  fi
  # Ninja requires "*_target" for target builds.
  GOMA_WRAPPER=${GOMA_WRAPPER} \
  CC_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) \
  CXX_target=$(basename ${ANDROID_TOOLCHAIN}/*-g++) \
  LINK_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) \
  AR_target=$(basename ${ANDROID_TOOLCHAIN}/*-ar) \
  "${CHROME_SRC}/build/gyp_chromium" --depth="${CHROME_SRC}"
}

export OBJCOPY=$(echo ${ANDROID_TOOLCHAIN}/*-objcopy)
export STRIP=$(echo ${ANDROID_TOOLCHAIN}/*-strip)

# The set of GYP_DEFINES to pass to gyp. Use 'readlink -e' on directories
# to canonicalize them (remove double '/', remove trailing '/', etc).
DEFINES="OS=android"
DEFINES+=" android_build_type=0"  # Currently, Only '0' is supportted.
DEFINES+=" host_os=${host_os}"
DEFINES+=" linux_fpic=1"
DEFINES+=" release_optimize=s"
DEFINES+=" linux_use_tcmalloc=0"
DEFINES+=" disable_nacl=1"
DEFINES+=" remoting=0"
DEFINES+=" p2p_apis=0"
DEFINES+=" enable_touch_events=1"
DEFINES+=" build_ffmpegsumo=0"
# TODO(bulach): use "shared_libraries" once the transition from executable
# is over.
DEFINES+=" gtest_target_type=executable"
DEFINES+=" branding=Chromium"

# If the TARGET_PRODUCT wasn't set, use 'full' by default.
if [ -z "${TARGET_PRODUCT}" ]; then
  TARGET_PRODUCT="full"
fi

# The following defines will affect ARM code generation of both C/C++ compiler
# and V8 mksnapshot.
case "${TARGET_PRODUCT}" in
  "full")
    DEFINES+=" target_arch=arm"
    DEFINES+=" arm_neon=0 armv7=1 arm_thumb=1 arm_fpu=vfpv3-d16"
    ;;
  *x86*)
    DEFINES+=" target_arch=ia32 use_libffmpeg=0"
    ;;
  *)
    echo "TARGET_PRODUCT: ${TARGET_PRODUCT} is not supported." >& 2
    return 1
esac

export GYP_DEFINES="${DEFINES}"

# Use the "android" flavor of the Makefile generator for both Linux and OS X.
export GYP_GENERATORS="make-android"

# Use our All target as the default
export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All"

# We want to use our version of "all" targets.
export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android.gyp"