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