blob: 77faec8605cb4947d60f323f66974037c16c62ae [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
65toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}/prebuilt/"
66export ANDROID_TOOLCHAIN="${toolchain_path}/${toolchain_dir}/bin/"
[email protected]ec5dcded2011-09-26 21:40:3867
[email protected]6fa1e7ef2012-03-14 11:24:0468export ANDROID_SDK_VERSION="15"
69
[email protected]d9f96952012-04-19 21:02:0970# Needed by android antfiles when creating apks.
71export ANDROID_SDK_HOME=${ANDROID_SDK_ROOT}
72
73# Add Android SDK/NDK tools to system path.
74export PATH=$PATH:${ANDROID_NDK_ROOT}
75export PATH=$PATH:${ANDROID_SDK_ROOT}/tools
76export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools
[email protected]4e2e2e2a2011-10-25 16:12:2477
[email protected]ec5dcded2011-09-26 21:40:3878if [ ! -d "${ANDROID_TOOLCHAIN}" ]; then
79 echo "Can not find Android toolchain in ${ANDROID_TOOLCHAIN}." >& 2
80 echo "The NDK version might be wrong." >& 2
81 return 1
82fi
83
84if [ -z "${CHROME_SRC}" ]; then
[email protected]4f0dd342012-02-14 00:41:5585 # If $CHROME_SRC was not set, assume current directory is CHROME_SRC.
86 export CHROME_SRC=$(readlink -f .)
[email protected]ec5dcded2011-09-26 21:40:3887fi
88
89if [ ! -d "${CHROME_SRC}" ]; then
90 echo "CHROME_SRC must be set to the path of Chrome source code." >& 2
91 return 1
92fi
93
[email protected]73919ea2012-04-26 00:48:4194# Add Chromium Android development scripts to system path.
95# Must be after CHROME_SRC is set.
96export PATH=$PATH:${CHROME_SRC}/build/android
97
[email protected]ec5dcded2011-09-26 21:40:3898# Performs a gyp_chromium run to convert gyp->Makefile for android code.
99android_gyp() {
[email protected]d10e2cc2012-03-20 10:45:27100 GOMA_WRAPPER=""
101 if [[ -d $GOMA_DIR ]]; then
102 GOMA_WRAPPER="$GOMA_DIR/gomacc"
103 fi
104 # Ninja requires "*_target" for target builds.
105 GOMA_WRAPPER=${GOMA_WRAPPER} \
106 CC_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) \
107 CXX_target=$(basename ${ANDROID_TOOLCHAIN}/*-g++) \
108 LINK_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) \
109 AR_target=$(basename ${ANDROID_TOOLCHAIN}/*-ar) \
[email protected]ec5dcded2011-09-26 21:40:38110 "${CHROME_SRC}/build/gyp_chromium" --depth="${CHROME_SRC}"
111}
112
[email protected]d10e2cc2012-03-20 10:45:27113export OBJCOPY=$(echo ${ANDROID_TOOLCHAIN}/*-objcopy)
114export STRIP=$(echo ${ANDROID_TOOLCHAIN}/*-strip)
[email protected]ec5dcded2011-09-26 21:40:38115
116# The set of GYP_DEFINES to pass to gyp. Use 'readlink -e' on directories
117# to canonicalize them (remove double '/', remove trailing '/', etc).
[email protected]febd3572012-05-03 09:17:45118DEFINES+=" OS=android"
[email protected]ec5dcded2011-09-26 21:40:38119DEFINES+=" android_build_type=0" # Currently, Only '0' is supportted.
120DEFINES+=" host_os=${host_os}"
121DEFINES+=" linux_fpic=1"
122DEFINES+=" release_optimize=s"
123DEFINES+=" linux_use_tcmalloc=0"
124DEFINES+=" disable_nacl=1"
125DEFINES+=" remoting=0"
126DEFINES+=" p2p_apis=0"
127DEFINES+=" enable_touch_events=1"
[email protected]3b0836d42011-11-18 13:57:48128DEFINES+=" build_ffmpegsumo=0"
[email protected]ec5dcded2011-09-26 21:40:38129# TODO(bulach): use "shared_libraries" once the transition from executable
130# is over.
131DEFINES+=" gtest_target_type=executable"
132DEFINES+=" branding=Chromium"
133
[email protected]ec5dcded2011-09-26 21:40:38134export GYP_DEFINES="${DEFINES}"
135
136# Use the "android" flavor of the Makefile generator for both Linux and OS X.
137export GYP_GENERATORS="make-android"
138
[email protected]4b397aa2011-11-28 23:07:53139# Use our All target as the default
140export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All"
141
[email protected]ec5dcded2011-09-26 21:40:38142# We want to use our version of "all" targets.
143export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android.gyp"