|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +if [ -z "$PROG_HOME" ] ; then |
| 4 | + ## resolve links - $0 may be a link to PROG_HOME |
| 5 | + PRG="$0" |
| 6 | + |
| 7 | + # need this for relative symlinks |
| 8 | + while [ -h "$PRG" ] ; do |
| 9 | + ls=`ls -ld "$PRG"` |
| 10 | + link=`expr "$ls" : '.*-> \(.*\)$'` |
| 11 | + if expr "$link" : '/.*' > /dev/null; then |
| 12 | + PRG="$link" |
| 13 | + else |
| 14 | + PRG="`dirname "$PRG"`/$link" |
| 15 | + fi |
| 16 | + done |
| 17 | + |
| 18 | + saveddir=`pwd` |
| 19 | + |
| 20 | + PROG_HOME=`dirname "$PRG"`/.. |
| 21 | + |
| 22 | + # make it fully qualified |
| 23 | + PROG_HOME=`cd "$PROG_HOME" && pwd` |
| 24 | + |
| 25 | + cd "$saveddir" |
| 26 | +fi |
| 27 | + |
| 28 | +source "$PROG_HOME/bin/common" |
| 29 | + |
| 30 | +default_java_opts="-Xmx768m -Xms768m" |
| 31 | +bootcp=true |
| 32 | + |
| 33 | +PROG_NAME=dotty.tools.dottydoc.Main |
| 34 | + |
| 35 | +addJava () { |
| 36 | + java_args+=("$1") |
| 37 | +} |
| 38 | +addScala () { |
| 39 | + scala_args+=("$1") |
| 40 | +} |
| 41 | +addResidual () { |
| 42 | + residual_args+=("$1") |
| 43 | +} |
| 44 | + |
| 45 | +classpathArgs () { |
| 46 | + # echo "dotty-compiler: $DOTTY_COMP" |
| 47 | + # echo "dotty-interface: $DOTTY_INTF" |
| 48 | + # echo "dotty-library: $DOTTY_LIB" |
| 49 | + # echo "dotty-doc: $DOTTY_DOC" |
| 50 | + # echo "scala-asm: $SCALA_ASM" |
| 51 | + # echo "scala-lib: $SCALA_LIB" |
| 52 | + # echo "scala-xml: $SCALA_XML" |
| 53 | + # echo "sbt-intface: $SBT_INTF" |
| 54 | + |
| 55 | + toolchain="" |
| 56 | + toolchain+="$SCALA_LIB$PSEP" |
| 57 | + toolchain+="$DOTTY_LIB$PSEP" |
| 58 | + toolchain+="$SCALA_ASM$PSEP" |
| 59 | + toolchain+="$SBT_INTF$PSEP" |
| 60 | + toolchain+="$DOTTY_INTF$PSEP" |
| 61 | + toolchain+="$DOTTY_LIB$PSEP" |
| 62 | + toolchain+="$DOTTY_COMP$PSEP" |
| 63 | + toolchain+="$DOTTY_DOC" |
| 64 | + |
| 65 | + if [[ -n "$bootcp" ]]; then |
| 66 | + jvm_cp_args="-Xbootclasspath/a:$toolchain" |
| 67 | + else |
| 68 | + jvm_cp_args="-classpath $toolchain" |
| 69 | + fi |
| 70 | +} |
| 71 | + |
| 72 | +while [[ $# -gt 0 ]]; do |
| 73 | +case "$1" in |
| 74 | + --) shift; for arg; do addResidual "$arg"; done; set -- ;; |
| 75 | + -h|-help) help=true && shift ;; |
| 76 | + -v|-verbose) verbose=true && shift ;; |
| 77 | + -debug) debug=true && shift ;; |
| 78 | + -q|-quiet) quiet=true && shift ;; |
| 79 | + |
| 80 | + # Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222 |
| 81 | + -Oshort) addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;; |
| 82 | + -repl) PROG_NAME="$ReplMain" && shift ;; |
| 83 | + -tasty) PROG_NAME="$FromTasty" && shift ;; |
| 84 | + -compile) PROG_NAME="$CompilerMain" && shift ;; |
| 85 | + -run) PROG_NAME="$ReplMain" && shift ;; |
| 86 | + -bootcp) bootcp=true && shift ;; |
| 87 | + -nobootcp) unset bootcp && shift ;; |
| 88 | + -colors) colors=true && shift ;; |
| 89 | + -no-colors) unset colors && shift ;; |
| 90 | + -jrebel) jrebel=true && shift ;; |
| 91 | + -no-jrebel) unset jrebel && shift ;; |
| 92 | + |
| 93 | + -toolcp) require_arg classpath "$1" "$2" && toolcp="$2" && shift 2 ;; |
| 94 | + |
| 95 | + # break out -D and -J options and add them to JAVA_OPTS as well |
| 96 | + # so they reach the JVM in time to do some good. The -D options |
| 97 | + # will be available as system properties. |
| 98 | + -D*) addJava "$1" && addScala "$1" && shift ;; |
| 99 | + -J*) addJava "${1:2}" && addScala "$1" && shift ;; |
| 100 | + *) addResidual "$1" && shift ;; |
| 101 | + esac |
| 102 | +done |
| 103 | + |
| 104 | +classpathArgs |
| 105 | + |
| 106 | +eval exec "\"$JAVACMD\"" \ |
| 107 | + ${JAVA_OPTS:-$default_java_opts} \ |
| 108 | + "${java_args[@]}" \ |
| 109 | + "$jvm_cp_args" \ |
| 110 | + -Dscala.usejavacp=true \ |
| 111 | + "$PROG_NAME" \ |
| 112 | + "${scala_args[@]}" \ |
| 113 | + "${residual_args[@]}" |
| 114 | +exit $? |
0 commit comments