Skip to content

avoid duplicate call to dist/bin/common via refactored scalac #12197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 27, 2021
Merged
5 changes: 2 additions & 3 deletions compiler/test-resources/repl/defaultClassloader
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
scala> val d: java.sql.Date = new java.sql.Date(100L)
val d: java.sql.Date = 1970-01-01

scala> val d: Long = (new java.sql.Date(100L)).getTime
val d: Long = 100
4 changes: 3 additions & 1 deletion compiler/test/dotty/tools/scripting/ClasspathTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ClasspathTests:
val packBinDir = "dist/target/pack/bin"
val scalaCopy = makeTestableScriptCopy("scala")
val scalacCopy = makeTestableScriptCopy("scalac")
val commonCopy = makeTestableScriptCopy("common")

// only interested in classpath test scripts
def testFiles = scripts("/scripting").filter { _.getName.matches("classpath.*[.]sc") }
Expand All @@ -38,7 +39,8 @@ class ClasspathTests:
if Files.exists(scriptPath) then
val lines = Files.readAllLines(scriptPath).asScala.map {
_.replaceAll("/scalac", "/scalac-copy").
replaceFirst("^eval(.*JAVACMD.*)", "echo $1")
replaceAll("/common", "/common-copy").
replaceFirst("^ *eval(.*JAVACMD.*)", "echo $1")
}
val bytes = (lines.mkString("\n")+"\n").getBytes
Files.write(scriptCopy, bytes)
Expand Down
72 changes: 65 additions & 7 deletions dist/bin/common
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ case "`uname`" in
esac

unset CYGPATHCMD
if [[ $cygwin || $mingw || $msys ]]; then
if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
# ConEmu terminal is incompatible with jna-5.*.jar
[[ ($CONEMUANSI || $ConEmuANSI) ]] && conemu=true
[[ (${CONEMUANSI-} || ${ConEmuANSI-}) ]] && conemu=true
# cygpath is used by various windows shells: cygwin, git-sdk, gitbash, msys, etc.
CYGPATHCMD=`which cygpath 2>/dev/null`
case "$TERM" in
rxvt* | xterm* | cygwin*)
stty -icanon min 1 -echo
SCALA_OPTS="$SCALA_OPTS -Djline.terminal=unix"
JAVA_OPTS="$JAVA_OPTS -Djline.terminal=unix"
;;
esac
fi
Expand Down Expand Up @@ -111,14 +111,14 @@ CLASSPATH_SUFFIX=""
PSEP=":"

# translate paths to Windows-mixed format before running java
if [ -n "$CYGPATHCMD" ]; then
[ -n "$PROG_HOME" ] &&
if [ -n "${CYGPATHCMD-}" ]; then
[ -n "${PROG_HOME-}" ] &&
PROG_HOME=`"$CYGPATHCMD" -am "$PROG_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`"$CYGPATHCMD" -am "$JAVA_HOME"`
CLASSPATH_SUFFIX=";"
PSEP=";"
elif [[ $mingw || $msys ]]; then
elif [[ ${mingw-} || ${msys-} ]]; then
# For Mingw / Msys, convert paths from UNIX format before anything is touched
[ -n "$PROG_HOME" ] &&
PROG_HOME="`(cd "$PROG_HOME"; pwd -W | sed 's|/|\\\\|g')`"
Expand Down Expand Up @@ -155,8 +155,66 @@ SBT_INTF=$(find_lib "*compiler-interface*")
JLINE_READER=$(find_lib "*jline-reader-3*")
JLINE_TERMINAL=$(find_lib "*jline-terminal-3*")
JLINE_TERMINAL_JNA=$(find_lib "*jline-terminal-jna-3*")
[[ $conemu ]] || JNA=$(find_lib "*jna-5*")
[[ ${conemu-} ]] || JNA=$(find_lib "*jna-5*")

# debug

DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005

classpathArgs () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename it to reflect that it's used for the compiler JVM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liufengyun - good idea. I didn't see this until after I pushed changes, so we'll have to do that when we update the two other calls to bin/scalac.

# echo "dotty-compiler: $DOTTY_COMP"
# echo "dotty-interface: $DOTTY_INTF"
# echo "dotty-library: $DOTTY_LIB"
# echo "tasty-core: $TASTY_CORE"
# echo "scala-asm: $SCALA_ASM"
# echo "scala-lib: $SCALA_LIB"
# 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_COMP$PSEP"
toolchain+="$TASTY_CORE$PSEP"
toolchain+="$DOTTY_STAGING$PSEP"
toolchain+="$DOTTY_TASTY_INSPECTOR$PSEP"

# jine
toolchain+="$JLINE_READER$PSEP"
toolchain+="$JLINE_TERMINAL$PSEP"
toolchain+="$JLINE_TERMINAL_JNA$PSEP"
[ -n "${JNA-}" ] && toolchain+="$JNA$PSEP"

if [ -n "${jvm_cp_args-}" ]; then
jvm_cp_args="$toolchain$jvm_cp_args"
else
jvm_cp_args="$toolchain$PSEP"
fi
}

default_java_opts="-Xmx768m -Xms768m"

CompilerMain=dotty.tools.dotc.Main
DecompilerMain=dotty.tools.dotc.decompiler.Main
ReplMain=dotty.tools.repl.Main
ScriptingMain=dotty.tools.scripting.Main

declare -a java_args
declare -a scala_args
declare -a residual_args
declare -a script_args

addJava () {
java_args+=("'$1'")
}
addScala () {
scala_args+=("'$1'")
}
addResidual () {
residual_args+=("'$1'")
}
addScript () {
script_args+=("'$1'")
}
Loading