blob: d63198f793dcf50641efec2175779e70a75620dd [file] [log] [blame]
Brett Chabot4bd67d52011-02-07 11:54:37 -08001#!/bin/bash
2
3# Copyright (C) 2010 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# A helper script that launches TradeFederation from the current build
18# environment.
19
20checkPath() {
21 if ! type -P $1 &> /dev/null; then
22 echo "Unable to find $1 in path."
23 exit
24 fi;
25}
26
Brett Chabot19d2db12011-02-23 15:26:03 -080027checkFile() {
28 if [ ! -f "$1" ]; then
29 echo "Unable to locate $1"
30 exit
31 fi;
32}
33
Brett Chabot4bd67d52011-02-07 11:54:37 -080034checkPath adb
Brett Chabot4bd67d52011-02-07 11:54:37 -080035checkPath java
36
37# check java version
Jorge Gonzalez8fe4cb42011-08-10 11:36:59 -070038JAVA_VERSION=$(java -version 2>&1 | grep '[ "]1\.6[\. "$$]')
Brett Chabot4bd67d52011-02-07 11:54:37 -080039if [ "${JAVA_VERSION}" == "" ]; then
40 echo "Wrong java version. 1.6 is required."
41 exit
42fi
43
Guang Zhuc5637f72011-07-24 13:15:24 -070044# check debug flag and set up remote debugging
45if [ -n "${TF_DEBUG}" ]; then
46 if [ -z "${TF_DEBUG_PORT}" ]; then
47 TF_DEBUG_PORT=10088
48 fi
49 RDBG_FLAG=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=${TF_DEBUG_PORT}
50fi
51
Brett Chabot19d2db12011-02-23 15:26:03 -080052# check if in Android build env
53if [ ! -z ${ANDROID_BUILD_TOP} ]; then
54 HOST=`uname`
55 if [ "$HOST" == "Linux" ]; then
56 OS="linux-x86"
57 elif [ "$HOST" == "Darwin" ]; then
58 OS="darwin-x86"
59 else
60 echo "Unrecognized OS"
61 exit
62 fi;
63 # ddmlib-prebuilt is still in standard dir
64 ddmlib_path=$ANDROID_BUILD_TOP/out/host/$OS/framework/ddmlib-prebuilt.jar
65 checkFile $ddmlib_path
66 # add all jars in tradefed out dir
67 tf_path=$ANDROID_BUILD_TOP/out/host/$OS/tradefed/\*
Brett Chabot4bd67d52011-02-07 11:54:37 -080068else
Brett Chabot19d2db12011-02-23 15:26:03 -080069 TF_ROOT_PATH=$(dirname $0)
70 # assume downloaded TF, look for jars in same directory as script
71 # sanity check - ensure ddmlib-prebuilt is there
72 checkFile $TF_ROOT_PATH/ddmlib-prebuilt.jar
73 tf_path=$TF_ROOT_PATH/\*
Brett Chabot4bd67d52011-02-07 11:54:37 -080074fi;
75
Guang Zhuc5637f72011-07-24 13:15:24 -070076java $RDBG_FLAG \
77 -cp $ddmlib_path:$tf_path com.android.tradefed.command.Console "$@"