2011-09-27 01:40:38 +04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2012-01-06 17:10:07 +04:00
|
|
|
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
2011-09-27 01:40:38 +04:00
|
|
|
# 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
|
2011-10-25 20:12:24 +04:00
|
|
|
echo "which could be installed by" >& 2
|
2012-03-07 06:22:18 +04:00
|
|
|
echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2
|
2011-10-25 20:12:24 +04:00
|
|
|
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
|
2012-03-07 06:22:18 +04:00
|
|
|
echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2
|
2011-09-27 01:40:38 +04:00
|
|
|
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
|
|
|
|
|
2012-05-03 13:17:45 +04:00
|
|
|
# The following defines will affect ARM code generation of both C/C++ compiler
|
|
|
|
# and V8 mksnapshot.
|
|
|
|
case "${TARGET_PRODUCT-full}" in
|
|
|
|
"full")
|
|
|
|
DEFINES=" target_arch=arm"
|
|
|
|
DEFINES+=" arm_neon=0 armv7=1 arm_thumb=1 arm_fpu=vfpv3-d16"
|
|
|
|
toolchain_arch="arm-linux-androideabi-4.4.3"
|
|
|
|
;;
|
|
|
|
*x86*)
|
|
|
|
DEFINES=" target_arch=ia32 use_libffmpeg=0"
|
|
|
|
toolchain_arch="x86-4.4.3"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "TARGET_PRODUCT: ${TARGET_PRODUCT} is not supported." >& 2
|
|
|
|
return 1
|
|
|
|
esac
|
|
|
|
|
2012-05-10 05:50:47 +04:00
|
|
|
# If we are building NDK/SDK, and in the upstream (open source) tree,
|
|
|
|
# define a special variable for bringup purposes.
|
|
|
|
case "${ANDROID_BUILD_TOP-undefined}" in
|
|
|
|
"undefined")
|
|
|
|
DEFINES+=" android_upstream_bringup=1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-05-03 13:17:45 +04:00
|
|
|
toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}/prebuilt/"
|
|
|
|
export ANDROID_TOOLCHAIN="${toolchain_path}/${toolchain_dir}/bin/"
|
2011-09-27 01:40:38 +04:00
|
|
|
|
2012-05-16 01:16:20 +04:00
|
|
|
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
|
|
|
|
|
2012-03-14 15:24:04 +04:00
|
|
|
export ANDROID_SDK_VERSION="15"
|
|
|
|
|
2012-04-20 01:02:09 +04:00
|
|
|
# Needed by android antfiles when creating apks.
|
|
|
|
export ANDROID_SDK_HOME=${ANDROID_SDK_ROOT}
|
|
|
|
|
|
|
|
# Add Android SDK/NDK tools to system path.
|
|
|
|
export PATH=$PATH:${ANDROID_NDK_ROOT}
|
|
|
|
export PATH=$PATH:${ANDROID_SDK_ROOT}/tools
|
|
|
|
export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools
|
2012-05-16 01:16:20 +04:00
|
|
|
# Must have tools like arm-linux-androideabi-gcc on the path for ninja
|
|
|
|
export PATH=$PATH:${ANDROID_TOOLCHAIN}
|
2011-09-27 01:40:38 +04:00
|
|
|
|
|
|
|
if [ -z "${CHROME_SRC}" ]; then
|
2012-02-14 04:41:55 +04:00
|
|
|
# If $CHROME_SRC was not set, assume current directory is CHROME_SRC.
|
|
|
|
export CHROME_SRC=$(readlink -f .)
|
2011-09-27 01:40:38 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "${CHROME_SRC}" ]; then
|
|
|
|
echo "CHROME_SRC must be set to the path of Chrome source code." >& 2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2012-04-26 04:48:41 +04:00
|
|
|
# Add Chromium Android development scripts to system path.
|
|
|
|
# Must be after CHROME_SRC is set.
|
|
|
|
export PATH=$PATH:${CHROME_SRC}/build/android
|
|
|
|
|
2011-09-27 01:40:38 +04:00
|
|
|
# Performs a gyp_chromium run to convert gyp->Makefile for android code.
|
|
|
|
android_gyp() {
|
2012-05-25 02:43:23 +04:00
|
|
|
ANDROID_GOMA_WRAPPER=""
|
2012-03-20 14:45:27 +04:00
|
|
|
if [[ -d $GOMA_DIR ]]; then
|
2012-05-25 02:43:23 +04:00
|
|
|
ANDROID_GOMA_WRAPPER="$GOMA_DIR/gomacc"
|
2012-03-20 14:45:27 +04:00
|
|
|
fi
|
|
|
|
# Ninja requires "*_target" for target builds.
|
2012-05-25 02:43:23 +04:00
|
|
|
ANDROID_GOMA_WRAPPER=${ANDROID_GOMA_WRAPPER} \
|
2012-03-20 14:45:27 +04:00
|
|
|
CC_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) \
|
|
|
|
CXX_target=$(basename ${ANDROID_TOOLCHAIN}/*-g++) \
|
|
|
|
LINK_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) \
|
|
|
|
AR_target=$(basename ${ANDROID_TOOLCHAIN}/*-ar) \
|
2012-05-08 02:33:19 +04:00
|
|
|
"${CHROME_SRC}/build/gyp_chromium" --depth="${CHROME_SRC}" "$@"
|
2011-09-27 01:40:38 +04:00
|
|
|
}
|
|
|
|
|
2012-03-20 14:45:27 +04:00
|
|
|
export OBJCOPY=$(echo ${ANDROID_TOOLCHAIN}/*-objcopy)
|
|
|
|
export STRIP=$(echo ${ANDROID_TOOLCHAIN}/*-strip)
|
2011-09-27 01:40:38 +04:00
|
|
|
|
|
|
|
# The set of GYP_DEFINES to pass to gyp. Use 'readlink -e' on directories
|
|
|
|
# to canonicalize them (remove double '/', remove trailing '/', etc).
|
2012-05-03 13:17:45 +04:00
|
|
|
DEFINES+=" OS=android"
|
2011-09-27 01:40:38 +04:00
|
|
|
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"
|
2011-11-18 17:57:48 +04:00
|
|
|
DEFINES+=" build_ffmpegsumo=0"
|
2011-09-27 01:40:38 +04:00
|
|
|
# TODO(bulach): use "shared_libraries" once the transition from executable
|
|
|
|
# is over.
|
|
|
|
DEFINES+=" gtest_target_type=executable"
|
|
|
|
DEFINES+=" branding=Chromium"
|
|
|
|
|
|
|
|
export GYP_DEFINES="${DEFINES}"
|
|
|
|
|
|
|
|
# Use the "android" flavor of the Makefile generator for both Linux and OS X.
|
|
|
|
export GYP_GENERATORS="make-android"
|
|
|
|
|
2011-11-29 03:07:53 +04:00
|
|
|
# Use our All target as the default
|
|
|
|
export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All"
|
|
|
|
|
2011-09-27 01:40:38 +04:00
|
|
|
# We want to use our version of "all" targets.
|
|
|
|
export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android.gyp"
|