1 #!/bin/bash 2 # 3 # Copyright (C) 2013 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. 19 prog="$0" 20 while [ -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 29 done 30 oldwd=`pwd` 31 progdir=`dirname "${prog}"` 32 cd "${progdir}" 33 progdir=`pwd` 34 prog="${progdir}"/`basename "${prog}"` 35 cd "${oldwd}" 36 37 jarfile=launcher_protoutil_lib.jar 38 libdir="$progdir" 39 40 if [ ! -r "$libdir/$jarfile" ]; then 41 # set jar location for the Android tree case 42 libdir=`dirname "$progdir"`/framework 43 fi 44 45 if [ ! -r "$libdir/$jarfile" ]; then 46 echo `basename "$prog"`": can't find $jarfile" 47 exit 1 48 fi 49 50 # By default, give decoder a max heap size of 1 gig. This can be overridden 51 # by using a "-J" option (see below). 52 defaultMx="-Xmx1024M" 53 54 # The following will extract any initial parameters of the form 55 # "-J<stuff>" from the command line and pass them to the Java 56 # invocation (instead of to the decoder). This makes it possible for 57 # you to add a command-line parameter such as "-JXmx256M" in your 58 # scripts, for example. "java" (with no args) and "java -X" give a 59 # summary of available options. 60 61 javaOpts="" 62 63 while expr "x$1" : 'x-J' >/dev/null; do 64 opt=`expr "x$1" : 'x-J\(.*\)'` 65 javaOpts="${javaOpts} -${opt}" 66 if expr "x${opt}" : "xXmx[0-9]" >/dev/null; then 67 defaultMx="no" 68 fi 69 shift 70 done 71 72 if [ "${defaultMx}" != "no" ]; then 73 javaOpts="${javaOpts} ${defaultMx}" 74 fi 75 76 if [ "$OSTYPE" = "cygwin" ]; then 77 # For Cygwin, convert the jarfile path into native Windows style. 78 jarpath=`cygpath -w "$libdir/$jarfile"` 79 else 80 jarpath="$libdir/$jarfile" 81 fi 82 83 exec java $javaOpts -jar "$jarpath" "$@" 84