OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 # |
| 3 # ios_setup.sh: Sets environment variables used by other iOS scripts. |
| 4 |
| 5 # File system location where we mount the ios devices. |
| 6 IOS_MOUNT_POINT="/tmp/mnt_iosdevice" |
| 7 |
| 8 # Location on the ios device where all data are stored. This is |
| 9 # relative to the mount point. |
| 10 IOS_DOCS_DIR="Documents" |
| 11 |
| 12 # Temporary location to assemble the app into an .ipa package. |
| 13 IOS_PCKG_DIR="/tmp/ios_pckg" |
| 14 |
| 15 # Bundle id of the app that runs the tests. |
| 16 TEST_RUNNER_BUNDLE_ID="com.google.iOSShell" |
| 17 |
| 18 # Directory with the Skia source. |
| 19 SKIA_SRC_DIR=$(cd "${SCRIPT_DIR}/../../.."; pwd) |
| 20 |
| 21 # BuildTYPE is 'Debug' by default. |
| 22 BUILDTYPE="Debug" |
| 23 |
| 24 # Provisioning profile - this needs to be set up on the local machine. |
| 25 PROVISIONING_PROFILE="9e88090d-abed-4e89-b106-3eff3512d31f" |
| 26 |
| 27 # Code Signing identity - this needs to be set up on the local machine. |
| 28 CODE_SIGN_IDENTITY="iPhone Developer: Google Development (3F4Y5873JF)" |
| 29 |
| 30 IOS_BUNDLE_ID="com.google.iOSShell" |
| 31 |
| 32 IOS_RESULTS_DIR="results" |
| 33 |
| 34 if [[ $# -ge 1 ]]; then |
| 35 BUILDTYPE=$1 |
| 36 fi |
| 37 |
| 38 set -x |
| 39 |
| 40 ios_uninstall_app() { |
| 41 ideviceinstaller -U "$IOS_BUNDLE_ID" |
| 42 } |
| 43 |
| 44 ios_install_app() { |
| 45 rm -rf $IOS_PCKG_DIR |
| 46 mkdir -p $IOS_PCKG_DIR/Payload # this directory must be named 'Payload' |
| 47 cp -rf "${SKIA_SRC_DIR}/xcodebuild/${BUILDTYPE}-iphoneos/iOSShell.app" "${IOS_
PCKG_DIR}/Payload/" |
| 48 local RET_DIR=`pwd` |
| 49 cd $IOS_PCKG_DIR |
| 50 zip -r iOSShell.ipa Payload |
| 51 ideviceinstaller -i ./iOSShell.ipa |
| 52 cd $RET_DIR |
| 53 } |
| 54 |
| 55 ios_clear_docs() { |
| 56 ios_mount |
| 57 rm -rf "$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$IOS_RESOURCE_DIR" |
| 58 rm -rf "$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$IOS_RESULTS_DIR" |
| 59 ios_umount |
| 60 } |
| 61 |
| 62 # ios_mount: mounts the iOS device for reading or writing. |
| 63 ios_mount() { |
| 64 # If this is already mounted we return. |
| 65 if $(mount | grep --quiet "$IOS_MOUNT_POINT"); then |
| 66 echo "Device already mounted at: $IOS_MOUNT_POINT - Unmounting." |
| 67 ios_umount |
| 68 fi |
| 69 |
| 70 # Ensure there is a mount directory. |
| 71 if [[ ! -d "$IOS_MOUNT_POINT" ]]; then |
| 72 mkdir -p $IOS_MOUNT_POINT |
| 73 fi |
| 74 ifuse --container $TEST_RUNNER_BUNDLE_ID $IOS_MOUNT_POINT |
| 75 sleep 1 |
| 76 echo "Successfully mounted device." |
| 77 } |
| 78 |
| 79 # ios_umount: unmounts the ios device. |
| 80 ios_umount() { |
| 81 umount $IOS_MOUNT_POINT |
| 82 sleep 1 |
| 83 } |
| 84 |
| 85 # ios_restart: restarts the iOS device. |
| 86 ios_restart() { |
| 87 idevicediagnostics restart |
| 88 } |
| 89 |
| 90 # ios_pull(ios_src, host_dst): Copies the content of ios_src to host_dst. |
| 91 # The path is relative to the 'Documents' folder on the device. |
| 92 ios_pull() { |
| 93 # read input params |
| 94 local IOS_SRC="$1" |
| 95 local HOST_DST="$2" |
| 96 |
| 97 ios_mount |
| 98 cp -r $IOS_MOUNT_POINT/$IOS_DOCS_DIR/$IOS_SRC $HOST_DST |
| 99 ios_umount |
| 100 } |
| 101 |
| 102 # ios_push(host_src, ios_dst) |
| 103 ios_push() { |
| 104 # read input params |
| 105 local HOST_SRC="$1" |
| 106 local IOS_DST="$2" |
| 107 |
| 108 ios_mount |
| 109 cp -r $HOST_SRC "$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$IOS_DST" |
| 110 ios_umount |
| 111 } |
| 112 |
| 113 |
| 114 ios_path_exists() { |
| 115 local TARGET_PATH="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1" |
| 116 local RET=1 |
| 117 ios_mount |
| 118 if [[ -e $TARGET_PATH ]]; then |
| 119 RET=0 |
| 120 fi |
| 121 ios_umount |
| 122 return $RET |
| 123 } |
| 124 |
| 125 # ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST` |
| 126 # HOST_LS=`ls -ld $HOST_SRC` |
| 127 # if [ "${ANDROID_LS:0:1}" == "d" -a "${HOST_LS:0:1}" == "-" ]; |
| 128 # then |
| 129 # ANDROID_DST="${ANDROID_DST}/$(basename ${HOST_SRC})" |
| 130 # fi |
| 131 |
| 132 |
| 133 # ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST` |
| 134 # if [ "${ANDROID_LS:0:1}" == "-" ]; then |
| 135 # #get the MD5 for dst and src |
| 136 # ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5 $ANDROID_DST` |
| 137 # if [ $(uname) == "Darwin" ]; then |
| 138 # HOST_MD5=`md5 -q $HOST_SRC` |
| 139 # else |
| 140 # HOST_MD5=`md5sum $HOST_SRC` |
| 141 # fi |
| 142 |
| 143 # if [ "${ANDROID_MD5:0:32}" != "${HOST_MD5:0:32}" ]; then |
| 144 # echo -n "$ANDROID_DST " |
| 145 # $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST |
| 146 # fi |
| 147 # elif [ "${ANDROID_LS:0:1}" == "d" ]; then |
| 148 # for FILE_ITEM in `ls $HOST_SRC`; do |
| 149 # adb_push_if_needed "${HOST_SRC}/${FILE_ITEM}" "${ANDROID_DST}/${FILE_ITE
M}" |
| 150 # done |
| 151 # else |
| 152 # HOST_LS=`ls -ld $HOST_SRC` |
| 153 # if [ "${HOST_LS:0:1}" == "d" ]; then |
| 154 # $ADB $DEVICE_SERIAL shell mkdir -p $ANDROID_DST |
| 155 # adb_push_if_needed $HOST_SRC $ANDROID_DST |
| 156 # else |
| 157 # echo -n "$ANDROID_DST " |
| 158 # $ADB $DEVICE_SERIAL shell mkdir -p "$(dirname "$ANDROID_DST")" |
| 159 # $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST |
| 160 # fi |
| 161 # fi |
| 162 # } |
| 163 |
| 164 # setup_device "${DEVICE_ID}" |
OLD | NEW |