• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
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.
18prog="$0"
19while [ -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
28done
29oldwd=`pwd`
30progdir=`dirname "${prog}"`
31cd "${progdir}"
32progdir=`pwd`
33prog="${progdir}"/`basename "${prog}"`
34cd "${oldwd}"
35
36jarfile=sdkmanager.jar
37frameworkdir="$progdir"
38libdir="$progdir"
39if [ ! -r "$frameworkdir/$jarfile" ]
40then
41    frameworkdir=`dirname "$progdir"`/tools/lib
42    libdir=`dirname "$progdir"`/tools/lib
43fi
44if [ ! -r "$frameworkdir/$jarfile" ]
45then
46    frameworkdir=`dirname "$progdir"`/framework
47    libdir=`dirname "$progdir"`/lib
48fi
49if [ ! -r "$frameworkdir/$jarfile" ]
50then
51    echo `basename "$prog"`": can't find $jarfile"
52    exit 1
53fi
54
55
56# Check args.
57if [ 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
61else
62    java_debug=
63fi
64
65java_cmd="java"
66
67# Mac OS X needs an additional arg, or you get an "illegal thread" complaint.
68if [ `uname` = "Darwin" ]; then
69    os_opts="-XstartOnFirstThread"
70else
71    os_opts=
72fi
73
74if [ `uname` = "Linux" ]; then
75    export GDK_NATIVE_WINDOWS=true
76fi
77
78if [ "$OSTYPE" = "cygwin" ] ; then
79    jarpath=`cygpath -w  "$frameworkdir/$jarfile"`
80    progdir=`cygpath -w  "$progdir"`
81else
82    jarpath="$frameworkdir/$jarfile"
83fi
84
85# Figure out the path to the swt.jar for the current architecture.
86# if ANDROID_SWT is defined, then just use this.
87# else, if running in the Android source tree, then look for the correct swt folder in prebuilt
88# else, look for the correct swt folder in the SDK under tools/lib/
89swtpath=""
90if [ -n "$ANDROID_SWT" ]; then
91    swtpath="$ANDROID_SWT"
92else
93    vmarch=`${java_cmd} -jar "${frameworkdir}"/archquery.jar`
94    if [ -n "$ANDROID_BUILD_TOP" ]; then
95        osname=`uname -s | tr A-Z a-z`
96        swtpath="${ANDROID_BUILD_TOP}/prebuilt/${osname}-${vmarch}/swt"
97    else
98        swtpath="${frameworkdir}/${vmarch}"
99    fi
100fi
101
102# Combine the swtpath and the framework dir path.
103if [ -d "$swtpath" ]; then
104    frameworkdir="${swtpath}:${frameworkdir}"
105else
106    echo "SWT folder '${swtpath}' does not exist."
107    echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
108    exit 1
109fi
110
111if [ -z "$1" ]; then
112    echo "Starting Android SDK and AVD Manager"
113fi
114
115# need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
116# might need more memory, e.g. -Xmx128M
117exec "$java_cmd" -Xmx256M $os_opts $java_debug -Djava.ext.dirs="$frameworkdir" -Dcom.android.sdkmanager.toolsdir="$progdir" -jar "$jarpath" "$@"
118