2015-04-21 15:31:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
###############################################################################
|
|
|
|
# Copyright 2015 Google Inc.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# ios_setup.sh: Sets environment variables used by other iOS scripts.
|
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
# File system location where we mount the ios devices.
|
2017-04-25 15:38:38 +00:00
|
|
|
if [[ -z "${IOS_MOUNT_POINT}" ]]; then
|
|
|
|
IOS_MOUNT_POINT="/tmp/mnt_iosdevice"
|
|
|
|
fi
|
2015-04-21 15:31:59 +00:00
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
# Location on the ios device where all data are stored. This is
|
|
|
|
# relative to the mount point.
|
2015-04-21 15:31:59 +00:00
|
|
|
IOS_DOCS_DIR="Documents"
|
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
# Directory with the Skia source.
|
2015-04-21 15:31:59 +00:00
|
|
|
SKIA_SRC_DIR=$(cd "${SCRIPT_DIR}/../../.."; pwd)
|
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
# Provisioning profile - this needs to be set up on the local machine.
|
2015-10-15 20:20:34 +00:00
|
|
|
PROVISIONING_PROFILE=""
|
2015-04-21 15:31:59 +00:00
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
# Code Signing identity - this needs to be set up on the local machine.
|
2015-10-15 20:20:34 +00:00
|
|
|
CODE_SIGN_IDENTITY="iPhone Developer"
|
2015-04-21 15:31:59 +00:00
|
|
|
|
|
|
|
IOS_RESULTS_DIR="results"
|
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
# BUILDTYPE is 'Debug' by default.
|
|
|
|
if [[ -z "$BUILDTYPE" ]]; then
|
|
|
|
BUILDTYPE="Debug"
|
2015-04-21 15:31:59 +00:00
|
|
|
fi
|
|
|
|
|
2017-02-03 18:31:05 +00:00
|
|
|
# Out dir is $SKIA_SRC_DIR/out by default.
|
|
|
|
if [[ -z "$SKIA_OUT" ]]; then
|
2015-05-22 17:55:32 +00:00
|
|
|
SKIA_OUT="$SKIA_SRC_DIR/out"
|
2017-02-03 18:31:05 +00:00
|
|
|
fi
|
2015-05-22 17:55:32 +00:00
|
|
|
|
2016-04-12 13:21:47 +00:00
|
|
|
# Location of XCode build products.
|
|
|
|
if [[ -z "$XCODEBUILD" ]]; then
|
|
|
|
XCODEBUILD="${SKIA_SRC_DIR}/xcodebuild"
|
|
|
|
fi
|
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
ios_rm() {
|
2015-04-21 15:31:59 +00:00
|
|
|
local TARGET="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1"
|
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
ios_mount
|
2015-04-21 15:31:59 +00:00
|
|
|
rm -rf "$TARGET"
|
2015-05-05 14:55:06 +00:00
|
|
|
ios_umount
|
2015-04-21 15:31:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ios_mkdir() {
|
|
|
|
local TARGET="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1"
|
|
|
|
ios_mount
|
|
|
|
mkdir -p "$TARGET"
|
|
|
|
ios_umount
|
|
|
|
}
|
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
ios_cat() {
|
|
|
|
local TARGET="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1"
|
2017-04-25 15:38:38 +00:00
|
|
|
>&2 echo "target: '${TARGET}''"
|
2015-05-05 14:55:06 +00:00
|
|
|
ios_mount
|
2017-04-25 15:38:38 +00:00
|
|
|
RET="$( cat ${TARGET} )"
|
2015-05-05 14:55:06 +00:00
|
|
|
ios_umount
|
2017-04-25 15:38:38 +00:00
|
|
|
>&2 echo "Result: '${RET}'"
|
|
|
|
echo -e "${RET}"
|
2015-05-05 14:55:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# ios_mount: mounts the iOS device for reading or writing.
|
2015-04-21 15:31:59 +00:00
|
|
|
ios_mount() {
|
2015-05-05 14:55:06 +00:00
|
|
|
# If this is already mounted we unmount it.
|
|
|
|
if $(mount | grep --quiet "$IOS_MOUNT_POINT"); then
|
|
|
|
>&2 echo "Device already mounted at: $IOS_MOUNT_POINT - Unmounting."
|
2017-02-03 18:31:05 +00:00
|
|
|
ios_umount || true
|
2015-04-21 15:31:59 +00:00
|
|
|
fi
|
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
# Ensure there is a mount directory.
|
|
|
|
if [[ ! -d "$IOS_MOUNT_POINT" ]]; then
|
2015-04-21 15:31:59 +00:00
|
|
|
mkdir -p $IOS_MOUNT_POINT
|
2015-05-05 14:55:06 +00:00
|
|
|
fi
|
2015-12-02 17:45:30 +00:00
|
|
|
ifuse --container $IOS_BUNDLE_ID $IOS_MOUNT_POINT
|
2017-04-25 15:38:38 +00:00
|
|
|
|
|
|
|
sleep 2
|
|
|
|
if [[ ! -d "${IOS_MOUNT_POINT}/${IOS_DOCS_DIR}" ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-05-05 14:55:06 +00:00
|
|
|
>&2 echo "Successfully mounted device."
|
2017-02-03 18:31:05 +00:00
|
|
|
#find $IOS_MOUNT_POINT
|
2015-04-21 15:31:59 +00:00
|
|
|
}
|
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
# ios_umount: unmounts the ios device.
|
2015-04-21 15:31:59 +00:00
|
|
|
ios_umount() {
|
2017-04-25 15:38:38 +00:00
|
|
|
sudo umount $IOS_MOUNT_POINT
|
2015-04-21 15:31:59 +00:00
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
# ios_restart: restarts the iOS device.
|
2015-04-21 15:31:59 +00:00
|
|
|
ios_restart() {
|
2017-02-03 18:31:05 +00:00
|
|
|
ios_umount || true
|
2015-04-21 15:31:59 +00:00
|
|
|
idevicediagnostics restart
|
|
|
|
}
|
|
|
|
|
2015-05-05 14:55:06 +00:00
|
|
|
# ios_pull(ios_src, host_dst): Copies the content of ios_src to host_dst.
|
|
|
|
# The path is relative to the 'Documents' folder on the device.
|
2015-04-21 15:31:59 +00:00
|
|
|
ios_pull() {
|
|
|
|
# read input params
|
2015-05-05 14:55:06 +00:00
|
|
|
local IOS_SRC="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1"
|
2015-04-21 15:31:59 +00:00
|
|
|
local HOST_DST="$2"
|
|
|
|
|
|
|
|
ios_mount
|
2015-05-05 14:55:06 +00:00
|
|
|
if [[ -d "${HOST_DST}" ]]; then
|
2017-04-25 15:38:38 +00:00
|
|
|
cp -r "$IOS_SRC/." "$HOST_DST"
|
2015-05-05 14:55:06 +00:00
|
|
|
else
|
|
|
|
cp -r "$IOS_SRC" "$HOST_DST"
|
|
|
|
fi
|
2015-04-21 15:31:59 +00:00
|
|
|
ios_umount
|
|
|
|
}
|
|
|
|
|
|
|
|
# ios_push(host_src, ios_dst)
|
|
|
|
ios_push() {
|
|
|
|
# read input params
|
|
|
|
local HOST_SRC="$1"
|
|
|
|
local IOS_DST="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$2"
|
2015-05-05 14:55:06 +00:00
|
|
|
|
2015-04-21 15:31:59 +00:00
|
|
|
ios_mount
|
2015-05-05 14:55:06 +00:00
|
|
|
rm -rf $IOS_DST
|
2015-04-21 15:31:59 +00:00
|
|
|
mkdir -p "$(dirname $IOS_DST)"
|
2017-04-25 15:38:38 +00:00
|
|
|
cp -r -L "$HOST_SRC" "$IOS_DST"
|
2015-04-21 15:31:59 +00:00
|
|
|
ios_umount
|
|
|
|
}
|
|
|
|
|
|
|
|
ios_path_exists() {
|
|
|
|
local TARGET_PATH="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1"
|
2015-05-05 14:55:06 +00:00
|
|
|
local RET=1
|
2015-04-21 15:31:59 +00:00
|
|
|
ios_mount
|
2015-05-05 14:55:06 +00:00
|
|
|
if [[ -e $TARGET_PATH ]]; then
|
2015-04-21 15:31:59 +00:00
|
|
|
RET=0
|
2015-05-05 14:55:06 +00:00
|
|
|
fi
|
2015-04-21 15:31:59 +00:00
|
|
|
ios_umount
|
|
|
|
return $RET
|
|
|
|
}
|
|
|
|
|
|
|
|
# ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST`
|
|
|
|
# HOST_LS=`ls -ld $HOST_SRC`
|
|
|
|
# if [ "${ANDROID_LS:0:1}" == "d" -a "${HOST_LS:0:1}" == "-" ];
|
|
|
|
# then
|
|
|
|
# ANDROID_DST="${ANDROID_DST}/$(basename ${HOST_SRC})"
|
|
|
|
# fi
|
|
|
|
|
|
|
|
|
|
|
|
# ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST`
|
|
|
|
# if [ "${ANDROID_LS:0:1}" == "-" ]; then
|
|
|
|
# #get the MD5 for dst and src
|
|
|
|
# ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5 $ANDROID_DST`
|
|
|
|
# if [ $(uname) == "Darwin" ]; then
|
|
|
|
# HOST_MD5=`md5 -q $HOST_SRC`
|
|
|
|
# else
|
|
|
|
# HOST_MD5=`md5sum $HOST_SRC`
|
|
|
|
# fi
|
|
|
|
|
|
|
|
# if [ "${ANDROID_MD5:0:32}" != "${HOST_MD5:0:32}" ]; then
|
|
|
|
# echo -n "$ANDROID_DST "
|
|
|
|
# $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST
|
|
|
|
# fi
|
|
|
|
# elif [ "${ANDROID_LS:0:1}" == "d" ]; then
|
|
|
|
# for FILE_ITEM in `ls $HOST_SRC`; do
|
|
|
|
# adb_push_if_needed "${HOST_SRC}/${FILE_ITEM}" "${ANDROID_DST}/${FILE_ITEM}"
|
|
|
|
# done
|
|
|
|
# else
|
|
|
|
# HOST_LS=`ls -ld $HOST_SRC`
|
|
|
|
# if [ "${HOST_LS:0:1}" == "d" ]; then
|
|
|
|
# $ADB $DEVICE_SERIAL shell mkdir -p $ANDROID_DST
|
|
|
|
# adb_push_if_needed $HOST_SRC $ANDROID_DST
|
|
|
|
# else
|
|
|
|
# echo -n "$ANDROID_DST "
|
|
|
|
# $ADB $DEVICE_SERIAL shell mkdir -p "$(dirname "$ANDROID_DST")"
|
|
|
|
# $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST
|
|
|
|
# fi
|
|
|
|
# fi
|
|
|
|
# }
|
|
|
|
|
|
|
|
# setup_device "${DEVICE_ID}"
|