| 1 |
#!/bin/sh |
| 2 |
# Copyright 2011, 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=manifest-merger.jar |
| 37 |
frameworkdir="$progdir" |
| 38 |
if [ ! -r "$frameworkdir/$jarfile" ] |
| 39 |
then |
| 40 |
frameworkdir=`dirname "$progdir"`/tools/lib |
| 41 |
fi |
| 42 |
if [ ! -r "$frameworkdir/$jarfile" ] |
| 43 |
then |
| 44 |
frameworkdir=`dirname "$progdir"`/framework |
| 45 |
fi |
| 46 |
if [ ! -r "$frameworkdir/$jarfile" ] |
| 47 |
then |
| 48 |
echo `basename "$prog"`": can't find $jarfile" |
| 49 |
exit 1 |
| 50 |
fi |
| 51 |
|
| 52 |
|
| 53 |
# Check args. |
| 54 |
if [ 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 |
| 58 |
else |
| 59 |
java_debug= |
| 60 |
fi |
| 61 |
|
| 62 |
java_cmd="java" |
| 63 |
|
| 64 |
# Mac OS X needs an additional arg, or you get an "illegal thread" complaint. |
| 65 |
if [ `uname` = "Darwin" ]; then |
| 66 |
os_opts="-XstartOnFirstThread" |
| 67 |
else |
| 68 |
os_opts= |
| 69 |
fi |
| 70 |
|
| 71 |
if [ `uname` = "Linux" ]; then |
| 72 |
export GDK_NATIVE_WINDOWS=true |
| 73 |
fi |
| 74 |
|
| 75 |
if [ "$OSTYPE" = "cygwin" ] ; then |
| 76 |
jarpath=`cygpath -w "$frameworkdir/$jarfile"` |
| 77 |
progdir=`cygpath -w "$progdir"` |
| 78 |
else |
| 79 |
jarpath="$frameworkdir/$jarfile" |
| 80 |
fi |
| 81 |
|
| 82 |
# need to use "java.ext.dirs" because "-jar" causes classpath to be ignored |
| 83 |
exec "$java_cmd" \ |
| 84 |
-Xmx256M $os_opts $java_debug \ |
| 85 |
-Dcom.android.manifmergerdir="$progdir" \ |
| 86 |
-classpath "$jarpath" \ |
| 87 |
com.android.manifestmerger.Main "$@" |