• 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"
38if [ ! -r "$frameworkdir/$jarfile" ]
39then
40    frameworkdir=`dirname "$progdir"`/tools/lib
41fi
42if [ ! -r "$frameworkdir/$jarfile" ]
43then
44    frameworkdir=`dirname "$progdir"`/framework
45fi
46if [ ! -r "$frameworkdir/$jarfile" ]
47then
48    echo `basename "$prog"`": can't find $jarfile"
49    exit 1
50fi
51
52
53# Check args.
54if [ debug = "$1" ]; then
55    # add this in for debugging
56    java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
57    shift 1
58else
59    java_debug=
60fi
61
62java_cmd="java"
63
64# Mac OS X needs an additional arg, or you get an "illegal thread" complaint.
65if [ `uname` = "Darwin" ]; then
66    os_opts="-XstartOnFirstThread"
67else
68    os_opts=
69fi
70
71if [ `uname` = "Linux" ]; then
72    export GDK_NATIVE_WINDOWS=true
73fi
74
75if [ "$OSTYPE" = "cygwin" ] ; then
76    jarpath=`cygpath -w  "$frameworkdir/$jarfile"`
77    jarpath="$jarpath;"`cygpath -w  "$frameworkdir/swtmenubar.jar"`
78    progdir=`cygpath -w  "$progdir"`
79else
80    jarpath="$frameworkdir/$jarfile:$frameworkdir/swtmenubar.jar"
81fi
82
83# Get the current content of java.ext.dirs so that we can add to it instead of replacing
84javaExtDirs=`"${java_cmd}" -jar "${frameworkdir}/archquery.jar" java.ext.dirs`
85
86# Figure out the path to the swt.jar for the current architecture.
87# if ANDROID_SWT is defined, then just use this.
88# else, if running in the Android source tree, then look for the correct swt folder in prebuilt
89# else, look for the correct swt folder in the SDK under tools/lib/
90swtpath=""
91if [ -n "$ANDROID_SWT" ]; then
92    swtpath="$ANDROID_SWT"
93else
94    vmarch=`"${java_cmd}" -jar "${frameworkdir}/archquery.jar"`
95    if [ -n "$ANDROID_BUILD_TOP" ]; then
96        osname=`uname -s | tr A-Z a-z`
97        swtpath="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
98    else
99        swtpath="${frameworkdir}/${vmarch}"
100    fi
101fi
102
103if [ ! -d "$swtpath" ]; then
104    echo "SWT folder '${swtpath}' does not exist."
105    echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
106    exit 1
107fi
108
109# need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
110exec "$java_cmd" \
111    -Xmx256M $os_opts $java_debug \
112    -Dcom.android.sdkmanager.toolsdir="$progdir" \
113    -classpath "$jarpath:$swtpath/swt.jar" \
114    com.android.sdkmanager.Main "$@"
115