Home | History | Annotate | Download | only in tools
      1 #!/bin/bash
      2 # Copyright 2005-2007, The Android Open Source Project
      3 #
      4 # Licensed under the Apache License, Version 2.0 (the "License");
      5 # you may not use this file except in compliance with the License.
      6 # You may obtain a copy of the License at
      7 #
      8 #     http://www.apache.org/licenses/LICENSE-2.0
      9 #
     10 # Unless required by applicable law or agreed to in writing, software
     11 # distributed under the License is distributed on an "AS IS" BASIS,
     12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 # See the License for the specific language governing permissions and
     14 # limitations under the License.
     15 
     16 # Set up prog to be the path of this script, including following symlinks,
     17 # and set up progdir to be the fully-qualified pathname of its directory.
     18 prog="$0"
     19 while [ -h "${prog}" ]; do
     20     newProg=`/bin/ls -ld "${prog}"`
     21     newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
     22     if expr "x${newProg}" : 'x/' >/dev/null; then
     23         prog="${newProg}"
     24     else
     25         progdir=`dirname "${prog}"`
     26         prog="${progdir}/${newProg}"
     27     fi
     28 done
     29 oldwd=`pwd`
     30 progdir=`dirname "${prog}"`
     31 cd "${progdir}"
     32 progdir=`pwd`
     33 prog="${progdir}"/`basename "${prog}"`
     34 cd "${oldwd}"
     35 
     36 jarfile=ddms.jar
     37 frameworkdir="$progdir"
     38 libdir="$progdir"
     39 if [ ! -r "$frameworkdir/$jarfile" ]
     40 then
     41     frameworkdir=`dirname "$progdir"`/tools/lib
     42     libdir=`dirname "$progdir"`/tools/lib
     43 fi
     44 if [ ! -r "$frameworkdir/$jarfile" ]
     45 then
     46     frameworkdir=`dirname "$progdir"`/framework
     47     libdir=`dirname "$progdir"`/lib
     48 fi
     49 if [ ! -r "$frameworkdir/$jarfile" ]
     50 then
     51     echo `basename "$prog"`": can't find $jarfile"
     52     exit 1
     53 fi
     54 
     55 
     56 # Check args.
     57 if [ debug = "$1" ]; then
     58     # add this in for debugging
     59     java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
     60     shift 1
     61 else
     62     java_debug=
     63 fi
     64 
     65 javaCmd="java"
     66 
     67 # Mac OS X needs an additional arg, or you get an "illegal thread" complaint.
     68 if [ `uname` = "Darwin" ]; then
     69     os_opts="-XstartOnFirstThread"
     70 else
     71     os_opts=
     72 fi
     73 
     74 if [ `uname` = "Linux" ]; then
     75     export GDK_NATIVE_WINDOWS=true
     76 fi
     77 
     78 jarpath="$frameworkdir/$jarfile:$frameworkdir/swtmenubar.jar"
     79 
     80 # Figure out the path to the swt.jar for the current architecture.
     81 # if ANDROID_SWT is defined, then just use this.
     82 # else, if running in the Android source tree, then look for the correct swt folder in prebuilt
     83 # else, look for the correct swt folder in the SDK under tools/lib/
     84 swtpath=""
     85 if [ -n "$ANDROID_SWT" ]; then
     86     swtpath="$ANDROID_SWT"
     87 else
     88     vmarch=`${javaCmd} -jar "${frameworkdir}"/archquery.jar`
     89     if [ -n "$ANDROID_BUILD_TOP" ]; then
     90         osname=`uname -s | tr A-Z a-z`
     91         swtpath="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
     92     else
     93         swtpath="${frameworkdir}/${vmarch}"
     94     fi
     95 fi
     96 
     97 if [ ! -d "$swtpath" ]; then
     98     echo "SWT folder '${swtpath}' does not exist."
     99     echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
    100     exit 1
    101 fi
    102 
    103 if [ -x $progdir/monitor ]; then
    104     echo "The standalone version of DDMS is deprecated."
    105     echo "Please use Android Device Monitor (tools/monitor) instead."
    106 fi
    107 exec "$javaCmd" \
    108     -Xmx256M $os_opts $java_debug \
    109     -Dcom.android.ddms.bindir="$progdir" \
    110     -classpath "$jarpath:$swtpath/swt.jar" \
    111     com.android.ddms.Main "$@"
    112