blob: 7ddd064ad6c5be0cf71b214d3455943d038de6ba [file] [log] [blame]
[email protected]ec5dcded2011-09-26 21:40:381#!/bin/bash
2
[email protected]94506282012-01-06 13:10:073# Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ec5dcded2011-09-26 21:40:384# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Sets up environment for building Chromium on Android. Only Android NDK,
8# Revision 6b on Linux or Mac is offically supported.
9#
10# To run this script, the system environment ANDROID_NDK_ROOT must be set
11# to Android NDK's root path.
12#
13# TODO(michaelbai): Develop a standard for NDK/SDK integration.
14#
15# If current path isn't the Chrome's src directory, CHROME_SRC must be set
16# to the Chrome's src directory.
17
18if [ ! -d "${ANDROID_NDK_ROOT}" ]; then
19 echo "ANDROID_NDK_ROOT must be set to the path of Android NDK, Revision 6b." \
20 >& 2
[email protected]4e2e2e2a2011-10-25 16:12:2421 echo "which could be installed by" >& 2
[email protected]c4fabbc32012-03-07 02:22:1822 echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2
[email protected]4e2e2e2a2011-10-25 16:12:2423 return 1
24fi
25
26if [ ! -d "${ANDROID_SDK_ROOT}" ]; then
27 echo "ANDROID_SDK_ROOT must be set to the path of Android SDK, Android 3.2." \
28 >& 2
29 echo "which could be installed by" >& 2
[email protected]c4fabbc32012-03-07 02:22:1830 echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2
[email protected]ec5dcded2011-09-26 21:40:3831 return 1
32fi
33
34host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')
35
36case "${host_os}" in
37 "linux")
38 toolchain_dir="linux-x86"
39 ;;
40 "mac")
41 toolchain_dir="darwin-x86"
42 ;;
43 *)
44 echo "Host platform ${host_os} is not supported" >& 2
45 return 1
46esac
47
[email protected]febd3572012-05-03 09:17:4548# The following defines will affect ARM code generation of both C/C++ compiler
49# and V8 mksnapshot.
50case "${TARGET_PRODUCT-full}" in
51 "full")
52 DEFINES=" target_arch=arm"
53 DEFINES+=" arm_neon=0 armv7=1 arm_thumb=1 arm_fpu=vfpv3-d16"
54 toolchain_arch="arm-linux-androideabi-4.4.3"
55 ;;
56 *x86*)
57 DEFINES=" target_arch=ia32 use_libffmpeg=0"
58 toolchain_arch="x86-4.4.3"
59 ;;
60 *)
61 echo "TARGET_PRODUCT: ${TARGET_PRODUCT} is not supported." >& 2
62 return 1
63esac
64
[email protected]e0825562012-05-10 01:50:4765# If we are building NDK/SDK, and in the upstream (open source) tree,
66# define a special variable for bringup purposes.
67case "${ANDROID_BUILD_TOP-undefined}" in
68 "undefined")
69 DEFINES+=" android_upstream_bringup=1"
70 ;;
71esac
72
[email protected]febd3572012-05-03 09:17:4573toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}/prebuilt/"
74export ANDROID_TOOLCHAIN="${toolchain_path}/${toolchain_dir}/bin/"
[email protected]ec5dcded2011-09-26 21:40:3875
[email protected]61fdbf22012-05-15 21:16:2076if [ ! -d "${ANDROID_TOOLCHAIN}" ]; then
77 echo "Can not find Android toolchain in ${ANDROID_TOOLCHAIN}." >& 2
78 echo "The NDK version might be wrong." >& 2
79 return 1
80fi
81
[email protected]6fa1e7ef2012-03-14 11:24:0482export ANDROID_SDK_VERSION="15"
83
[email protected]d9f96952012-04-19 21:02:0984# Needed by android antfiles when creating apks.
85export ANDROID_SDK_HOME=${ANDROID_SDK_ROOT}
86
87# Add Android SDK/NDK tools to system path.
88export PATH=$PATH:${ANDROID_NDK_ROOT}
89export PATH=$PATH:${ANDROID_SDK_ROOT}/tools
90export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools
[email protected]61fdbf22012-05-15 21:16:2091# Must have tools like arm-linux-androideabi-gcc on the path for ninja
92export PATH=$PATH:${ANDROID_TOOLCHAIN}
[email protected]ec5dcded2011-09-26 21:40:3893
94if [ -z "${CHROME_SRC}" ]; then
[email protected]4f0dd342012-02-14 00:41:5595 # If $CHROME_SRC was not set, assume current directory is CHROME_SRC.
96 export CHROME_SRC=$(readlink -f .)
[email protected]ec5dcded2011-09-26 21:40:3897fi
98
99if [ ! -d "${CHROME_SRC}" ]; then
100 echo "CHROME_SRC must be set to the path of Chrome source code." >& 2
101 return 1
102fi
103
[email protected]73919ea2012-04-26 00:48:41104# Add Chromium Android development scripts to system path.
105# Must be after CHROME_SRC is set.
106export PATH=$PATH:${CHROME_SRC}/build/android
107
[email protected]ec5dcded2011-09-26 21:40:38108# Performs a gyp_chromium run to convert gyp->Makefile for android code.
109android_gyp() {
[email protected]4aef1772012-05-24 22:43:23110 ANDROID_GOMA_WRAPPER=""
[email protected]d10e2cc2012-03-20 10:45:27111 if [[ -d $GOMA_DIR ]]; then
[email protected]4aef1772012-05-24 22:43:23112 ANDROID_GOMA_WRAPPER="$GOMA_DIR/gomacc"
[email protected]d10e2cc2012-03-20 10:45:27113 fi
114 # Ninja requires "*_target" for target builds.
[email protected]4aef1772012-05-24 22:43:23115 ANDROID_GOMA_WRAPPER=${ANDROID_GOMA_WRAPPER} \
[email protected]d10e2cc2012-03-20 10:45:27116 CC_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) \
117 CXX_target=$(basename ${ANDROID_TOOLCHAIN}/*-g++) \
118 LINK_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) \
119 AR_target=$(basename ${ANDROID_TOOLCHAIN}/*-ar) \
[email protected]c6c8cfee2012-05-07 22:33:19120 "${CHROME_SRC}/build/gyp_chromium" --depth="${CHROME_SRC}" "$@"
[email protected]ec5dcded2011-09-26 21:40:38121}
122
[email protected]d10e2cc2012-03-20 10:45:27123export OBJCOPY=$(echo ${ANDROID_TOOLCHAIN}/*-objcopy)
124export STRIP=$(echo ${ANDROID_TOOLCHAIN}/*-strip)
[email protected]ec5dcded2011-09-26 21:40:38125
126# The set of GYP_DEFINES to pass to gyp. Use 'readlink -e' on directories
127# to canonicalize them (remove double '/', remove trailing '/', etc).
[email protected]febd3572012-05-03 09:17:45128DEFINES+=" OS=android"
[email protected]ec5dcded2011-09-26 21:40:38129DEFINES+=" android_build_type=0" # Currently, Only '0' is supportted.
130DEFINES+=" host_os=${host_os}"
131DEFINES+=" linux_fpic=1"
132DEFINES+=" release_optimize=s"
133DEFINES+=" linux_use_tcmalloc=0"
134DEFINES+=" disable_nacl=1"
135DEFINES+=" remoting=0"
136DEFINES+=" p2p_apis=0"
137DEFINES+=" enable_touch_events=1"
[email protected]3b0836d42011-11-18 13:57:48138DEFINES+=" build_ffmpegsumo=0"
[email protected]ec5dcded2011-09-26 21:40:38139# TODO(bulach): use "shared_libraries" once the transition from executable
140# is over.
141DEFINES+=" gtest_target_type=executable"
142DEFINES+=" branding=Chromium"
143
[email protected]ec5dcded2011-09-26 21:40:38144export GYP_DEFINES="${DEFINES}"
145
146# Use the "android" flavor of the Makefile generator for both Linux and OS X.
147export GYP_GENERATORS="make-android"
148
[email protected]4b397aa2011-11-28 23:07:53149# Use our All target as the default
150export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All"
151
[email protected]ec5dcded2011-09-26 21:40:38152# We want to use our version of "all" targets.
153export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android.gyp"