| OLD | NEW |
| 1 function exportVar { | 1 function exportVar { |
| 2 NAME=$1 | 2 NAME=$1 |
| 3 VALUE=$2 | 3 VALUE=$2 |
| 4 echo export $NAME=\"$VALUE\" | 4 echo export $NAME=\"$VALUE\" |
| 5 export $NAME="$VALUE" | 5 export $NAME="$VALUE" |
| 6 } | 6 } |
| 7 | 7 |
| 8 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | 8 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 9 | 9 |
| 10 # A valid Android SDK installation is required to build the sample app. | 10 # A valid Android SDK installation is required to build the sample app. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 THIRD_PARTY_EXTERNAL_DIR=${SCRIPT_DIR}/../third_party/externals | 30 THIRD_PARTY_EXTERNAL_DIR=${SCRIPT_DIR}/../third_party/externals |
| 31 if [ ! -d "$THIRD_PARTY_EXTERNAL_DIR" ]; then | 31 if [ ! -d "$THIRD_PARTY_EXTERNAL_DIR" ]; then |
| 32 echo "" | 32 echo "" |
| 33 echo "ERROR: Unable to find the required third_party dependencies needed
to build." | 33 echo "ERROR: Unable to find the required third_party dependencies needed
to build." |
| 34 echo " To fix this add the following line to your .gclient file an
d run 'gclient sync'" | 34 echo " To fix this add the following line to your .gclient file an
d run 'gclient sync'" |
| 35 echo " target_os = ['android']" | 35 echo " target_os = ['android']" |
| 36 echo "" | 36 echo "" |
| 37 exit 1; | 37 exit 1; |
| 38 fi | 38 fi |
| 39 | 39 |
| 40 # determine the toolchain that we will be using | 40 # Helper function to determine and download the toolchain that we will be using. |
| 41 API_LEVEL=14 | 41 setup_toolchain() { |
| 42 | 42 API_LEVEL=14 |
| 43 if [[ -z "$NDK_REV" ]]; | 43 |
| 44 then | 44 if [[ -z "$NDK_REV" ]]; |
| 45 NDK_REV="8e" | 45 then |
| 46 fi | 46 NDK_REV="8e" |
| 47 | |
| 48 if [[ -z "$ANDROID_ARCH" ]]; | |
| 49 then | |
| 50 ANDROID_ARCH="arm" | |
| 51 fi | |
| 52 | |
| 53 TOOLCHAIN_DIR=${SCRIPT_DIR}/../toolchains | |
| 54 if [ $(uname) == "Linux" ]; then | |
| 55 echo "Using Linux toolchain." | |
| 56 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-linux_v$API_LEVEL | |
| 57 elif [ $(uname) == "Darwin" ]; then | |
| 58 echo "Using Mac toolchain." | |
| 59 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-mac_v$API_LEVEL | |
| 60 else | |
| 61 echo "Could not automatically determine toolchain! Defaulting to Linux." | |
| 62 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-linux_v$API_LEVEL | |
| 63 fi | |
| 64 exportVar ANDROID_TOOLCHAIN ${TOOLCHAIN_DIR}/${TOOLCHAIN_TYPE}/bin | |
| 65 | |
| 66 # if the toolchain doesn't exist on your machine then we need to fetch it | |
| 67 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then | |
| 68 # create the toolchain directory if needed | |
| 69 if [ ! -d "$TOOLCHAIN_DIR" ]; then | |
| 70 mkdir $TOOLCHAIN_DIR | |
| 71 fi | 47 fi |
| 72 # enter the toolchain directory then download, unpack, and remove the tarball | 48 |
| 73 pushd $TOOLCHAIN_DIR | 49 if [[ -z "$ANDROID_ARCH" ]]; |
| 74 TARBALL=ndk-r$NDK_REV-v$API_LEVEL.tgz | 50 then |
| 75 | 51 ANDROID_ARCH="arm" |
| 76 echo "Downloading $TARBALL ..." | |
| 77 ${SCRIPT_DIR}/download_toolchains.py http://chromium-skia-gm.commondatastorage
.googleapis.com/android-toolchains/$TARBALL $TOOLCHAIN_DIR/$TARBALL | |
| 78 if [[ "$?" != "0" ]]; then | |
| 79 echo "ERROR: Unable to download toolchain $TARBALL." | |
| 80 exit 1 | |
| 81 fi | 52 fi |
| 82 | 53 |
| 83 echo "Untarring $TOOLCHAIN_TYPE from $TARBALL." | 54 TOOLCHAIN_DIR=${SCRIPT_DIR}/../toolchains |
| 84 tar -xzf $TARBALL $TOOLCHAIN_TYPE | 55 if [ $(uname) == "Linux" ]; then |
| 85 echo "Removing $TARBALL" | 56 echo "Using Linux toolchain." |
| 86 rm $TARBALL | 57 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-linux_v$API_LEVEL |
| 87 popd | 58 elif [ $(uname) == "Darwin" ]; then |
| 88 fi | 59 echo "Using Mac toolchain." |
| 89 | 60 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-mac_v$API_LEVEL |
| 90 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then | 61 else |
| 91 echo "ERROR: unable to download/setup the required toolchain (${TOOLCHAIN_TYPE
})" | 62 echo "Could not automatically determine toolchain! Defaulting to Linux." |
| 92 return 1; | 63 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-linux_v$API_LEVEL |
| 93 fi | 64 fi |
| 94 | 65 exportVar ANDROID_TOOLCHAIN ${TOOLCHAIN_DIR}/${TOOLCHAIN_TYPE}/bin |
| 95 echo "The build is targeting NDK API level $API_LEVEL for use on Android 4.0 (ND
K Revision $NDK_REV) and above" | 66 |
| 96 | 67 # if the toolchain doesn't exist on your machine then we need to fetch it |
| 97 LS="/bin/ls" # Use directly to avoid any 'ls' alias that might be defined. | 68 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then |
| 98 GCC=$($LS $ANDROID_TOOLCHAIN/*-gcc | head -n1) | 69 # create the toolchain directory if needed |
| 99 if [ -z "$GCC" ]; then | 70 if [ ! -d "$TOOLCHAIN_DIR" ]; then |
| 100 echo "ERROR: Could not find Android cross-compiler in: $ANDROID_TOOLCHAIN" | 71 mkdir $TOOLCHAIN_DIR |
| 101 return 1 | 72 fi |
| 102 fi | 73 # enter the toolchain directory then download, unpack, and remove the tarbal
l |
| 103 | 74 pushd $TOOLCHAIN_DIR |
| 104 # Remove the '-gcc' at the end to get the full toolchain prefix | 75 TARBALL=ndk-r$NDK_REV-v$API_LEVEL.tgz |
| 105 ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc} | 76 |
| 106 | 77 echo "Downloading $TARBALL ..." |
| 107 exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar" | 78 ${SCRIPT_DIR}/download_toolchains.py http://chromium-skia-gm.commondatastora
ge.googleapis.com/android-toolchains/$TARBALL $TOOLCHAIN_DIR/$TARBALL |
| 108 if [[ -z "$ANDROID_MAKE_CCACHE" ]]; then | 79 if [[ "$?" != "0" ]]; then |
| 109 exportVar CC "$ANDROID_TOOLCHAIN_PREFIX-gcc" | 80 echo "ERROR: Unable to download toolchain $TARBALL." |
| 110 exportVar CXX "$ANDROID_TOOLCHAIN_PREFIX-g++" | 81 exit 1 |
| 111 exportVar LINK "$ANDROID_TOOLCHAIN_PREFIX-gcc" | 82 fi |
| 112 else | 83 |
| 113 exportVar CC "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" | 84 echo "Untarring $TOOLCHAIN_TYPE from $TARBALL." |
| 114 exportVar CXX "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" | 85 tar -xzf $TARBALL $TOOLCHAIN_TYPE |
| 115 exportVar LINK "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" | 86 echo "Removing $TARBALL" |
| 116 fi | 87 rm $TARBALL |
| 117 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib" | 88 popd |
| 118 exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy" | 89 fi |
| 119 exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip" | 90 |
| 120 | 91 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then |
| 121 # Use the "android" flavor of the Makefile generator for both Linux and OS X. | 92 echo "ERROR: unable to download/setup the required toolchain (${TOOLCHAIN_TY
PE})" |
| 122 exportVar GYP_GENERATORS "make-android" | 93 return 1; |
| 94 fi |
| 95 |
| 96 echo "The build is targeting NDK API level $API_LEVEL for use on Android 4.0 (
NDK Revision $NDK_REV) and above" |
| 97 |
| 98 LS="/bin/ls" # Use directly to avoid any 'ls' alias that might be defined. |
| 99 GCC=$($LS $ANDROID_TOOLCHAIN/*-gcc | head -n1) |
| 100 if [ -z "$GCC" ]; then |
| 101 echo "ERROR: Could not find Android cross-compiler in: $ANDROID_TOOLCHAIN" |
| 102 return 1 |
| 103 fi |
| 104 |
| 105 # Remove the '-gcc' at the end to get the full toolchain prefix |
| 106 ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc} |
| 107 |
| 108 exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar" |
| 109 if [[ -z "$ANDROID_MAKE_CCACHE" ]]; then |
| 110 exportVar CC "$ANDROID_TOOLCHAIN_PREFIX-gcc" |
| 111 exportVar CXX "$ANDROID_TOOLCHAIN_PREFIX-g++" |
| 112 exportVar LINK "$ANDROID_TOOLCHAIN_PREFIX-gcc" |
| 113 else |
| 114 exportVar CC "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" |
| 115 exportVar CXX "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" |
| 116 exportVar LINK "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" |
| 117 fi |
| 118 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib" |
| 119 exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy" |
| 120 exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip" |
| 121 } |
| 123 | 122 |
| 124 # Helper function to configure the GYP defines to the appropriate values | 123 # Helper function to configure the GYP defines to the appropriate values |
| 125 # based on the target device. | 124 # based on the target device. |
| 126 setup_device() { | 125 setup_device() { |
| 127 DEFINES="OS=android" | 126 DEFINES="OS=android" |
| 128 DEFINES="${DEFINES} host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/'
)" | 127 DEFINES="${DEFINES} host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/'
)" |
| 129 DEFINES="${DEFINES} skia_os=android" | 128 DEFINES="${DEFINES} skia_os=android" |
| 130 DEFINES="${DEFINES} android_base=${SCRIPT_DIR}/.." | 129 DEFINES="${DEFINES} android_base=${SCRIPT_DIR}/.." |
| 131 DEFINES="${DEFINES} android_toolchain=${TOOLCHAIN_TYPE}" | |
| 132 DEFINES="${DEFINES} skia_shared_lib=1" | 130 DEFINES="${DEFINES} skia_shared_lib=1" |
| 133 | 131 |
| 134 # Setup the build variation depending on the target device | 132 # Setup the build variation depending on the target device |
| 135 TARGET_DEVICE="$1" | 133 TARGET_DEVICE="$1" |
| 136 | 134 |
| 137 if [ -z "$TARGET_DEVICE" ]; then | 135 if [ -z "$TARGET_DEVICE" ]; then |
| 138 echo "INFO: no target device type was specified so using the default 'arm_v7
'" | 136 echo "INFO: no target device type was specified so using the default 'arm_v7
'" |
| 139 TARGET_DEVICE="arm_v7" | 137 TARGET_DEVICE="arm_v7" |
| 140 fi | 138 fi |
| 141 | 139 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 ;; | 174 ;; |
| 177 *) | 175 *) |
| 178 echo -n "ERROR: unknown device specified ($TARGET_DEVICE), valid values: " | 176 echo -n "ERROR: unknown device specified ($TARGET_DEVICE), valid values: " |
| 179 echo "nexus_[s,4,7,10] xoom galaxy_nexus razr_i arm arm_thumb arm_v7 arm_v
7_thumb x86" | 177 echo "nexus_[s,4,7,10] xoom galaxy_nexus razr_i arm arm_thumb arm_v7 arm_v
7_thumb x86" |
| 180 return 1; | 178 return 1; |
| 181 ;; | 179 ;; |
| 182 esac | 180 esac |
| 183 | 181 |
| 184 echo "The build is targeting the device: $TARGET_DEVICE" | 182 echo "The build is targeting the device: $TARGET_DEVICE" |
| 185 | 183 |
| 184 # Set up the toolchain. |
| 185 setup_toolchain |
| 186 DEFINES="${DEFINES} android_toolchain=${TOOLCHAIN_TYPE}" |
| 187 |
| 188 # Use the "android" flavor of the Makefile generator for both Linux and OS X. |
| 189 exportVar GYP_GENERATORS "make-android" |
| 186 exportVar GYP_DEFINES "$DEFINES" | 190 exportVar GYP_DEFINES "$DEFINES" |
| 187 exportVar SKIA_OUT "out/config/android-${TARGET_DEVICE}" | 191 exportVar SKIA_OUT "out/config/android-${TARGET_DEVICE}" |
| 188 } | 192 } |
| 189 | 193 |
| 190 # adb_pull_if_needed(android_src, host_dst) | 194 # adb_pull_if_needed(android_src, host_dst) |
| 191 adb_pull_if_needed() { | 195 adb_pull_if_needed() { |
| 192 | 196 |
| 193 # get adb location | 197 # get adb location |
| 194 source $SCRIPT_DIR/utils/setup_adb.sh | 198 source $SCRIPT_DIR/utils/setup_adb.sh |
| 195 | 199 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 213 if [ "${ANDROID_MD5:0:32}" != "${HOST_MD5:0:32}" ]; | 217 if [ "${ANDROID_MD5:0:32}" != "${HOST_MD5:0:32}" ]; |
| 214 then | 218 then |
| 215 $ADB pull $ANDROID_SRC $HOST_DST | 219 $ADB pull $ANDROID_SRC $HOST_DST |
| 216 # else | 220 # else |
| 217 # echo "md5 match of android [$ANDROID_SRC] and host [$HOST_DST]" | 221 # echo "md5 match of android [$ANDROID_SRC] and host [$HOST_DST]" |
| 218 fi | 222 fi |
| 219 else | 223 else |
| 220 $ADB pull $ANDROID_SRC $HOST_DST | 224 $ADB pull $ANDROID_SRC $HOST_DST |
| 221 fi | 225 fi |
| 222 } | 226 } |
| OLD | NEW |