Raphael Moll | cba8e11 | 2013-02-04 15:21:35 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2011, The Android Open Source Project |
Raphael Moll | 08537a5 | 2013-01-04 15:17:44 -0800 | [diff] [blame] | 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 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. |
Raphael Moll | 08537a5 | 2013-01-04 15:17:44 -0800 | [diff] [blame] | 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 | |
Raphael Moll | cba8e11 | 2013-02-04 15:21:35 -0800 | [diff] [blame] | 36 | jarfile=lint.jar |
Raphael Moll | 08537a5 | 2013-01-04 15:17:44 -0800 | [diff] [blame] | 37 | frameworkdir="$progdir" |
| 38 | libdir="$progdir" |
| 39 | if [ ! -r "$frameworkdir/$jarfile" ] |
| 40 | then |
| 41 | frameworkdir=`dirname "$progdir"`/tools/lib |
| 42 | libdir=`dirname "$progdir"`/tools/lib |
| 43 | fi |
| 44 | if [ ! -r "$frameworkdir/$jarfile" ] |
| 45 | then |
| 46 | frameworkdir=`dirname "$progdir"`/framework |
| 47 | libdir=`dirname "$progdir"`/lib |
| 48 | fi |
| 49 | if [ ! -r "$frameworkdir/$jarfile" ] |
| 50 | then |
| 51 | echo `basename "$prog"`": can't find $jarfile" |
| 52 | exit 1 |
| 53 | fi |
| 54 | |
Raphael Moll | cba8e11 | 2013-02-04 15:21:35 -0800 | [diff] [blame] | 55 | # Check args. |
| 56 | if [ debug = "$1" ]; then |
| 57 | # add this in for debugging |
| 58 | java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y |
| 59 | shift 1 |
| 60 | else |
| 61 | java_debug= |
Raphael Moll | 08537a5 | 2013-01-04 15:17:44 -0800 | [diff] [blame] | 62 | fi |
| 63 | |
Raphael Moll | cba8e11 | 2013-02-04 15:21:35 -0800 | [diff] [blame] | 64 | javaCmd="java" |
| 65 | |
| 66 | jarpath="$frameworkdir/$jarfile" |
Raphael Moll | 08537a5 | 2013-01-04 15:17:44 -0800 | [diff] [blame] | 67 | |
Tobias Thierer | 07a8c19 | 2017-11-30 23:30:21 +0000 | [diff] [blame] | 68 | is_java_version_9=$(java -version 2>&1| grep 'version [ "]9.*[ "]') |
| 69 | if [ "${is_java_version_9}" = "" ]; then |
| 70 | modules_arg="" |
| 71 | else |
| 72 | modules_arg="--add-modules=java.xml.bind" |
| 73 | fi |
| 74 | |
Raphael Moll | 08537a5 | 2013-01-04 15:17:44 -0800 | [diff] [blame] | 75 | exec "$javaCmd" \ |
Raphael Moll | cba8e11 | 2013-02-04 15:21:35 -0800 | [diff] [blame] | 76 | -Xmx512m $os_opts $java_debug \ |
| 77 | -Dcom.android.tools.lint.bindir="$progdir" \ |
Siva Velusamy | 707bded | 2013-07-29 09:28:27 -0700 | [diff] [blame] | 78 | -Djava.awt.headless=true \ |
Raphael Moll | 08537a5 | 2013-01-04 15:17:44 -0800 | [diff] [blame] | 79 | -classpath "$jarpath" \ |
Tobias Thierer | 07a8c19 | 2017-11-30 23:30:21 +0000 | [diff] [blame] | 80 | ${modules_arg} \ |
Raphael Moll | cba8e11 | 2013-02-04 15:21:35 -0800 | [diff] [blame] | 81 | com.android.tools.lint.Main "$@" |