#!/bin/bash
#
# Copyright (C)2007The Android Open Source Project
#
# Licensed under the Apache License, Version2.0 (the "License");
# you may not use thisfile except incompliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed toinwriting, software
# distributed under the License is distributed on an"AS IS"BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the Licenseforthe specific language governing permissions and
# limitations under the License.
# This script is a wrapperfor smali.jar, so you can simply call "smali",
# instead of java-jar smali.jar. It is heavily based on the "dx"script
# from the Android SDK
# Set up prog to be the path of this script, including following symlinks,
# and set up progdir to be the fully-qualified pathname of its directory.
prog="$0"
while [ -h "${prog}" ]; donewProg=`/bin/ls -ld "${prog}"`echo${newProg}
newProg=`expr "${newProg}" : ".* -> (.*)$"`if expr "x${newProg}" : 'x/' >/dev/null; thenprog="${newProg}"
elseprogdir=`dirname "${prog}"`
prog="${progdir}/${newProg}"
fi
doneoldwd=`pwd`
progdir=`dirname "${prog}"`
cd"${progdir}"progdir=`pwd`
prog="${progdir}"/`basename "${prog}"`
cd"${oldwd}"jarfile=apktool.jar
libdir="$progdir"
if [ ! -r "$libdir/$jarfile"]then
echo `basename "$prog"`": can't find $jarfile"exit1
fijavaOpts=""# If you want DX to havemorememory when executing, uncomment the following
# line and adjust the value accordingly. Use"java -X" fora list of options
# you can pass here.
#
javaOpts="-Xmx256M"# Alternatively, this will extract any parameter"-Jxxx"from the command line
# and pass them to Java (instead of to dx). This makes it possibleforyou to
# add a command-line parameter such as "-JXmx256M" in your ant scripts, for# example.while expr "x$1" : 'x-J' >/dev/null; doopt=`expr "$1" : '-J(.*)'`
javaOpts="${javaOpts} -${opt}"
shift
done
if [ "$OSTYPE" = "cygwin" ] ; thenjarpath=`cygpath -w "$libdir/$jarfile"`elsejarpath="$libdir/$jarfile"
fi# add current location to pathforaapt
PATH=$PATH:`pwd`;
export PATH;
exec java $javaOpts-Djava.awt.headless=true -jar "$jarpath" "$@"