android-project/gradlew
author Ryan C. Gordon <icculus@icculus.org>
Sun, 21 Oct 2018 22:40:17 -0400
changeset 12345 50e1cca28b39
parent 11647 5816b27073a4
permissions -rwxr-xr-x
wasapi/win32: Sort initial device lists by device GUID.

This makes an unchanged set of hardware always report devices in the same
order on each run.
slouken@11647
     1
#!/usr/bin/env bash
slouken@11647
     2
slouken@11647
     3
##############################################################################
slouken@11647
     4
##
slouken@11647
     5
##  Gradle start up script for UN*X
slouken@11647
     6
##
slouken@11647
     7
##############################################################################
slouken@11647
     8
slouken@11647
     9
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
slouken@11647
    10
DEFAULT_JVM_OPTS=""
slouken@11647
    11
slouken@11647
    12
APP_NAME="Gradle"
slouken@11647
    13
APP_BASE_NAME=`basename "$0"`
slouken@11647
    14
slouken@11647
    15
# Use the maximum available, or set MAX_FD != -1 to use that value.
slouken@11647
    16
MAX_FD="maximum"
slouken@11647
    17
slouken@11647
    18
warn ( ) {
slouken@11647
    19
    echo "$*"
slouken@11647
    20
}
slouken@11647
    21
slouken@11647
    22
die ( ) {
slouken@11647
    23
    echo
slouken@11647
    24
    echo "$*"
slouken@11647
    25
    echo
slouken@11647
    26
    exit 1
slouken@11647
    27
}
slouken@11647
    28
slouken@11647
    29
# OS specific support (must be 'true' or 'false').
slouken@11647
    30
cygwin=false
slouken@11647
    31
msys=false
slouken@11647
    32
darwin=false
slouken@11647
    33
case "`uname`" in
slouken@11647
    34
  CYGWIN* )
slouken@11647
    35
    cygwin=true
slouken@11647
    36
    ;;
slouken@11647
    37
  Darwin* )
slouken@11647
    38
    darwin=true
slouken@11647
    39
    ;;
slouken@11647
    40
  MINGW* )
slouken@11647
    41
    msys=true
slouken@11647
    42
    ;;
slouken@11647
    43
esac
slouken@11647
    44
slouken@11647
    45
# Attempt to set APP_HOME
slouken@11647
    46
# Resolve links: $0 may be a link
slouken@11647
    47
PRG="$0"
slouken@11647
    48
# Need this for relative symlinks.
slouken@11647
    49
while [ -h "$PRG" ] ; do
slouken@11647
    50
    ls=`ls -ld "$PRG"`
slouken@11647
    51
    link=`expr "$ls" : '.*-> \(.*\)$'`
slouken@11647
    52
    if expr "$link" : '/.*' > /dev/null; then
slouken@11647
    53
        PRG="$link"
slouken@11647
    54
    else
slouken@11647
    55
        PRG=`dirname "$PRG"`"/$link"
slouken@11647
    56
    fi
slouken@11647
    57
done
slouken@11647
    58
SAVED="`pwd`"
slouken@11647
    59
cd "`dirname \"$PRG\"`/" >/dev/null
slouken@11647
    60
APP_HOME="`pwd -P`"
slouken@11647
    61
cd "$SAVED" >/dev/null
slouken@11647
    62
slouken@11647
    63
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
slouken@11647
    64
slouken@11647
    65
# Determine the Java command to use to start the JVM.
slouken@11647
    66
if [ -n "$JAVA_HOME" ] ; then
slouken@11647
    67
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
slouken@11647
    68
        # IBM's JDK on AIX uses strange locations for the executables
slouken@11647
    69
        JAVACMD="$JAVA_HOME/jre/sh/java"
slouken@11647
    70
    else
slouken@11647
    71
        JAVACMD="$JAVA_HOME/bin/java"
slouken@11647
    72
    fi
slouken@11647
    73
    if [ ! -x "$JAVACMD" ] ; then
slouken@11647
    74
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
slouken@11647
    75
slouken@11647
    76
Please set the JAVA_HOME variable in your environment to match the
slouken@11647
    77
location of your Java installation."
slouken@11647
    78
    fi
slouken@11647
    79
else
slouken@11647
    80
    JAVACMD="java"
slouken@11647
    81
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
slouken@11647
    82
slouken@11647
    83
Please set the JAVA_HOME variable in your environment to match the
slouken@11647
    84
location of your Java installation."
slouken@11647
    85
fi
slouken@11647
    86
slouken@11647
    87
# Increase the maximum file descriptors if we can.
slouken@11647
    88
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
slouken@11647
    89
    MAX_FD_LIMIT=`ulimit -H -n`
slouken@11647
    90
    if [ $? -eq 0 ] ; then
slouken@11647
    91
        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
slouken@11647
    92
            MAX_FD="$MAX_FD_LIMIT"
slouken@11647
    93
        fi
slouken@11647
    94
        ulimit -n $MAX_FD
slouken@11647
    95
        if [ $? -ne 0 ] ; then
slouken@11647
    96
            warn "Could not set maximum file descriptor limit: $MAX_FD"
slouken@11647
    97
        fi
slouken@11647
    98
    else
slouken@11647
    99
        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
slouken@11647
   100
    fi
slouken@11647
   101
fi
slouken@11647
   102
slouken@11647
   103
# For Darwin, add options to specify how the application appears in the dock
slouken@11647
   104
if $darwin; then
slouken@11647
   105
    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
slouken@11647
   106
fi
slouken@11647
   107
slouken@11647
   108
# For Cygwin, switch paths to Windows format before running java
slouken@11647
   109
if $cygwin ; then
slouken@11647
   110
    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
slouken@11647
   111
    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
slouken@11647
   112
    JAVACMD=`cygpath --unix "$JAVACMD"`
slouken@11647
   113
slouken@11647
   114
    # We build the pattern for arguments to be converted via cygpath
slouken@11647
   115
    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
slouken@11647
   116
    SEP=""
slouken@11647
   117
    for dir in $ROOTDIRSRAW ; do
slouken@11647
   118
        ROOTDIRS="$ROOTDIRS$SEP$dir"
slouken@11647
   119
        SEP="|"
slouken@11647
   120
    done
slouken@11647
   121
    OURCYGPATTERN="(^($ROOTDIRS))"
slouken@11647
   122
    # Add a user-defined pattern to the cygpath arguments
slouken@11647
   123
    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
slouken@11647
   124
        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
slouken@11647
   125
    fi
slouken@11647
   126
    # Now convert the arguments - kludge to limit ourselves to /bin/sh
slouken@11647
   127
    i=0
slouken@11647
   128
    for arg in "$@" ; do
slouken@11647
   129
        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
slouken@11647
   130
        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
slouken@11647
   131
slouken@11647
   132
        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
slouken@11647
   133
            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
slouken@11647
   134
        else
slouken@11647
   135
            eval `echo args$i`="\"$arg\""
slouken@11647
   136
        fi
slouken@11647
   137
        i=$((i+1))
slouken@11647
   138
    done
slouken@11647
   139
    case $i in
slouken@11647
   140
        (0) set -- ;;
slouken@11647
   141
        (1) set -- "$args0" ;;
slouken@11647
   142
        (2) set -- "$args0" "$args1" ;;
slouken@11647
   143
        (3) set -- "$args0" "$args1" "$args2" ;;
slouken@11647
   144
        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
slouken@11647
   145
        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
slouken@11647
   146
        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
slouken@11647
   147
        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
slouken@11647
   148
        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
slouken@11647
   149
        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
slouken@11647
   150
    esac
slouken@11647
   151
fi
slouken@11647
   152
slouken@11647
   153
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
slouken@11647
   154
function splitJvmOpts() {
slouken@11647
   155
    JVM_OPTS=("$@")
slouken@11647
   156
}
slouken@11647
   157
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
slouken@11647
   158
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
slouken@11647
   159
slouken@11647
   160
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"