dexdeps revision 72e93344b4d1ffc71e9c832ec23de0657e5b04a5
1#!/bin/bash
2#
3# Copyright (C) 2009 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.
19prog="$0"
20while [ -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
29done
30oldwd=`pwd`
31progdir=`dirname "${prog}"`
32cd "${progdir}"
33progdir=`pwd`
34prog="${progdir}"/`basename "${prog}"`
35cd "${oldwd}"
36
37jarfile=dexdeps.jar
38libdir="$progdir"
39if [ ! -r "$libdir/$jarfile" ]
40then
41    libdir=`dirname "$progdir"`/tools/lib
42fi
43if [ ! -r "$libdir/$jarfile" ]
44then
45    libdir=`dirname "$progdir"`/framework
46fi
47if [ ! -r "$libdir/$jarfile" ]
48then
49    echo `basename "$prog"`": can't find $jarfile"
50    exit 1
51fi
52
53javaOpts=""
54
55# Alternatively, this will extract any parameter "-Jxxx" from the command line
56# and pass them to Java (instead of to dexdeps).
57while expr "x$1" : 'x-J' >/dev/null; do
58    opt=`expr "$1" : '-J\(.*\)'`
59    javaOpts="${javaOpts} -${opt}"
60    shift
61done
62
63if [ "$OSTYPE" = "cygwin" ] ; then
64    jarpath=`cygpath -w  "$libdir/$jarfile"`
65else
66    jarpath="$libdir/$jarfile"
67fi
68
69exec java $javaOpts -jar "$jarpath" "$@"
70