Chromium Code Reviews| Index: tools/android/envsetup.sh |
| diff --git a/tools/android/envsetup.sh b/tools/android/envsetup.sh |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..431c3feddbbec8f1d6ce4325bf465c7e0c649d64 |
| --- /dev/null |
| +++ b/tools/android/envsetup.sh |
| @@ -0,0 +1,168 @@ |
| + |
|
cshapiro
2012/08/07 22:39:40
Any reason why #!/bin/bash isn't the first line?
jackpal
2012/08/08 00:26:19
This script is designed to be _sourced_ only, rath
|
| + #!/bin/bash |
| + |
| +# Copyright (c) 2012 The Dart 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 Dart on Android. Only Android NDK, |
| +# Revision 8b 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. |
| +# |
| +# If current path isn't Dart's root directory, DART_ROOT must be set |
| +# to Dart's root 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 |
| + |
| +TARGET_PRODUCT="x86" |
| + |
| +# 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 |
| + |
| +# 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 |
| + |
| +toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}/prebuilt/" |
| +export ANDROID_TOOLCHAIN="${toolchain_path}/${toolchain_dir}/bin/" |
| + |
| +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 |
| + |
| +export ANDROID_SDK_VERSION="9" |
| + |
| +# 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 |
| +# Must have tools like arm-linux-androideabi-gcc on the path for ninja |
| +export PATH=$PATH:${ANDROID_TOOLCHAIN} |
| + |
| +CURRENT_DIR="$(readlink -f ${PWD})" |
| +if [ -z "${DART_ROOT}" ]; then |
| + # If $DART_ROOT was not set, assume current directory is DART_ROOT. |
| + export DART_ROOT="${CURRENT_DIR}" |
| +fi |
| + |
| +if [ "${CURRENT_DIR/"${DART_ROOT}"/}" == "${CURRENT_DIR}" ]; then |
| + # If current directory is not in $DART_ROOT, it might be set for other |
| + # source tree. If $DART_ROOT was set correctly and we are in the correct |
| + # directory, "${CURRENT_DIR/"${DART_ROOT}"/}" will be "". |
| + # Otherwise, it will equal to "${CURRENT_DIR}" |
| + echo "Warning: Current directory is out of DART_ROOT, it may not be \ |
| +the one you want." |
| + echo "${DART_ROOT}" |
| +fi |
| + |
| +if [ ! -d "${DART_ROOT}" ]; then |
| + echo "DART_ROOT must be set to the path of Chrome source code." >& 2 |
| + return 1 |
| +fi |
| + |
| +# Add Dart Android development scripts to system path. |
| +# Must be after DART_ROOT is set. |
| +export PATH=$PATH:${DART_ROOT}/tools/android |
| + |
| +ANDROID_GOMA_WRAPPER="" |
| +if [[ -d $GOMA_DIR ]]; then |
| + ANDROID_GOMA_WRAPPER="$GOMA_DIR/gomacc" |
| +fi |
| +export ANDROID_GOMA_WRAPPER |
| + |
| +export CC_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) |
| +export CXX_target=$(basename ${ANDROID_TOOLCHAIN}/*-g++) |
| +export LINK_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) |
| +export AR_target=$(basename ${ANDROID_TOOLCHAIN}/*-ar) |
| + |
| +# Performs a gyp_chromium run to convert gyp->Makefile for android code. |
| +# android_gyp() { |
| +# echo "GYP_GENERATORS set to '$GYP_GENERATORS'" |
| +# "${DART_ROOT}/tools/generate_projects.py" "$@" |
| +# } |
| + |
| +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" |
| +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" |
| +DEFINES+=" gtest_target_type=shared_library" |
| +DEFINES+=" branding=Chromium" |
| +DEFINES+=\ |
| +" android_sdk=${ANDROID_SDK_ROOT}/platforms/android-${ANDROID_SDK_VERSION}" |
| +DEFINES+=" android_sdk_tools=${ANDROID_SDK_ROOT}/platform-tools" |
| + |
| +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="${DART_ROOT}/build/all_android.gyp" |