OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # android_setup.sh: Sets environment variables used by other Android scripts. | 3 # android_setup.sh: Sets environment variables used by other Android scripts. |
4 | 4 |
5 # Fail-fast if anything in the script fails. | 5 # Fail-fast if anything in the script fails. |
6 set -e | 6 set -e |
7 | 7 |
8 BUILDTYPE=${BUILDTYPE-Debug} | 8 BUILDTYPE=${BUILDTYPE-Debug} |
9 | 9 |
10 while (( "$#" )); do | 10 while (( "$#" )); do |
hal.canary
2014/04/09 14:37:00
if [[ "$1" == '--help' ]]; then
usage; exit
fi
djsollen
2014/04/09 14:40:25
since this is a common include statement do you su
| |
11 if [[ "$1" == "-d" ]]; then | 11 if [[ "$1" == "-d" ]]; then |
12 DEVICE_ID=$2 | 12 DEVICE_ID=$2 |
13 shift | 13 shift |
14 elif [[ "$1" == "-s" ]]; then | 14 elif [[ "$1" == "-s" ]]; then |
15 DEVICE_SERIAL="-s $2" | 15 DEVICE_SERIAL="-s $2" |
16 shift | 16 shift |
17 elif [[ "$1" == "-t" ]]; then | 17 elif [[ "$1" == "-t" ]]; then |
18 BUILDTYPE=$2 | 18 BUILDTYPE=$2 |
19 shift | 19 shift |
20 elif [[ "$1" == "--release" ]]; then | 20 elif [[ "$1" == "--release" ]]; then |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 THIRD_PARTY_EXTERNAL_DIR=${SCRIPT_DIR}/../third_party/externals | 57 THIRD_PARTY_EXTERNAL_DIR=${SCRIPT_DIR}/../third_party/externals |
58 if [ ! -d "$THIRD_PARTY_EXTERNAL_DIR" ]; then | 58 if [ ! -d "$THIRD_PARTY_EXTERNAL_DIR" ]; then |
59 echo "" | 59 echo "" |
60 echo "ERROR: Unable to find the required third_party dependencies needed to build." | 60 echo "ERROR: Unable to find the required third_party dependencies needed to build." |
61 echo " To fix this add the following line to your .gclient file an d run 'gclient sync'" | 61 echo " To fix this add the following line to your .gclient file an d run 'gclient sync'" |
62 echo " target_os = ['android']" | 62 echo " target_os = ['android']" |
63 echo "" | 63 echo "" |
64 exit 1; | 64 exit 1; |
65 fi | 65 fi |
66 | 66 |
67 # Helper function to determine and download the toolchain that we will be using. | |
68 setup_toolchain() { | |
69 API_LEVEL=14 | |
70 NDK_REV=${NDK_REV-8e} | |
71 ANDROID_ARCH=${ANDROID_ARCH-arm} | |
72 | |
73 TOOLCHAIN_DIR=${SCRIPT_DIR}/../toolchains | |
74 if [ $(uname) == "Darwin" ]; then | |
75 verbose "Using Mac toolchain." | |
76 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-mac_v$API_LEVEL | |
77 else | |
78 verbose "Using Linux toolchain." | |
79 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-linux_v$API_LEVEL | |
80 fi | |
81 exportVar ANDROID_TOOLCHAIN "${TOOLCHAIN_DIR}/${TOOLCHAIN_TYPE}/bin" | |
82 | |
83 # if the toolchain doesn't exist on your machine then we need to fetch it | |
84 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then | |
85 mkdir -p $TOOLCHAIN_DIR | |
86 # enter the toolchain directory then download, unpack, and remove the tarbal l | |
87 pushd $TOOLCHAIN_DIR | |
88 TARBALL=ndk-r$NDK_REV-v$API_LEVEL.tgz | |
89 | |
90 ${SCRIPT_DIR}/download_toolchains.py \ | |
91 http://chromium-skia-gm.commondatastorage.googleapis.com/android-toolcha ins/$TARBALL \ | |
92 $TOOLCHAIN_DIR/$TARBALL | |
93 tar -xzf $TARBALL $TOOLCHAIN_TYPE | |
94 rm $TARBALL | |
95 popd | |
96 fi | |
97 | |
98 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then | |
99 echo "ERROR: unable to download/setup the required toolchain (${TOOLCHAIN_TY PE})" | |
100 return 1; | |
101 fi | |
102 | |
103 verbose "Targeting NDK API $API_LEVEL for use on Android 4.0 (NDK Revision $ND K_REV) and above" | |
104 | |
105 GCC=$(command ls $ANDROID_TOOLCHAIN/*-gcc | head -n1) | |
106 if [ -z "$GCC" ]; then | |
107 echo "ERROR: Could not find Android cross-compiler in: $ANDROID_TOOLCHAIN" | |
108 return 1 | |
109 fi | |
110 | |
111 # Remove the '-gcc' at the end to get the full toolchain prefix | |
112 ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc} | |
113 | |
114 CCACHE=${ANDROID_MAKE_CCACHE-$(which ccache || true)} | |
115 | |
116 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" | |
117 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" | |
118 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" | |
119 | |
120 exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar" | |
121 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib" | |
122 exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy" | |
123 exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip" | |
124 | |
125 # Create symlinks for nm & readelf and add them to the path so that the ninja | |
126 # build uses them instead of attempting to use the one on the system. | |
127 # This is required to build using ninja on a Mac. | |
128 ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm | |
129 ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf | |
130 exportVar PATH $ANDROID_TOOLCHAIN:$PATH | |
131 } | |
132 | |
133 # Helper function to configure the GYP defines to the appropriate values | 67 # Helper function to configure the GYP defines to the appropriate values |
134 # based on the target device. | 68 # based on the target device. |
135 setup_device() { | 69 setup_device() { |
136 DEFINES="OS=android" | 70 DEFINES="OS=android" |
137 DEFINES="${DEFINES} host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/' )" | 71 DEFINES="${DEFINES} host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/' )" |
138 DEFINES="${DEFINES} skia_os=android" | 72 DEFINES="${DEFINES} skia_os=android" |
139 DEFINES="${DEFINES} android_base=$(absPath ${SCRIPT_DIR}/..)" | 73 DEFINES="${DEFINES} android_base=$(absPath ${SCRIPT_DIR}/..)" |
140 if [[ "$GYP_DEFINES" != *skia_shared_lib=* ]]; then | 74 if [[ "$GYP_DEFINES" != *skia_shared_lib=* ]]; then |
141 DEFINES="${DEFINES} skia_shared_lib=1" | 75 DEFINES="${DEFINES} skia_shared_lib=1" |
142 fi | 76 fi |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 ;; | 135 ;; |
202 *) | 136 *) |
203 echo "ERROR: unknown device $TARGET_DEVICE" | 137 echo "ERROR: unknown device $TARGET_DEVICE" |
204 exit 1 | 138 exit 1 |
205 ;; | 139 ;; |
206 esac | 140 esac |
207 | 141 |
208 verbose "The build is targeting the device: $TARGET_DEVICE" | 142 verbose "The build is targeting the device: $TARGET_DEVICE" |
209 exportVar DEVICE_ID $TARGET_DEVICE | 143 exportVar DEVICE_ID $TARGET_DEVICE |
210 | 144 |
211 setup_toolchain | 145 # setup the appropriate cross compiling toolchains |
146 source $SCRIPT_DIR/utils/setup_toolchain.sh | |
212 | 147 |
213 DEFINES="${DEFINES} android_toolchain=${TOOLCHAIN_TYPE}" | 148 DEFINES="${DEFINES} android_toolchain=${TOOLCHAIN_TYPE}" |
214 | 149 |
215 exportVar GYP_DEFINES "$DEFINES $GYP_DEFINES" | 150 exportVar GYP_DEFINES "$DEFINES $GYP_DEFINES" |
216 exportVar SKIA_OUT "out/config/android-${TARGET_DEVICE}" | 151 exportVar SKIA_OUT "out/config/android-${TARGET_DEVICE}" |
217 } | 152 } |
218 | 153 |
219 # adb_pull_if_needed(android_src, host_dst) | 154 # adb_pull_if_needed(android_src, host_dst) |
220 adb_pull_if_needed() { | 155 adb_pull_if_needed() { |
221 | 156 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 echo -n "$ANDROID_DST " | 218 echo -n "$ANDROID_DST " |
284 $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST | 219 $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST |
285 fi | 220 fi |
286 else | 221 else |
287 echo -n "$ANDROID_DST " | 222 echo -n "$ANDROID_DST " |
288 $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST | 223 $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST |
289 fi | 224 fi |
290 } | 225 } |
291 | 226 |
292 setup_device "${DEVICE_ID}" | 227 setup_device "${DEVICE_ID}" |
OLD | NEW |