2 ###############################################################################
3 # Copyright 2015 Google Inc.
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7 ###############################################################################
9 # ios_setup.sh: Sets environment variables used by other iOS scripts.
11 # File system location where we mount the ios devices.
12 if [[ -z "${IOS_MOUNT_POINT}" ]]; then
13 IOS_MOUNT_POINT="/tmp/mnt_iosdevice"
16 # Location on the ios device where all data are stored. This is
17 # relative to the mount point.
18 IOS_DOCS_DIR="Documents"
20 # Directory with the Skia source.
21 SKIA_SRC_DIR=$(cd "${SCRIPT_DIR}/../../.."; pwd)
23 # Provisioning profile - this needs to be set up on the local machine.
24 PROVISIONING_PROFILE=""
26 # Code Signing identity - this needs to be set up on the local machine.
27 CODE_SIGN_IDENTITY="iPhone Developer"
29 IOS_RESULTS_DIR="results"
31 # Location of XCode build products.
32 if [[ -z "$XCODEBUILD" ]]; then
33 XCODEBUILD="${SKIA_SRC_DIR}/xcodebuild"
37 local TARGET="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1"
45 local TARGET="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1"
52 local TARGET="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1"
53 >&2 echo "target: '${TARGET}''"
55 RET="$( cat ${TARGET} )"
57 >&2 echo "Result: '${RET}'"
61 # ios_mount: mounts the iOS device for reading or writing.
63 # If this is already mounted we unmount it.
64 if $(mount | grep --quiet "$IOS_MOUNT_POINT"); then
65 >&2 echo "Device already mounted at: $IOS_MOUNT_POINT - Unmounting."
69 # Ensure there is a mount directory.
70 if [[ ! -d "$IOS_MOUNT_POINT" ]]; then
71 mkdir -p $IOS_MOUNT_POINT
73 ifuse --container $IOS_BUNDLE_ID $IOS_MOUNT_POINT
76 if [[ ! -d "${IOS_MOUNT_POINT}/${IOS_DOCS_DIR}" ]]; then
79 >&2 echo "Successfully mounted device."
80 #find $IOS_MOUNT_POINT
83 # ios_umount: unmounts the ios device.
85 sudo umount $IOS_MOUNT_POINT
89 # ios_restart: restarts the iOS device.
92 idevicediagnostics restart
95 # ios_pull(ios_src, host_dst): Copies the content of ios_src to host_dst.
96 # The path is relative to the 'Documents' folder on the device.
99 local IOS_SRC="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1"
103 if [[ -d "${HOST_DST}" ]]; then
104 cp -r "$IOS_SRC/." "$HOST_DST"
106 cp -r "$IOS_SRC" "$HOST_DST"
111 # ios_push(host_src, ios_dst)
115 local IOS_DST="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$2"
119 mkdir -p "$(dirname $IOS_DST)"
120 cp -r -L "$HOST_SRC" "$IOS_DST"
125 local TARGET_PATH="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1"
128 if [[ -e $TARGET_PATH ]]; then
135 # ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST`
136 # HOST_LS=`ls -ld $HOST_SRC`
137 # if [ "${ANDROID_LS:0:1}" == "d" -a "${HOST_LS:0:1}" == "-" ];
139 # ANDROID_DST="${ANDROID_DST}/$(basename ${HOST_SRC})"
143 # ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST`
144 # if [ "${ANDROID_LS:0:1}" == "-" ]; then
145 # #get the MD5 for dst and src
146 # ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5 $ANDROID_DST`
147 # if [ $(uname) == "Darwin" ]; then
148 # HOST_MD5=`md5 -q $HOST_SRC`
150 # HOST_MD5=`md5sum $HOST_SRC`
153 # if [ "${ANDROID_MD5:0:32}" != "${HOST_MD5:0:32}" ]; then
154 # echo -n "$ANDROID_DST "
155 # $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST
157 # elif [ "${ANDROID_LS:0:1}" == "d" ]; then
158 # for FILE_ITEM in `ls $HOST_SRC`; do
159 # adb_push_if_needed "${HOST_SRC}/${FILE_ITEM}" "${ANDROID_DST}/${FILE_ITEM}"
162 # HOST_LS=`ls -ld $HOST_SRC`
163 # if [ "${HOST_LS:0:1}" == "d" ]; then
164 # $ADB $DEVICE_SERIAL shell mkdir -p $ANDROID_DST
165 # adb_push_if_needed $HOST_SRC $ANDROID_DST
167 # echo -n "$ANDROID_DST "
168 # $ADB $DEVICE_SERIAL shell mkdir -p "$(dirname "$ANDROID_DST")"
169 # $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST
174 # setup_device "${DEVICE_ID}"