• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Copyright (C) 2007 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# As per the Apache license requirements, this file has been modified
18# from its original state.
19#
20# Such modifications are Copyright (C) 2010 Ben Gruver, and are released
21# under the original license
22
23# This script is a wrapper around baksmali.jar, so you can simply call
24# "baksmali", instead of java -jar baksmali.jar. It is heavily based on
25# the "dx" script from the Android SDK
26
27# Set up prog to be the path of this script, including following symlinks,
28# and set up progdir to be the fully-qualified pathname of its directory.
29prog="$0"
30while [ -h "${prog}" ]; do
31    newProg=`/bin/ls -ld "${prog}"`
32    echo ${newProg}
33
34
35    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
36    if expr "x${newProg}" : 'x/' >/dev/null; then
37        prog="${newProg}"
38    else
39        progdir=`dirname "${prog}"`
40        prog="${progdir}/${newProg}"
41    fi
42done
43oldwd=`pwd`
44progdir=`dirname "${prog}"`
45cd "${progdir}"
46progdir=`pwd`
47prog="${progdir}"/`basename "${prog}"`
48cd "${oldwd}"
49
50
51jarfile=baksmali.jar
52libdir="$progdir"
53if [ ! -r "$libdir/$jarfile" ]
54then
55    echo `basename "$prog"`": can't find $jarfile"
56    exit 1
57fi
58
59javaOpts=""
60
61# If you want DX to have more memory when executing, uncomment the following
62# line and adjust the value accordingly. Use "java -X" for a list of options
63# you can pass here.
64#
65javaOpts="-Xmx256M"
66
67# Alternatively, this will extract any parameter "-Jxxx" from the command line
68# and pass them to Java (instead of to dx). This makes it possible for you to
69# add a command-line parameter such as "-JXmx256M" in your ant scripts, for
70# example.
71while expr "x$1" : 'x-J' >/dev/null; do
72    opt=`expr "$1" : '-J\(.*\)'`
73    javaOpts="${javaOpts} -${opt}"
74    shift
75done
76
77if [ "$OSTYPE" = "cygwin" ] ; then
78	jarpath=`cygpath -w  "$libdir/$jarfile"`
79else
80	jarpath="$libdir/$jarfile"
81fi
82
83exec java $javaOpts -jar "$jarpath" "$@"
84