Skip to content

Commit ce57b71

Browse files
authored
chore: drop scala_legacy and MainGenericRunner (#24244)
With everything that is happening for `3.8.0`, I believe it is now time to remove the old runner infrastructure and the `scala_legacy` script too. `scala-cli` has been shipped with every release of Scala since `3.5.0`. In preparation for #24243
2 parents ea1d344 + 420af61 commit ce57b71

File tree

11 files changed

+15
-634
lines changed

11 files changed

+15
-634
lines changed

bin/scalaQ

Lines changed: 0 additions & 6 deletions
This file was deleted.

compiler/src/dotty/tools/MainGenericCompiler.scala

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,20 @@ object MainGenericCompiler {
8787

8888
val classpathSeparator: String = File.pathSeparator
8989

90+
def processClasspath(cp: String, tail: List[String]): (List[String], List[String]) =
91+
val cpEntries = cp.split(classpathSeparator).toList
92+
val singleEntryClasspath: Boolean = cpEntries.take(2).size == 1
93+
val globdir: String = if singleEntryClasspath then cp.replaceAll("[\\\\/][^\\\\/]*$", "") else "" // slash/backslash agnostic
94+
def validGlobbedJar(s: String): Boolean = s.startsWith(globdir) && ((s.toLowerCase.endsWith(".jar") || s.toLowerCase.endsWith(".zip")))
95+
if singleEntryClasspath && validGlobbedJar(cpEntries.head) then
96+
// reassemble globbed wildcard classpath
97+
// globdir is wildcard directory for globbed jar files, reconstruct the intended classpath
98+
val cpJars = tail.takeWhile( f => validGlobbedJar(f) )
99+
val remainingArgs = tail.drop(cpJars.size)
100+
(remainingArgs, cpEntries ++ cpJars)
101+
else
102+
(tail, cpEntries)
103+
90104
@sharable val javaOption = raw"""-J(.*)""".r
91105
@sharable val javaPropOption = raw"""-D(.+?)=(.?)""".r
92106
@tailrec
@@ -122,11 +136,10 @@ object MainGenericCompiler {
122136
case "-with-compiler" :: tail =>
123137
process(tail, settings.withCompiler)
124138
case ("-cp" | "-classpath" | "--class-path") :: cp :: tail =>
125-
val (tailargs, newEntries) = MainGenericRunner.processClasspath(cp, tail)
139+
val (tailargs, newEntries) = processClasspath(cp, tail)
126140
process(tailargs, settings.copy(classPath = settings.classPath ++ newEntries.filter(_.nonEmpty)))
127141
case "-Oshort" :: tail =>
128142
// Nothing is to be done here. Request that the user adds the relevant flags manually.
129-
// i.e this has no effect when MainGenericRunner is invoked programatically.
130143
val addTC="-XX:+TieredCompilation"
131144
val tStopAtLvl="-XX:TieredStopAtLevel=1"
132145
println(s"ignoring deprecated -Oshort flag, please add `-J$addTC` and `-J$tStopAtLvl` flags manually")

compiler/src/dotty/tools/MainGenericRunner.scala

Lines changed: 0 additions & 297 deletions
This file was deleted.

0 commit comments

Comments
 (0)