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