OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2012 The Dart Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 # This file is designed to be "sourced" into an existing shell environment. |
| 6 # |
| 7 # Example: |
| 8 # |
| 9 # $ . envsetup.h <--- if running sh or bash |
| 10 # $ source envsetup.h <--- if running csh |
| 11 # |
| 12 # Sets up environment for building Dart on Android. Only Android NDK, |
| 13 # Revision 8b on Linux or Mac is offically supported. |
| 14 # |
| 15 # To run this script, the system environment ANDROID_NDK_ROOT must be set |
| 16 # to Android NDK's root path. |
| 17 # |
| 18 # If current path isn't Dart's root directory, DART_ROOT must be set |
| 19 # to Dart's root directory. |
| 20 |
| 21 if [ ! -d "${ANDROID_NDK_ROOT}" ]; then |
| 22 echo "ANDROID_NDK_ROOT must be set to the path of Android NDK, Revision 6b." \ |
| 23 >& 2 |
| 24 echo "which could be installed by" >& 2 |
| 25 echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2 |
| 26 return 1 |
| 27 fi |
| 28 |
| 29 if [ ! -d "${ANDROID_SDK_ROOT}" ]; then |
| 30 echo "ANDROID_SDK_ROOT must be set to the path of Android SDK, Android 3.2." \ |
| 31 >& 2 |
| 32 echo "which could be installed by" >& 2 |
| 33 echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2 |
| 34 return 1 |
| 35 fi |
| 36 |
| 37 host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/') |
| 38 |
| 39 case "${host_os}" in |
| 40 "linux") |
| 41 toolchain_dir="linux-x86" |
| 42 ;; |
| 43 "mac") |
| 44 toolchain_dir="darwin-x86" |
| 45 ;; |
| 46 *) |
| 47 echo "Host platform ${host_os} is not supported" >& 2 |
| 48 return 1 |
| 49 esac |
| 50 |
| 51 TARGET_PRODUCT="x86" |
| 52 |
| 53 # The following defines will affect ARM code generation of both C/C++ compiler |
| 54 # and V8 mksnapshot. |
| 55 case "${TARGET_PRODUCT-full}" in |
| 56 "full") |
| 57 DEFINES=" target_arch=arm" |
| 58 DEFINES+=" arm_neon=0 armv7=1 arm_thumb=1 arm_fpu=vfpv3-d16" |
| 59 toolchain_arch="arm-linux-androideabi-4.4.3" |
| 60 ;; |
| 61 *x86*) |
| 62 DEFINES=" target_arch=ia32 use_libffmpeg=0" |
| 63 toolchain_arch="x86-4.4.3" |
| 64 ;; |
| 65 *) |
| 66 echo "TARGET_PRODUCT: ${TARGET_PRODUCT} is not supported." >& 2 |
| 67 return 1 |
| 68 esac |
| 69 |
| 70 # If we are building NDK/SDK, and in the upstream (open source) tree, |
| 71 # define a special variable for bringup purposes. |
| 72 case "${ANDROID_BUILD_TOP-undefined}" in |
| 73 "undefined") |
| 74 DEFINES+=" android_upstream_bringup=1" |
| 75 ;; |
| 76 esac |
| 77 |
| 78 toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}/prebuilt/" |
| 79 export ANDROID_TOOLCHAIN="${toolchain_path}/${toolchain_dir}/bin/" |
| 80 |
| 81 if [ ! -d "${ANDROID_TOOLCHAIN}" ]; then |
| 82 echo "Can not find Android toolchain in ${ANDROID_TOOLCHAIN}." >& 2 |
| 83 echo "The NDK version might be wrong." >& 2 |
| 84 return 1 |
| 85 fi |
| 86 |
| 87 export ANDROID_SDK_VERSION="9" |
| 88 |
| 89 # Needed by android antfiles when creating apks. |
| 90 export ANDROID_SDK_HOME=${ANDROID_SDK_ROOT} |
| 91 |
| 92 # Add Android SDK/NDK tools to system path. |
| 93 export PATH=$PATH:${ANDROID_NDK_ROOT} |
| 94 export PATH=$PATH:${ANDROID_SDK_ROOT}/tools |
| 95 export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools |
| 96 # Must have tools like arm-linux-androideabi-gcc on the path for ninja |
| 97 export PATH=$PATH:${ANDROID_TOOLCHAIN} |
| 98 |
| 99 CURRENT_DIR="$(readlink -f ${PWD})" |
| 100 if [ -z "${DART_ROOT}" ]; then |
| 101 # If $DART_ROOT was not set, assume current directory is DART_ROOT. |
| 102 export DART_ROOT="${CURRENT_DIR}" |
| 103 fi |
| 104 |
| 105 if [ "${CURRENT_DIR/"${DART_ROOT}"/}" == "${CURRENT_DIR}" ]; then |
| 106 # If current directory is not in $DART_ROOT, it might be set for other |
| 107 # source tree. If $DART_ROOT was set correctly and we are in the correct |
| 108 # directory, "${CURRENT_DIR/"${DART_ROOT}"/}" will be "". |
| 109 # Otherwise, it will equal to "${CURRENT_DIR}" |
| 110 echo "Warning: Current directory is out of DART_ROOT, it may not be \ |
| 111 the one you want." |
| 112 echo "${DART_ROOT}" |
| 113 fi |
| 114 |
| 115 if [ ! -d "${DART_ROOT}" ]; then |
| 116 echo "DART_ROOT must be set to the path of Chrome source code." >& 2 |
| 117 return 1 |
| 118 fi |
| 119 |
| 120 # Add Dart Android development scripts to system path. |
| 121 # Must be after DART_ROOT is set. |
| 122 export PATH=$PATH:${DART_ROOT}/tools/android |
| 123 |
| 124 ANDROID_GOMA_WRAPPER="" |
| 125 if [[ -d $GOMA_DIR ]]; then |
| 126 ANDROID_GOMA_WRAPPER="$GOMA_DIR/gomacc" |
| 127 fi |
| 128 export ANDROID_GOMA_WRAPPER |
| 129 |
| 130 export CC_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) |
| 131 export CXX_target=$(basename ${ANDROID_TOOLCHAIN}/*-g++) |
| 132 export LINK_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) |
| 133 export AR_target=$(basename ${ANDROID_TOOLCHAIN}/*-ar) |
| 134 |
| 135 # Performs a gyp_chromium run to convert gyp->Makefile for android code. |
| 136 # android_gyp() { |
| 137 # echo "GYP_GENERATORS set to '$GYP_GENERATORS'" |
| 138 # "${DART_ROOT}/tools/generate_projects.py" "$@" |
| 139 # } |
| 140 |
| 141 export OBJCOPY=$(echo ${ANDROID_TOOLCHAIN}/*-objcopy) |
| 142 export STRIP=$(echo ${ANDROID_TOOLCHAIN}/*-strip) |
| 143 |
| 144 # The set of GYP_DEFINES to pass to gyp. Use 'readlink -e' on directories |
| 145 # to canonicalize them (remove double '/', remove trailing '/', etc). |
| 146 DEFINES+=" OS=android" |
| 147 DEFINES+=" android_build_type=0" |
| 148 DEFINES+=" host_os=${host_os}" |
| 149 DEFINES+=" linux_fpic=1" |
| 150 DEFINES+=" release_optimize=s" |
| 151 DEFINES+=" linux_use_tcmalloc=0" |
| 152 DEFINES+=" disable_nacl=1" |
| 153 DEFINES+=" remoting=0" |
| 154 DEFINES+=" p2p_apis=0" |
| 155 DEFINES+=" enable_touch_events=1" |
| 156 DEFINES+=" build_ffmpegsumo=0" |
| 157 DEFINES+=" gtest_target_type=shared_library" |
| 158 DEFINES+=" branding=Chromium" |
| 159 DEFINES+=\ |
| 160 " android_sdk=${ANDROID_SDK_ROOT}/platforms/android-${ANDROID_SDK_VERSION}" |
| 161 DEFINES+=" android_sdk_tools=${ANDROID_SDK_ROOT}/platform-tools" |
| 162 |
| 163 export GYP_DEFINES="${DEFINES}" |
| 164 |
| 165 # Use the "android" flavor of the Makefile generator for both Linux and OS X. |
| 166 export GYP_GENERATORS="make-android" |
| 167 |
| 168 # Use our All target as the default |
| 169 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" |
| 170 |
| 171 # We want to use our version of "all" targets. |
| 172 # export CHROMIUM_GYP_FILE="${DART_ROOT}/build/all_android.gyp" |
OLD | NEW |