aboutsummaryrefslogtreecommitdiffhomepage
path: root/platform_tools/android/bin
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-29 12:09:31 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-29 12:09:31 +0000
commitdcdd57faf02fb4fd23bb8265392b9c22e068907e (patch)
tree9fd7bfc2238672202dd72f29fd3b3c8c1c7fb776 /platform_tools/android/bin
parent48115de566aaa861b06371fc649899915174279f (diff)
Copy the top level Android directory into trunk.
This CL is the first step in a series needed to move the android directory into trunk. After the copy we will update GYP and DEPS to point to the new location and only then remove the original directory. git-svn-id: http://skia.googlecode.com/svn/trunk@8891 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'platform_tools/android/bin')
-rwxr-xr-xplatform_tools/android/bin/adb_list_devices.py153
-rwxr-xr-xplatform_tools/android/bin/android_gdb63
-rwxr-xr-xplatform_tools/android/bin/android_gdb_exe80
-rwxr-xr-xplatform_tools/android/bin/android_install_skia78
-rwxr-xr-xplatform_tools/android/bin/android_kill_skia16
-rwxr-xr-xplatform_tools/android/bin/android_make57
-rw-r--r--platform_tools/android/bin/android_perf145
-rwxr-xr-xplatform_tools/android/bin/android_run_skia48
-rwxr-xr-xplatform_tools/android/bin/android_setup.sh189
-rwxr-xr-xplatform_tools/android/bin/linux/adbbin0 -> 1226659 bytes
-rw-r--r--platform_tools/android/bin/linux/perfhostbin0 -> 2219858 bytes
-rwxr-xr-xplatform_tools/android/bin/mac/adbbin0 -> 1256228 bytes
-rwxr-xr-xplatform_tools/android/bin/mac/perfhostbin0 -> 639612 bytes
-rw-r--r--platform_tools/android/bin/utils/setup_adb.sh17
-rw-r--r--platform_tools/android/bin/utils/setup_skia_out.sh22
15 files changed, 868 insertions, 0 deletions
diff --git a/platform_tools/android/bin/adb_list_devices.py b/platform_tools/android/bin/adb_list_devices.py
new file mode 100755
index 0000000000..f140484f4b
--- /dev/null
+++ b/platform_tools/android/bin/adb_list_devices.py
@@ -0,0 +1,153 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+""" adb_list_devices: list information about attached Android devices. """
+
+
+import os
+import re
+import shlex
+import subprocess
+import sys
+
+# This file, which resides on every Android device, contains a great deal of
+# information about the device.
+INFO_FILE = '/system/build.prop'
+
+# Default set of properties to query about a device.
+DEFAULT_PROPS_TO_GET = ['ro.product.device', 'ro.build.version.release',
+ 'ro.build.type']
+
+
+def GetDeviceInfo(adb, serial, props_to_get):
+ """ Return a list of values (or "<Unknown>" if no value can be found) for the
+ given set of properties for the device with the given serial number.
+
+ adb: path to the ADB program.
+ serial: serial number of the target device.
+ props_to_get: list of strings indicating which properties to determine.
+ """
+ device_proc = subprocess.Popen([adb, '-s', serial, 'shell', 'cat',
+ INFO_FILE], stdout=subprocess.PIPE)
+ code = device_proc.wait()
+ if code != 0:
+ raise Exception('Could not query device with serial number %s.' % serial)
+ output = device_proc.stdout.read()
+ device_info = []
+ for prop in props_to_get:
+ # Find the property in the outputs
+ search_str = r'%s=(\S+)' % prop
+ match = re.search(search_str, output)
+ if not match:
+ value = '<Unknown>'
+ else:
+ value = match.group(1)
+ device_info.append(value)
+ return device_info
+
+
+def PrintPrettyTable(data, file=None):
+ """ Print out the given data in a nicely-spaced format. This function scans
+ the list multiple times and uses extra memory, so don't use it for big data
+ sets.
+
+ data: list of lists of strings, where each list represents a row of data.
+ This table is assumed to be rectangular; if the length of any list differs
+ some of the output may not get printed.
+ file: file-like object into which the table should be written. If none is
+ provided, the table is written to stdout.
+ """
+ if not file:
+ file = sys.stdout
+ column_widths = [0 for length in data[0]]
+ for line in data:
+ column_widths = [max(longest_len, len(prop)) for \
+ longest_len, prop in zip(column_widths, line)]
+ for line in data:
+ for prop, width in zip(line, column_widths):
+ file.write(prop.ljust(width + 1))
+ file.write('\n')
+
+
+def FindADB(hint=None):
+ """ Attempt to find the ADB program using the following sequence of steps.
+ Returns the path to ADB if it can be found, or None otherwise.
+ 1. If a hint was provided, is it a valid path to ADB?
+ 2. Is ADB in PATH?
+ 3. Is there an environment variable for ADB?
+ 4. If the ANDROID_SDK_ROOT variable is set, try to find ADB in the SDK
+ directory.
+
+ hint: string indicating a possible path to ADB.
+ """
+ # 1. If a hint was provided, does it point to ADB?
+ if hint:
+ if os.path.basename(hint) == 'adb':
+ adb = hint
+ else:
+ adb = os.path.join(hint, 'adb')
+ if subprocess.Popen([adb, 'version'], stdout=subprocess.PIPE).wait() == 0:
+ return adb
+
+ # 2. Is 'adb' in our PATH?
+ adb = 'adb'
+ if subprocess.Popen([adb, 'version'], stdout=subprocess.PIPE).wait() == 0:
+ return adb
+
+ # 3. Is there an environment variable for ADB?
+ try:
+ adb = os.environ.get('ADB')
+ if subprocess.Popen([adb, 'version'], stdout=subprocess.PIPE).wait() == 0:
+ return adb
+ except:
+ pass
+
+ # 4. If ANDROID_SDK_ROOT is set, try to find ADB in the SDK directory.
+ try:
+ sdk_dir = os.environ.get('ANDROID_SDK_ROOT')
+ adb = os.path.join(sdk_dir, 'platform-tools', 'adb')
+ if subprocess.Popen([adb, 'version'], stdout=subprocess.PIPE).wait() == 0:
+ return adb
+ except:
+ pass
+ return None
+
+
+def main(argv):
+ """ Print out information about connected Android devices. By default, print
+ the serial number, status, device name, OS version, and build type of each
+ device. If any arguments are supplied on the command line, print the serial
+ number and status for each device along with values for those arguments
+ interpreted as properties.
+ """
+ if len(argv) > 1:
+ props_to_get = argv[1:]
+ else:
+ props_to_get = DEFAULT_PROPS_TO_GET
+ adb = FindADB()
+ if not adb:
+ raise Exception('Could not find ADB!')
+ proc = subprocess.Popen([adb, 'devices'], stdout=subprocess.PIPE)
+ code = proc.wait()
+ if code != 0:
+ raise Exception('Failure in ADB: could not find attached devices.')
+ header = ['Serial', 'Status']
+ header.extend(props_to_get)
+ output_lines = [header]
+ for line in proc.stdout:
+ line = line.rstrip()
+ if line != 'List of devices attached' and line != '':
+ line_list = shlex.split(line)
+ serial = line_list[0]
+ status = line_list[1]
+ device_info = [serial, status]
+ device_info.extend(GetDeviceInfo(adb, serial, props_to_get))
+ output_lines.append(device_info)
+ PrintPrettyTable(output_lines)
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv)) \ No newline at end of file
diff --git a/platform_tools/android/bin/android_gdb b/platform_tools/android/bin/android_gdb
new file mode 100755
index 0000000000..58e0b177bd
--- /dev/null
+++ b/platform_tools/android/bin/android_gdb
@@ -0,0 +1,63 @@
+#!/bin/bash
+#
+# android_gdb: Pushes parameter binary and gdbserver. Connects
+# and enters debugging environment.
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+APP_NAME=$(basename $1)
+PORT=5039
+
+# Collect extra arguments to be passed to the Skia binary
+shift
+while (( "$#" )); do
+ APP_ARGS="$APP_ARGS $1"
+ shift
+done
+
+source $SCRIPT_DIR/android_setup.sh
+source $SCRIPT_DIR/utils/setup_adb.sh
+
+echo "Installing Skia Android app"
+$SCRIPT_DIR/android_install_skia -f
+
+# Forward local to remote socket connection.
+$ADB forward "tcp:$PORT" "tcp:$PORT"
+
+# We kill all previous instances of gdbserver to rid all port overriding errors.
+$ADB shell ps | grep gdbserver | awk '{print $2}' | xargs -r $ADB shell kill
+
+# We need the debug symbols from these files
+GDB_TMP_DIR=$(pwd)/android_gdb_tmp
+mkdir $GDB_TMP_DIR
+echo "Copying symbol files"
+$ADB pull /system/bin/app_process $GDB_TMP_DIR
+$ADB pull /system/lib/libc.so $GDB_TMP_DIR
+$ADB pull /data/data/com.skia/lib/lib$APP_NAME.so $GDB_TMP_DIR
+
+# Launch the app
+SK_COMMAND="$APP_NAME$APP_ARGS"
+echo "Running command $SK_COMMAND"
+$ADB shell am broadcast -a com.skia.intent.action.LAUNCH_SKIA -n com.skia/.SkiaReceiver -e args "$SK_COMMAND"
+
+# Attach gdbserver to the app process
+PID=$($ADB shell ps | grep skia_native | awk '{print $2}')
+echo "Attaching to pid: $PID"
+$ADB shell /data/data/com.skia/lib/gdbserver :$PORT --attach $PID &
+
+# Wait for gdbserver
+sleep 2
+
+# Set up gdb commands
+GDBSETUP=$GDB_TMP_DIR/gdb.setup
+echo "file $GDB_TMP_DIR/app_process" >> $GDBSETUP
+echo "target remote :$PORT" >> $GDBSETUP
+echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP
+echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP
+
+# Launch gdb client
+echo "Entering gdb client shell"
+$ANDROID_TOOLCHAIN/arm-linux-androideabi-gdb -x $GDBSETUP
+
+# Clean up
+rm -rf $GDB_TMP_DIR
+
diff --git a/platform_tools/android/bin/android_gdb_exe b/platform_tools/android/bin/android_gdb_exe
new file mode 100755
index 0000000000..21c739d25f
--- /dev/null
+++ b/platform_tools/android/bin/android_gdb_exe
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# android_gdb: Pushes gdbserver. Connects and enters debugging environment.
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+APP_NAME=$(basename $1)
+PORT=5039
+
+# Collect extra arguments to be passed to the Skia binary
+shift
+while (( "$#" )); do
+ APP_ARGS="$APP_ARGS $1"
+ shift
+done
+
+source $SCRIPT_DIR/android_setup.sh
+source $SCRIPT_DIR/utils/setup_adb.sh
+
+# We need the debug symbols from these files
+GDB_TMP_DIR=$(pwd)/android_gdb_tmp
+mkdir $GDB_TMP_DIR
+echo "Copying symbol files"
+$ADB pull /system/bin/skia_launcher $GDB_TMP_DIR
+$ADB pull /system/lib/libc.so $GDB_TMP_DIR
+$ADB pull /data/data/com.skia/lib/lib$APP_NAME.so $GDB_TMP_DIR
+
+echo "Checking for skia_launcher app..."
+if [ ! -f $GDB_TMP_DIR/skia_launcher ]
+then
+ echo "Unable for find the skia_launcher on the device"
+ rm -rf $GDB_TMP_DIR
+ exit 1;
+fi
+
+echo "Checking for $APP_NAME library..."
+if [ ! -f $GDB_TMP_DIR/lib$APP_NAME.so ]
+then
+ echo "Unable for find the app's shared library on the device"
+ rm -rf $GDB_TMP_DIR
+ exit 1;
+fi
+
+echo "Pushing gdbserver..."
+$ADB remount
+$ADB push $ANDROID_TOOLCHAIN/../gdbserver /system/bin/gdbserver
+
+echo "Setting up port forward"
+$ADB forward "tcp:5039" "tcp:5039"
+
+# Kill all previous instances of gdbserver and skia_launcher to rid all port overriding errors.
+echo "Killing any running Skia processes."
+$ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill
+$ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kill
+
+# Starting up gdbserver in android shell
+echo "Starting gdbserver with command: skia_launcher $APP_NAME$APP_ARGS"
+$ADB shell gdbserver :5039 /system/bin/skia_launcher $APP_NAME$APP_ARGS &
+
+# Wait for gdbserver
+sleep 2
+
+# Set up gdb commands
+GDBSETUP=$GDB_TMP_DIR/gdb.setup
+echo "file $GDB_TMP_DIR/skia_launcher" >> $GDBSETUP
+echo "target remote :$PORT" >> $GDBSETUP
+echo "set solib-absolute-prefix $GDB_TMP_DIR" >> $GDBSETUP
+echo "set solib-search-path $GDB_TMP_DIR" >> $GDBSETUP
+
+# The apps shared library symbols are not loaded by default so we load them here
+echo "break skia_launcher.cpp:launch_app" >> $GDBSETUP
+echo "continue" >> $GDBSETUP
+echo "sharedLibrary $APP_NAME" >> $GDBSETUP
+
+
+# Launch gdb client
+echo "Entering gdb client shell"
+$ANDROID_TOOLCHAIN/arm-linux-androideabi-gdb -x $GDBSETUP
+
+# Clean up
+rm -rf $GDB_TMP_DIR \ No newline at end of file
diff --git a/platform_tools/android/bin/android_install_skia b/platform_tools/android/bin/android_install_skia
new file mode 100755
index 0000000000..da16b1ab7a
--- /dev/null
+++ b/platform_tools/android/bin/android_install_skia
@@ -0,0 +1,78 @@
+#!/bin/bash
+#
+# android_install_skia: installs the skia apk on the device.
+
+function print_usage {
+ echo "USAGE: android_install_skia [options]"
+ echo " Options: -f Forces the package to be installed by removing any"
+ echo " previously installed packages"
+ echo " -h Prints this help message"
+ echo " --install-launcher Remounts the system partition and installs the"
+ echo " skia_launcher binary on the device"
+ echo " --release Install the release build of Skia"
+ echo " -s [device_s/n] Serial number of the device to be used"
+}
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+source $SCRIPT_DIR/utils/setup_adb.sh
+source $SCRIPT_DIR/utils/setup_skia_out.sh
+
+forceRemoval="false"
+installLauncher="false"
+installOptions="-r"
+configuration="Debug"
+serialNumber=""
+
+while (( "$#" )); do
+
+ if [[ "$1" == "-f" ]];
+ then
+ forceRemoval="true"
+ elif [[ "$1" == "-h" ]];
+ then
+ print_usage
+ exit
+ elif [[ "$1" == "--install-launcher" ]];
+ then
+ installLauncher="true"
+ elif [[ "$1" == "-r" ]];
+ then
+ echo "DEPRECATED: -r is now a no-op"
+ elif [[ "$1" == "--release" ]];
+ then
+ configuration="Release"
+ elif [[ "$1" == "-s" ]];
+ then
+ if [[ $# -lt 2 ]];
+ then
+ echo "ERROR: missing serial number"
+ exit 1;
+ fi
+ serialNumber="-s $2"
+ shift
+ else
+ echo "ERROR: unrecognized option $1"
+ print_usage
+ exit 1;
+ fi
+
+shift
+done
+
+if [[ "$forceRemoval" == "true" ]];
+then
+ echo "Forcing removal of previously installed packages"
+ $ADB ${serialNumber} uninstall com.skia > /dev/null
+fi
+
+if [[ "$installLauncher" == "true" ]];
+then
+ echo "Installing skia_launcher binary"
+ $ADB ${serialNumber} root
+ $ADB ${serialNumber} remount
+ $ADB ${serialNumber} push ${SKIA_OUT}/${configuration}/skia_launcher /system/bin
+fi
+
+echo "Installing Skia App from ${SKIA_OUT}/${configuration}"
+$ADB ${serialNumber} install ${installOptions} ${SKIA_OUT}/${configuration}/android/bin/SkiaAndroid.apk
diff --git a/platform_tools/android/bin/android_kill_skia b/platform_tools/android/bin/android_kill_skia
new file mode 100755
index 0000000000..5560efc746
--- /dev/null
+++ b/platform_tools/android/bin/android_kill_skia
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# android_kill_skia: kills any skia processes on the device.
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+source $SCRIPT_DIR/utils/setup_adb.sh
+
+if [ $(uname) == "Linux" ]; then
+ $ADB shell ps | grep skia | awk '{print $2}' | xargs -r $ADB shell kill
+elif [ $(uname) == "Darwin" ]; then
+ $ADB shell ps | grep skia | awk '{print $2}' | xargs $ADB shell kill
+else
+ echo "Could not automatically determine OS!"
+ exit 1;
+fi
diff --git a/platform_tools/android/bin/android_make b/platform_tools/android/bin/android_make
new file mode 100755
index 0000000000..497859d42d
--- /dev/null
+++ b/platform_tools/android/bin/android_make
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+makeVars=""
+deviceID=""
+
+while (( "$#" )); do
+
+ if [[ $(echo "$1" | grep "^-d$") != "" ]];
+ then
+ deviceID="$2"
+ shift
+ elif [[ "$1" == "--use-ccache" ]];
+ then
+ if [[ -z "$ANDROID_MAKE_CCACHE" ]];
+ then
+ ANDROID_MAKE_CCACHE=$(which ccache)
+ fi
+ else
+ makeVars="$makeVars $1"
+ fi
+
+shift
+done
+
+if [[ -n "$ANDROID_MAKE_CCACHE" ]]; then
+ $ANDROID_MAKE_CCACHE --version &> /dev/null
+ if [[ "$?" != "0" ]]; then
+ echo "Unable to find ccache!"
+ exit 1
+ fi
+fi
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+# hack for x86 support in android_setup.sh
+if [ "$deviceID" == "x86" ]
+then
+ ANDROID_ARCH="x86"
+fi
+
+source $SCRIPT_DIR/android_setup.sh
+
+setup_device $deviceID
+returnVal=$?
+if [ $returnVal != 0 ]
+then
+ exit 1;
+fi
+
+# write the out directory into the .android_config file
+echo $SKIA_OUT > .android_config
+
+make $makeVars
+if [ $? != 0 ]
+then
+ exit 1;
+fi
diff --git a/platform_tools/android/bin/android_perf b/platform_tools/android/bin/android_perf
new file mode 100644
index 0000000000..5e4b7c8b7a
--- /dev/null
+++ b/platform_tools/android/bin/android_perf
@@ -0,0 +1,145 @@
+#!/bin/bash
+#
+# android_perf: utility for running perf on an android device
+#
+# The basic usage sequence is to run...
+# 1) perf record [gm/tests/bench] # runs profiler on specified app
+# 2) perf report # prints profiler results
+# 3) perf clean # cleans the temporary directory used to store results
+#
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+PERF_CMD=$1
+
+source $SCRIPT_DIR/utils/setup_adb.sh
+
+if [ $(uname) == "Linux" ]; then
+ PERFHOST=$SCRIPT_DIR/linux/perfhost
+elif [ $(uname) == "Darwin" ]; then
+ PERFHOST=$SCRIPT_DIR/mac/perfhost
+else
+ echo "Could not automatically determine OS!"
+ exit 1;
+fi
+
+# We need the debug symbols from these files
+PERF_TMP_DIR=$(pwd)/android_perf_tmp
+
+TMP_SYS_BIN=$PERF_TMP_DIR/system/bin
+TMP_SYS_LIB=$PERF_TMP_DIR/system/lib
+TMP_APP_LIB=$PERF_TMP_DIR/data/data/com.skia/lib
+
+perf_setup() {
+
+ mkdir -p $TMP_SYS_BIN
+ mkdir -p $TMP_SYS_LIB
+ mkdir -p $TMP_APP_LIB
+
+ # setup symlinks to account for perf potentially looking elsewhere
+ mkdir -p $PERF_TMP_DIR/data/app-lib
+ $( cd $PERF_TMP_DIR/data/app-lib && ln -s ../data/com.skia/lib com.skia-1)
+ $( cd $PERF_TMP_DIR/data/app-lib && ln -s ../data/com.skia/lib com.skia-2)
+
+ echo "Copying symbol files"
+ $ADB pull /system/bin/skia_launcher $TMP_SYS_BIN
+ $ADB pull /system/lib/libc.so $TMP_SYS_LIB
+ $ADB pull /system/lib/libstlport.so $TMP_SYS_LIB
+ $ADB pull /system/lib/libcutils.so $TMP_SYS_LIB
+ $ADB pull /system/lib/libGLESv2.so $TMP_SYS_LIB
+ $ADB pull /system/lib/libandroid.so $TMP_SYS_LIB
+ $ADB pull /system/lib/libm.so $TMP_SYS_LIB
+ $ADB pull /system/lib/libz.so $TMP_SYS_LIB
+
+ if [ $# -ge 2 ]
+ then
+ APP_NAME=$(basename $2)
+ $ADB pull /data/data/com.skia/lib/lib${APP_NAME}.so $TMP_APP_LIB
+ else
+ $ADB pull /data/data/com.skia/lib/ $TMP_APP_LIB
+ fi
+
+
+}
+
+perf_record() {
+
+ APP_NAME=$(basename $2)
+ # Collect extra arguments to be passed to the skia_launcher binary
+ shift # perf_cmd
+ shift # app_name
+ while (( "$#" )); do
+ APP_ARGS="$APP_ARGS $1"
+ shift
+ done
+
+ echo "Checking for skia_launcher app..."
+ if [ ! -f $TMP_SYS_BIN/skia_launcher ]
+ then
+ echo "Unable to find the skia_launcher on the device"
+ rm -rf $PERF_TMP_DIR
+ exit 1;
+ fi
+
+ echo "Checking for $APP_NAME library..."
+ if [ ! -f $TMP_APP_LIB/lib$APP_NAME.so ]
+ then
+ echo "Unable to find the app's shared library on the device"
+ rm -rf $PERF_TMP_DIR
+ exit 1;
+ fi
+
+ echo "Killing any running Skia processes."
+ $ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kill
+
+ echo "Starting application"
+ $ADB shell skia_launcher $APP_NAME $APP_ARGS &
+
+ # WE REALLY REALLY WANT TO BE ABLE TO PASS THE SKIA_LAUNCHER APP DIRECTLY TO
+ # PERF, BUT AT THIS POINT THE DATA FILE WE GET WHEN GOING THAT ROUTE IS UNABLE
+ # TO BE READ BY THE REPORTING TOOL
+ echo "Starting profiler"
+ APP_PID=$($ADB shell ps | grep skia_launcher | awk '{print $2}')
+ $ADB shell perf record -p ${APP_PID} sleep 70
+
+ $ADB pull /data/perf.data $PERF_TMP_DIR/perf.data
+
+ exit 0;
+}
+
+perf_report() {
+ # Collect extra arguments to be passed to the perfhost binary
+ while (( "$#" )); do
+ APP_ARGS="$APP_ARGS $1"
+ shift
+ done
+
+ $PERFHOST report -i $PERF_TMP_DIR/perf.data --symfs=$PERF_TMP_DIR $APP_ARGS
+}
+
+# Clean up
+perf_clean() {
+ rm -rf $PERF_TMP_DIR
+}
+
+case $PERF_CMD in
+ setup)
+ perf_setup $@
+ ;;
+ record)
+ perf_setup $@
+ perf_record $@
+ ;;
+ report)
+ perf_report
+ ;;
+ clean)
+ perf_clean
+ ;;
+ *)
+ echo -n "ERROR: unknown perf command ($PERF_CMD), valid values: "
+ echo "setup, record, report, clean"
+ exit 1;
+ ;;
+esac
+
+exit 0;
diff --git a/platform_tools/android/bin/android_run_skia b/platform_tools/android/bin/android_run_skia
new file mode 100755
index 0000000000..f958b76840
--- /dev/null
+++ b/platform_tools/android/bin/android_run_skia
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# android_run_skia: starts the correct skia program on the device, prints the
+# output, and kills the app if interrupted.
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+source $SCRIPT_DIR/utils/setup_adb.sh
+
+APP_ARGS=""
+USE_INTENT="false"
+SERIAL=""
+
+while (( "$#" )); do
+
+ if [[ "$1" == "--intent" ]];
+ then
+ USE_INTENT="true"
+ elif [[ "$1" == "-s" ]];
+ then
+ if [[ $# -lt 2 ]];
+ then
+ echo "ERROR: missing serial number"
+ exit 1;
+ fi
+ SERIAL="-s $2"
+ shift
+ else
+ APP_ARGS="$APP_ARGS $1"
+ fi
+
+shift
+done
+
+
+if [[ "$USE_INTENT" == "true" ]];
+then
+ $ADB logcat -c
+ $ADB $SERIAL shell am broadcast -a com.skia.intent.action.LAUNCH_SKIA -n com.skia/.SkiaReceiver -e args "$APP_ARGS"
+ trap "echo \"Interrupt.\"" INT
+ eval "($ADB logcat)"
+ trap - INT
+ echo "Interrupt. Killing Skia process..."
+ $SCRIPT_DIR/android_kill_skia
+ echo "Done."
+else
+ $ADB $SERIAL shell skia_launcher $APP_ARGS
+fi
diff --git a/platform_tools/android/bin/android_setup.sh b/platform_tools/android/bin/android_setup.sh
new file mode 100755
index 0000000000..058d943329
--- /dev/null
+++ b/platform_tools/android/bin/android_setup.sh
@@ -0,0 +1,189 @@
+function exportVar {
+ NAME=$1
+ VALUE=$2
+ echo export $NAME=\"$VALUE\"
+ export $NAME="$VALUE"
+}
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+# A valid Android SDK installation is required to build the sample app.
+if [ -z "$ANDROID_SDK_ROOT" ]; then
+ ANDROID_TOOL=$(which android 2>/dev/null)
+ if [ -z "$ANDROID_TOOL" ]; then
+ echo "ERROR: Please define ANDROID_SDK_ROOT in your environment to point"
+ echo " to a valid Android SDK installation."
+ return 1
+ fi
+ ANDROID_SDK_ROOT=$(cd $(dirname "$ANDROID_TOOL")/.. && pwd)
+ exportVar ANDROID_SDK_ROOT "$ANDROID_SDK_ROOT"
+fi
+
+# ant is required to be installed on your system and in your PATH
+ant -version &> /dev/null
+if [[ "$?" != "0" ]]; then
+ echo "ERROR: Unable to find ant. Please install it before proceeding."
+ exit 1
+fi
+
+# determine the toolchain that we will be using
+API_LEVEL=14
+
+if [[ -z "$NDK_REV" ]];
+then
+ NDK_REV="8d"
+fi
+
+if [[ -z "$ANDROID_ARCH" ]];
+then
+ ANDROID_ARCH="arm"
+fi
+
+TOOLCHAIN_DIR=${SCRIPT_DIR}/../toolchains
+if [ $(uname) == "Linux" ]; then
+ echo "Using Linux toolchain."
+ TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-linux_v$API_LEVEL
+elif [ $(uname) == "Darwin" ]; then
+ echo "Using Mac toolchain."
+ TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-mac_v$API_LEVEL
+else
+ echo "Could not automatically determine toolchain! Defaulting to Linux."
+ TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-linux_v$API_LEVEL
+fi
+exportVar ANDROID_TOOLCHAIN ${TOOLCHAIN_DIR}/${TOOLCHAIN_TYPE}/bin
+
+# if the toolchain doesn't exist on your machine then we need to fetch it
+if [ ! -d "$ANDROID_TOOLCHAIN" ]; then
+ # gsutil must be installed on your system and in your PATH
+ gsutil version &> /dev/null
+ if [[ "$?" != "0" ]]; then
+ echo "ERROR: Unable to find gsutil. Please install it before proceeding."
+ exit 1
+ fi
+ # create the toolchain directory if needed
+ if [ ! -d "$TOOLCHAIN_DIR" ]; then
+ mkdir $TOOLCHAIN_DIR
+ fi
+ # enter the toolchain directory then download, unpack, and remove the tarball
+ pushd $TOOLCHAIN_DIR
+ TARBALL=ndk-r$NDK_REV-v$API_LEVEL.tgz
+ gsutil cp gs://chromium-skia-gm/android-toolchains/$TARBALL $TARBALL
+ echo "Untarring $TOOLCHAIN_TYPE from $TARBALL."
+ tar -xzf $TARBALL $TOOLCHAIN_TYPE
+ echo "Removing $TARBALL"
+ rm $TARBALL
+ popd
+fi
+
+if [ ! -d "$ANDROID_TOOLCHAIN" ]; then
+ echo "ERROR: unable to download/setup the required toolchain (${TOOLCHAIN_TYPE})"
+ return 1;
+fi
+
+echo "The build is targeting NDK API level $API_LEVEL for use on Android 4.0 (NDK Revision $NDK_REV) and above"
+
+LS="/bin/ls" # Use directly to avoid any 'ls' alias that might be defined.
+GCC=$($LS $ANDROID_TOOLCHAIN/*-gcc | head -n1)
+if [ -z "$GCC" ]; then
+ echo "ERROR: Could not find Android cross-compiler in: $ANDROID_TOOLCHAIN"
+ return 1
+fi
+
+# Remove the '-gcc' at the end to get the full toolchain prefix
+ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc}
+
+exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar"
+if [[ -z "$ANDROID_MAKE_CCACHE" ]]; then
+ exportVar CC "$ANDROID_TOOLCHAIN_PREFIX-gcc"
+ exportVar CXX "$ANDROID_TOOLCHAIN_PREFIX-g++"
+ exportVar LINK "$ANDROID_TOOLCHAIN_PREFIX-gcc"
+else
+ exportVar CC "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
+ exportVar CXX "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++"
+ exportVar LINK "$ANDROID_MAKE_CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
+fi
+exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib"
+exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy"
+exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip"
+
+# Helper function to configure the GYP defines to the appropriate values
+# based on the target device.
+setup_device() {
+ DEFINES="OS=android"
+ DEFINES="${DEFINES} host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')"
+ DEFINES="${DEFINES} skia_os=android"
+ DEFINES="${DEFINES} android_base=${SCRIPT_DIR}/.."
+ DEFINES="${DEFINES} android_toolchain=${TOOLCHAIN_TYPE}"
+
+ # Setup the build variation depending on the target device
+ TARGET_DEVICE="$1"
+
+ if [ -z "$TARGET_DEVICE" ]; then
+ echo "INFO: no target device type was specified so using the default 'arm_v7'"
+ TARGET_DEVICE="arm_v7"
+ fi
+
+ case $TARGET_DEVICE in
+ nexus_s)
+ DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 armv7=1 arm_thumb=0"
+ DEFINES="${DEFINES} skia_texture_cache_mb_limit=24"
+ ;;
+ nexus_4 | nexus_7 | nexus_10)
+ DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 armv7=1 arm_thumb=0"
+ ;;
+ xoom)
+ DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 armv7=1 arm_thumb=0"
+ ;;
+ galaxy_nexus)
+ DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 armv7=1 arm_thumb=0"
+ DEFINES="${DEFINES} skia_texture_cache_mb_limit=32"
+ ;;
+ razr_i)
+ DEFINES="${DEFINES} skia_arch_type=x86 skia_arch_width=32"
+ DEFINES="${DEFINES} skia_texture_cache_mb_limit=32"
+ ;;
+ arm_v7)
+ DEFINES="${DEFINES} skia_arch_type=arm arm_neon_optional=1 armv7=1 arm_thumb=0"
+ ;;
+ arm_v7_thumb)
+ DEFINES="${DEFINES} skia_arch_type=arm arm_neon_optional=1 armv7=1 arm_thumb=1"
+ ;;
+ arm)
+ DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 armv7=0 arm_thumb=0"
+ ;;
+ arm_thumb)
+ DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 armv7=0 arm_thumb=1"
+ ;;
+ x86)
+ DEFINES="${DEFINES} skia_arch_type=x86 skia_arch_width=32"
+ DEFINES="${DEFINES} skia_texture_cache_mb_limit=32"
+ ;;
+ *)
+ echo -n "ERROR: unknown device specified ($TARGET_DEVICE), valid values: "
+ echo "nexus_[s,4,7,10] xoom galaxy_nexus arm arm_thumb arm_v7 arm_v7_thumb x86"
+ return 1;
+ ;;
+ esac
+
+ echo "The build is targeting the device: $TARGET_DEVICE"
+
+ exportVar GYP_DEFINES "$DEFINES"
+ exportVar SKIA_OUT "out/config/android-${TARGET_DEVICE}"
+}
+
+# Run the setup device command initially as a convenience for the user
+#setup_device
+#echo "** The device has been setup for you by default. If you would like to **"
+#echo "** use a different device then run the setup_device function with the **"
+#echo "** appropriate input. **"
+
+# Use the "android" flavor of the Makefile generator for both Linux and OS X.
+exportVar GYP_GENERATORS "make-android"
+
+# Helper function so that when we run "make" to build for clank it exports
+# the toolchain variables to make.
+#make_android() {
+# CC="$CROSS_CC" CXX="$CROSS_CXX" LINK="$CROSS_LINK" \
+# AR="$CROSS_AR" RANLIB="$CROSS_RANLIB" \
+# command make $*
+#}
diff --git a/platform_tools/android/bin/linux/adb b/platform_tools/android/bin/linux/adb
new file mode 100755
index 0000000000..94257a05a5
--- /dev/null
+++ b/platform_tools/android/bin/linux/adb
Binary files differ
diff --git a/platform_tools/android/bin/linux/perfhost b/platform_tools/android/bin/linux/perfhost
new file mode 100644
index 0000000000..926a639813
--- /dev/null
+++ b/platform_tools/android/bin/linux/perfhost
Binary files differ
diff --git a/platform_tools/android/bin/mac/adb b/platform_tools/android/bin/mac/adb
new file mode 100755
index 0000000000..137d7fd6dd
--- /dev/null
+++ b/platform_tools/android/bin/mac/adb
Binary files differ
diff --git a/platform_tools/android/bin/mac/perfhost b/platform_tools/android/bin/mac/perfhost
new file mode 100755
index 0000000000..3e81fbcc61
--- /dev/null
+++ b/platform_tools/android/bin/mac/perfhost
Binary files differ
diff --git a/platform_tools/android/bin/utils/setup_adb.sh b/platform_tools/android/bin/utils/setup_adb.sh
new file mode 100644
index 0000000000..2f4e52956d
--- /dev/null
+++ b/platform_tools/android/bin/utils/setup_adb.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+
+UTIL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+if [ "$(which adb)" != "" ]; then
+ ADB="$(which adb)"
+elif [ $(uname) == "Linux" ]; then
+ ADB=$UTIL_DIR/../linux/adb
+elif [ $(uname) == "Darwin" ]; then
+ ADB=$UTIL_DIR/../mac/adb
+else
+ echo "ERROR: Could not find ADB!"
+ exit 1;
+fi
+
+echo "ADB is: $ADB"
diff --git a/platform_tools/android/bin/utils/setup_skia_out.sh b/platform_tools/android/bin/utils/setup_skia_out.sh
new file mode 100644
index 0000000000..78375a5cd7
--- /dev/null
+++ b/platform_tools/android/bin/utils/setup_skia_out.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+
+UTIL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+if [ -z "$SKIA_OUT" ]
+then
+
+ if [ ! -f .android_config ]
+ then
+ echo "Unable to find the .android_config file"
+ exit 1;
+ fi
+
+ export SKIA_OUT=$(cat .android_config)
+
+ if [ ! -d ${SKIA_OUT} ]
+ then
+ echo "The contents of .android_config are invalid"
+ exit 1;
+ fi
+fi \ No newline at end of file