From deee2980f41cb9586bb7a596cf99d25775f7c698 Mon Sep 17 00:00:00 2001 From: stephana Date: Tue, 5 May 2015 07:55:06 -0700 Subject: cleanup BUG=skia: Review URL: https://codereview.chromium.org/1085583006 --- platform_tools/ios/bin/ios_cat_file | 21 ++++++++ platform_tools/ios/bin/ios_install | 18 +++++++ platform_tools/ios/bin/ios_mkdir | 2 + platform_tools/ios/bin/ios_mount | 18 +++++++ platform_tools/ios/bin/ios_mount.sh | 14 ----- platform_tools/ios/bin/ios_ninja | 10 ++-- platform_tools/ios/bin/ios_path_exists | 11 ++-- platform_tools/ios/bin/ios_pull.sh | 16 ------ platform_tools/ios/bin/ios_pull_if_needed | 10 ++-- platform_tools/ios/bin/ios_push_file | 7 +-- platform_tools/ios/bin/ios_push_if_needed | 7 +++ platform_tools/ios/bin/ios_rm | 17 ++++++ platform_tools/ios/bin/ios_rmdir | 12 ----- platform_tools/ios/bin/ios_run_skia | 18 +++---- platform_tools/ios/bin/ios_setup.sh | 86 +++++++++++++++++-------------- platform_tools/ios/bin/ios_umount | 17 ++++++ platform_tools/ios/bin/ios_umount.sh | 15 ------ 17 files changed, 176 insertions(+), 123 deletions(-) create mode 100755 platform_tools/ios/bin/ios_cat_file create mode 100755 platform_tools/ios/bin/ios_install create mode 100755 platform_tools/ios/bin/ios_mount delete mode 100755 platform_tools/ios/bin/ios_mount.sh delete mode 100755 platform_tools/ios/bin/ios_pull.sh create mode 100755 platform_tools/ios/bin/ios_rm delete mode 100755 platform_tools/ios/bin/ios_rmdir create mode 100755 platform_tools/ios/bin/ios_umount delete mode 100755 platform_tools/ios/bin/ios_umount.sh (limited to 'platform_tools') diff --git a/platform_tools/ios/bin/ios_cat_file b/platform_tools/ios/bin/ios_cat_file new file mode 100755 index 0000000000..2e712ca961 --- /dev/null +++ b/platform_tools/ios/bin/ios_cat_file @@ -0,0 +1,21 @@ +#!/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. +############################################################################### +# +# Writes the content of the file identified by the first argument to standard +# output. The path is relative to the Documents directory of the installed app. +# + +# Do not set -x here, since we only want the content of the file sent to +# standard out. +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $SCRIPT_DIR/ios_setup.sh + +ios_cat $1 diff --git a/platform_tools/ios/bin/ios_install b/platform_tools/ios/bin/ios_install new file mode 100755 index 0000000000..7dfe3b66de --- /dev/null +++ b/platform_tools/ios/bin/ios_install @@ -0,0 +1,18 @@ +#!/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. +############################################################################### +# +# Installs the app on the device. +# + +set -e -x + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $SCRIPT_DIR/ios_setup.sh + +ios_install_app diff --git a/platform_tools/ios/bin/ios_mkdir b/platform_tools/ios/bin/ios_mkdir index 713702b524..9bc50944d1 100755 --- a/platform_tools/ios/bin/ios_mkdir +++ b/platform_tools/ios/bin/ios_mkdir @@ -7,6 +7,8 @@ ############################################################################### # # Create a directory relative to the Documents directory. +# +set -e -x SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/ios_setup.sh diff --git a/platform_tools/ios/bin/ios_mount b/platform_tools/ios/bin/ios_mount new file mode 100755 index 0000000000..d71e32df0e --- /dev/null +++ b/platform_tools/ios/bin/ios_mount @@ -0,0 +1,18 @@ +#!/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. +############################################################################### +# +# Mounts the iOS device locally. See the value of IOS_MOUNT_POINT in +# ios_setup.sh for the exact location. +# +set -x -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $SCRIPT_DIR/ios_setup.sh + +ios_mount diff --git a/platform_tools/ios/bin/ios_mount.sh b/platform_tools/ios/bin/ios_mount.sh deleted file mode 100755 index 06d23e013f..0000000000 --- a/platform_tools/ios/bin/ios_mount.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/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. -############################################################################### -# -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/ios_setup.sh - -ios_install_app -ios_mount diff --git a/platform_tools/ios/bin/ios_ninja b/platform_tools/ios/bin/ios_ninja index 054f1084e9..55f30bb0f3 100755 --- a/platform_tools/ios/bin/ios_ninja +++ b/platform_tools/ios/bin/ios_ninja @@ -7,14 +7,16 @@ # found in the LICENSE file. ############################################################################### # -# Build the skia for ios. This assumes that GYP_DEFINES has been set. +# Build the skia for ios. This assumes that GYP_DEFINES has been set. # +set -x -e + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/ios_setup.sh -pushd -cd ${SKIA_SRC_DIR} +OLD_DIR=`pwd` +cd ${SKIA_SRC_DIR} "${SKIA_SRC_DIR}/gyp_skia" xcodebuild -project "$SKIA_SRC_DIR/out/gyp/iOSShell.xcodeproj"\ -configuration "$BUILDTYPE" -popd +cd $OLD_DIR diff --git a/platform_tools/ios/bin/ios_path_exists b/platform_tools/ios/bin/ios_path_exists index 06794eec3d..42a4f7ef5f 100755 --- a/platform_tools/ios/bin/ios_path_exists +++ b/platform_tools/ios/bin/ios_path_exists @@ -6,16 +6,19 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. ############################################################################### -# -# Check if ios path exists. # +# Check if ios path exists. +# + +set -x -e + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/ios_setup.sh -if [[ "$#" -ne "1" ]]; then +if [[ "$#" -ne "1" ]]; then echo "Usage: ios_path_exists " exit 1 fi RET=ios_path_exists $1 -exit $RET +exit $RET diff --git a/platform_tools/ios/bin/ios_pull.sh b/platform_tools/ios/bin/ios_pull.sh deleted file mode 100755 index 531fccfaaf..0000000000 --- a/platform_tools/ios/bin/ios_pull.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/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. -############################################################################### -# -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/ios_setup.sh - -TARGET_DIR=$1 - -ios_pull "*" "$TARGET_DIR" - diff --git a/platform_tools/ios/bin/ios_pull_if_needed b/platform_tools/ios/bin/ios_pull_if_needed index 46ad89437e..25edfd9732 100755 --- a/platform_tools/ios/bin/ios_pull_if_needed +++ b/platform_tools/ios/bin/ios_pull_if_needed @@ -7,12 +7,14 @@ # found in the LICENSE file. ############################################################################### # -# Pull the given file/directory off the device. +# Pull the given file/directory off the device. # +set -x -e + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/ios_setup.sh -HOST_PATH=$1 -DEVICE_PATH=$2 +DEVICE_PATH=$1 +HOST_PATH=$2 -ios_pull $HOST_PATH $DEVICE_PATH +ios_pull $DEVICE_PATH $HOST_PATH diff --git a/platform_tools/ios/bin/ios_push_file b/platform_tools/ios/bin/ios_push_file index 263b7c0a63..504f0ccb0a 100755 --- a/platform_tools/ios/bin/ios_push_file +++ b/platform_tools/ios/bin/ios_push_file @@ -5,9 +5,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. ############################################################################### - -# Fail-fast if anything in the script fails. -set -e +# +# Copies a single file from the host to the device. +# +set -x -e SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/ios_setup.sh diff --git a/platform_tools/ios/bin/ios_push_if_needed b/platform_tools/ios/bin/ios_push_if_needed index adb1afe34c..11b9dfa767 100755 --- a/platform_tools/ios/bin/ios_push_if_needed +++ b/platform_tools/ios/bin/ios_push_if_needed @@ -5,6 +5,13 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. ############################################################################### +# +# Copies the files identified by the first argument from the host to the target +# path on the device. The path on the devide is relative to the Documents +# directory. +# + +set -x -e SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/ios_setup.sh diff --git a/platform_tools/ios/bin/ios_rm b/platform_tools/ios/bin/ios_rm new file mode 100755 index 0000000000..1d606fcd89 --- /dev/null +++ b/platform_tools/ios/bin/ios_rm @@ -0,0 +1,17 @@ +#!/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. +############################################################################### +# +# Removes the path identified by the first argument from the directory. +# + +set -x -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $SCRIPT_DIR/ios_setup.sh + +ios_rm $1 diff --git a/platform_tools/ios/bin/ios_rmdir b/platform_tools/ios/bin/ios_rmdir deleted file mode 100755 index 127127341d..0000000000 --- a/platform_tools/ios/bin/ios_rmdir +++ /dev/null @@ -1,12 +0,0 @@ -#!/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. -############################################################################### - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/ios_setup.sh - -ios_rmdir $1 diff --git a/platform_tools/ios/bin/ios_run_skia b/platform_tools/ios/bin/ios_run_skia index bdeaece9d7..248593a66e 100755 --- a/platform_tools/ios/bin/ios_run_skia +++ b/platform_tools/ios/bin/ios_run_skia @@ -9,18 +9,12 @@ # ios_run_skia: starts the correct skia program on the device, prints the # output, and kills the app if interrupted. +set -x -e + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/ios_setup.sh -# (Re-)Install the app to create the necessary directories. -ios_uninstall_app -ios_install_app - -# Move the resources to the Documents forlder of the iOS device. -# Note: The iOSShell app expects 'resources' in the Documents folder. -ios_push "${SKIA_SRC_DIR}/resources" "" - -# Run the application. -ios-deploy -I -m -b "$SKIA_SRC_DIR/xcodebuild/${BUILDTYPE}-iphoneos/iOSShell.app --args '""$ARGS""'" - -#ios-deploy -I -m -b "$SKIA_SRC_DIR/xcodebuild/${BUILDTYPE}-iphoneos/iOSShell.app --args '""$ARGS""'-v --writePath results --dm --nogpu --threads 0 --src gm tests --config 8888 --match ~Threaded ~Math ~VarAlloc' +# Run the application. +IOS_DEPLOY_ARGS="${SKIA_SRC_DIR}/xcodebuild/${BUILDTYPE}-iphoneos/iOSShell.app --args \"${*}\"" +CMD="ios-deploy -I -m -b ${IOS_DEPLOY_ARGS}" +eval $CMD diff --git a/platform_tools/ios/bin/ios_setup.sh b/platform_tools/ios/bin/ios_setup.sh index 5df7ac00d2..7b42e21c52 100755 --- a/platform_tools/ios/bin/ios_setup.sh +++ b/platform_tools/ios/bin/ios_setup.sh @@ -8,47 +8,43 @@ # # ios_setup.sh: Sets environment variables used by other iOS scripts. -# File system location where we mount the ios devices. +# File system location where we mount the ios devices. IOS_MOUNT_POINT="/tmp/mnt_iosdevice" -# Location on the ios device where all data are stored. This is -# relative to the mount point. +# Location on the ios device where all data are stored. This is +# relative to the mount point. IOS_DOCS_DIR="Documents" -# Temporary location to assemble the app into an .ipa package. +# Temporary location to assemble the app into an .ipa package. IOS_PCKG_DIR="/tmp/ios_pckg" -# Bundle id of the app that runs the tests. +# Bundle id of the app that runs the tests. TEST_RUNNER_BUNDLE_ID="com.google.iOSShell" -# Directory with the Skia source. +# Directory with the Skia source. SKIA_SRC_DIR=$(cd "${SCRIPT_DIR}/../../.."; pwd) -# BuildTYPE is 'Debug' by default. -BUILDTYPE="Debug" - -# Provisioning profile - this needs to be set up on the local machine. +# Provisioning profile - this needs to be set up on the local machine. PROVISIONING_PROFILE="9e88090d-abed-4e89-b106-3eff3512d31f" -# Code Signing identity - this needs to be set up on the local machine. +# Code Signing identity - this needs to be set up on the local machine. CODE_SIGN_IDENTITY="iPhone Developer: Google Development (3F4Y5873JF)" IOS_BUNDLE_ID="com.google.iOSShell" IOS_RESULTS_DIR="results" -if [[ $# -ge 1 ]]; then - BUILDTYPE=$1 +# BUILDTYPE is 'Debug' by default. +if [[ -z "$BUILDTYPE" ]]; then + BUILDTYPE="Debug" fi -set -x - ios_uninstall_app() { ideviceinstaller -U "$IOS_BUNDLE_ID" } ios_install_app() { - rm -rf $IOS_PCKG_DIR + rm -rf $IOS_PCKG_DIR mkdir -p $IOS_PCKG_DIR/Payload # this directory must be named 'Payload' cp -rf "${SKIA_SRC_DIR}/xcodebuild/${BUILDTYPE}-iphoneos/iOSShell.app" "${IOS_PCKG_DIR}/Payload/" local RET_DIR=`pwd` @@ -58,12 +54,12 @@ ios_install_app() { cd $RET_DIR } -ios_rmdir() { +ios_rm() { local TARGET="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1" - ios_mount + ios_mount rm -rf "$TARGET" - ios_umount + ios_umount } ios_mkdir() { @@ -73,43 +69,55 @@ ios_mkdir() { ios_umount } -# ios_mount: mounts the iOS device for reading or writing. +ios_cat() { + local TARGET="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1" + ios_mount + RET="$(cat $TARGET)" + ios_umount + echo -e "$RET" +} + +# ios_mount: mounts the iOS device for reading or writing. ios_mount() { - # If this is already mounted we return. - if $(mount | grep --quiet "$IOS_MOUNT_POINT"); then - echo "Device already mounted at: $IOS_MOUNT_POINT - Unmounting." + # 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." ios_umount fi - # Ensure there is a mount directory. - if [[ ! -d "$IOS_MOUNT_POINT" ]]; then + # Ensure there is a mount directory. + if [[ ! -d "$IOS_MOUNT_POINT" ]]; then mkdir -p $IOS_MOUNT_POINT - fi + fi ifuse --container $TEST_RUNNER_BUNDLE_ID $IOS_MOUNT_POINT sleep 1 - echo "Successfully mounted device." + >&2 echo "Successfully mounted device." } -# ios_umount: unmounts the ios device. +# ios_umount: unmounts the ios device. ios_umount() { - umount $IOS_MOUNT_POINT + umount $IOS_MOUNT_POINT sleep 1 } -# ios_restart: restarts the iOS device. +# ios_restart: restarts the iOS device. ios_restart() { idevicediagnostics restart } -# 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. +# 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. ios_pull() { # read input params - local IOS_SRC="$1" + local IOS_SRC="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1" local HOST_DST="$2" ios_mount - cp -r $IOS_MOUNT_POINT/$IOS_DOCS_DIR/$IOS_SRC $HOST_DST + if [[ -d "${HOST_DST}" ]]; then + cp -r "$IOS_SRC/" "$HOST_DST" + else + cp -r "$IOS_SRC" "$HOST_DST" + fi ios_umount } @@ -118,9 +126,9 @@ ios_push() { # read input params local HOST_SRC="$1" local IOS_DST="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$2" - + ios_mount - rm -rf $IOS_DST + rm -rf $IOS_DST mkdir -p "$(dirname $IOS_DST)" cp -r "$HOST_SRC" "$IOS_DST" ios_umount @@ -128,11 +136,11 @@ ios_push() { ios_path_exists() { local TARGET_PATH="$IOS_MOUNT_POINT/$IOS_DOCS_DIR/$1" - local RET=1 + local RET=1 ios_mount - if [[ -e $TARGET_PATH ]]; then + if [[ -e $TARGET_PATH ]]; then RET=0 - fi + fi ios_umount return $RET } diff --git a/platform_tools/ios/bin/ios_umount b/platform_tools/ios/bin/ios_umount new file mode 100755 index 0000000000..ddc477c1fb --- /dev/null +++ b/platform_tools/ios/bin/ios_umount @@ -0,0 +1,17 @@ +#!/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. +############################################################################### +# +# Mount the ios device. +# +set -x -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $SCRIPT_DIR/ios_setup.sh + +ios_umount diff --git a/platform_tools/ios/bin/ios_umount.sh b/platform_tools/ios/bin/ios_umount.sh deleted file mode 100755 index 07598b073f..0000000000 --- a/platform_tools/ios/bin/ios_umount.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/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. -############################################################################### -# -# Mount the ios device. -# -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/ios_setup.sh - -ios_umount -- cgit v1.2.3