github.com/westcoastroms/westcoastroms-build@v0.0.0-20190928114312-2350e5a73030/build/soong/scripts/jar-wrapper.sh (about)

     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  # 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  
    20  prog="$0"
    21  while [ -h "${prog}" ]; do
    22      fullprog=`/bin/ls -ld "${prog}"`
    23      fullprog=`expr "${fullprog}" : ".* -> \(.*\)$"`
    24      if expr "x${fullprog}" : 'x/' >/dev/null; then
    25          prog="${fullprog}"
    26      else
    27          progdir=`dirname "${prog}"`
    28          prog="${progdir}/${fullprog}"
    29      fi
    30  done
    31  
    32  oldwd=`pwd`
    33  progdir=`dirname "${prog}"`
    34  cd "${progdir}"
    35  progdir=`pwd`
    36  prog="${progdir}"/`basename "${prog}"`
    37  cd "${oldwd}"
    38  
    39  jarfile=`basename "${prog}"`.jar
    40  jardir="${progdir}"
    41  
    42  if [ ! -r "${jardir}/${jarfile}" ]; then
    43      jardir=`dirname "${progdir}"`/framework
    44  fi
    45  
    46  if [ ! -r "${jardir}/${jarfile}" ]; then
    47      echo `basename "${prog}"`": can't find ${jarfile}"
    48      exit 1
    49  fi
    50  
    51  javaOpts=""
    52  while expr "x$1" : 'x-J' >/dev/null; do
    53      opt=`expr "$1" : '-J\(.*\)'`
    54      javaOpts="${javaOpts} -${opt}"
    55      shift
    56  done
    57  
    58  exec java ${javaOpts} -jar ${jardir}/${jarfile} "$@"