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