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