Brett Chabot | 4bd67d5 | 2011-02-07 11:54:37 -0800 | [diff] [blame] | 1 | #!/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 | |
| 20 | checkPath() { |
| 21 | if ! type -P $1 &> /dev/null; then |
| 22 | echo "Unable to find $1 in path." |
| 23 | exit |
| 24 | fi; |
| 25 | } |
| 26 | |
Brett Chabot | 19d2db1 | 2011-02-23 15:26:03 -0800 | [diff] [blame] | 27 | checkFile() { |
| 28 | if [ ! -f "$1" ]; then |
| 29 | echo "Unable to locate $1" |
| 30 | exit |
| 31 | fi; |
| 32 | } |
| 33 | |
Brett Chabot | 4bd67d5 | 2011-02-07 11:54:37 -0800 | [diff] [blame] | 34 | checkPath adb |
Brett Chabot | 4bd67d5 | 2011-02-07 11:54:37 -0800 | [diff] [blame] | 35 | checkPath java |
| 36 | |
| 37 | # check java version |
Jorge Gonzalez | 8fe4cb4 | 2011-08-10 11:36:59 -0700 | [diff] [blame] | 38 | JAVA_VERSION=$(java -version 2>&1 | grep '[ "]1\.6[\. "$$]') |
Brett Chabot | 4bd67d5 | 2011-02-07 11:54:37 -0800 | [diff] [blame] | 39 | if [ "${JAVA_VERSION}" == "" ]; then |
| 40 | echo "Wrong java version. 1.6 is required." |
| 41 | exit |
| 42 | fi |
| 43 | |
Guang Zhu | c5637f7 | 2011-07-24 13:15:24 -0700 | [diff] [blame] | 44 | # check debug flag and set up remote debugging |
| 45 | if [ -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} |
| 50 | fi |
| 51 | |
Brett Chabot | 19d2db1 | 2011-02-23 15:26:03 -0800 | [diff] [blame] | 52 | # check if in Android build env |
| 53 | if [ ! -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 Chabot | 4bd67d5 | 2011-02-07 11:54:37 -0800 | [diff] [blame] | 68 | else |
Brett Chabot | 19d2db1 | 2011-02-23 15:26:03 -0800 | [diff] [blame] | 69 | 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 Chabot | 4bd67d5 | 2011-02-07 11:54:37 -0800 | [diff] [blame] | 74 | fi; |
| 75 | |
Guang Zhu | c5637f7 | 2011-07-24 13:15:24 -0700 | [diff] [blame] | 76 | java $RDBG_FLAG \ |
| 77 | -cp $ddmlib_path:$tf_path com.android.tradefed.command.Console "$@" |