Home | History | Annotate | Download | only in tools
      1 #!/bin/bash
      2 #
      3 # Copyright 2005-2006, 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 # Set up prog to be the path of this script, including following symlinks,
     18 # and set up progdir to be the fully-qualified pathname of its directory.
     19 prog="$0"
     20 while [ -h "${prog}" ]; do
     21     newProg=`/bin/ls -ld "${prog}"`
     22     newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
     23     if expr "x${newProg}" : 'x/' >/dev/null; then
     24         prog="${newProg}"
     25     else
     26         progdir=`dirname "${prog}"`
     27         prog="${progdir}/${newProg}"
     28     fi
     29 done
     30 oldwd=`pwd`
     31 progdir=`dirname "${prog}"`
     32 progname=`basename "${prog}"`
     33 cd "${progdir}"
     34 progdir=`pwd`
     35 prog="${progdir}"/"${progname}"
     36 cd "${oldwd}"
     37 
     38 jarfile=traceview.jar
     39 frameworkdir="$progdir"
     40 libdir="$progdir"
     41 if [ ! -r "$frameworkdir/$jarfile" ]
     42 then
     43     frameworkdir=`dirname "$progdir"`/tools/lib
     44     libdir=`dirname "$progdir"`/tools/lib
     45 fi
     46 if [ ! -r "$frameworkdir/$jarfile" ]
     47 then
     48     frameworkdir=`dirname "$progdir"`/framework
     49     libdir=`dirname "$progdir"`/lib
     50 fi
     51 if [ ! -r "$frameworkdir/$jarfile" ]
     52 then
     53     echo "${progname}: can't find $jarfile"
     54     exit 1
     55 fi
     56 
     57 javaCmd="java"
     58 
     59 os=`uname`
     60 if [ $os == 'Darwin' ]; then
     61   javaOpts="-Xmx1600M -XstartOnFirstThread"
     62 else
     63   javaOpts="-Xmx1600M"
     64 fi
     65 
     66 if [ `uname` = "Linux" ]; then
     67     export GDK_NATIVE_WINDOWS=true
     68 fi
     69 
     70 while expr "x$1" : 'x-J' >/dev/null; do
     71     opt=`expr "x$1" : 'x-J\(.*\)'`
     72     javaOpts="${javaOpts} -${opt}"
     73     shift
     74 done
     75 
     76 jarpath="$frameworkdir/$jarfile"
     77 
     78 # Figure out the path to the swt.jar for the current architecture.
     79 # if ANDROID_SWT is defined, then just use this.
     80 # else, if running in the Android source tree, then look for the correct swt folder in prebuilt
     81 # else, look for the correct swt folder in the SDK under tools/lib/
     82 swtpath=""
     83 if [ -n "$ANDROID_SWT" ]; then
     84     swtpath="$ANDROID_SWT"
     85 else
     86     vmarch=`${javaCmd} -jar "${frameworkdir}"/archquery.jar`
     87     if [ -n "$ANDROID_BUILD_TOP" ]; then
     88         osname=`uname -s | tr A-Z a-z`
     89         swtpath="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
     90     else
     91         swtpath="${frameworkdir}/${vmarch}"
     92     fi
     93 fi
     94 
     95 # Combine the swtpath and the framework dir path.
     96 if [ -d "$swtpath" ]; then
     97     frameworkdir="${swtpath}:${frameworkdir}"
     98 else
     99     echo "SWT folder '${swtpath}' does not exist."
    100     echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
    101     exit 1
    102 fi
    103 
    104 if [ -x $progdir/monitor ]; then
    105     echo "The standalone version of traceview is deprecated."
    106     echo "Please use Android Device Monitor (tools/monitor) instead."
    107 fi
    108 exec "${javaCmd}" $javaOpts -Djava.ext.dirs="$frameworkdir" -Dcom.android.traceview.toolsdir="$progdir" -jar "$jarpath" "$@"
    109