launcher_protoutil 2.4 KB

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