@@ -116,9 +116,6 @@ object Build {
116116 // Run tests with filter through vulpix test suite
117117 val testCompilation = inputKey[Unit ](" runs integration test with the supplied filter" )
118118
119- // Spawns a repl with the correct classpath
120- val repl = inputKey[Unit ](" run the REPL with correct classpath" )
121-
122119 // Used to compile files similar to ./bin/scalac script
123120 val scalac = inputKey[Unit ](" run the compiler using the correct classpath, or the user supplied classpath" )
124121
@@ -171,7 +168,9 @@ object Build {
171168
172169 // enable verbose exception messages for JUnit
173170 testOptions in Test += Tests .Argument (TestFrameworks .JUnit , " -a" , " -v" ),
174- )
171+ ) ++
172+ // Spawns a repl with the correct classpath
173+ addCommandAlias(" repl" , " scala3-compiler-bootstrapped/console" )
175174
176175 // Settings shared globally (scoped in Global). Used in build.sbt
177176 lazy val globalSettings = Def .settings(
@@ -387,9 +386,6 @@ object Build {
387386
388387 // Settings shared between scala3-compiler and scala3-compiler-bootstrapped
389388 lazy val commonDottyCompilerSettings = Seq (
390- // set system in/out for repl
391- connectInput in run := true ,
392-
393389 // Generate compiler.properties, used by sbt
394390 resourceGenerators in Compile += Def .task {
395391 import java .util ._
@@ -531,8 +527,46 @@ object Build {
531527 },
532528
533529 run := scalac.evaluated,
534- scalac := runCompilerMain().evaluated,
535- repl := runCompilerMain(repl = true ).evaluated,
530+ scalac := Def .inputTaskDyn {
531+ val log = streams.value.log
532+ val externalDeps = externalCompilerClasspathTask.value
533+ val jars = packageAll.value
534+ val scalaLib = findArtifactPath(externalDeps, " scala-library" )
535+ val dottyLib = jars(" scala3-library" )
536+ val dottyCompiler = jars(" scala3-compiler" )
537+ val args0 : List [String ] = spaceDelimited(" <arg>" ).parsed.toList
538+ val decompile = args0.contains(" -decompile" )
539+ val printTasty = args0.contains(" -print-tasty" )
540+ val debugFromTasty = args0.contains(" -Ythrough-tasty" )
541+ val args = args0.filter(arg => arg != " -repl" && arg != " -decompile" &&
542+ arg != " -with-compiler" && arg != " -Ythrough-tasty" )
543+
544+ val main =
545+ if (decompile || printTasty) " dotty.tools.dotc.decompiler.Main"
546+ else if (debugFromTasty) " dotty.tools.dotc.fromtasty.Debug"
547+ else " dotty.tools.dotc.Main"
548+
549+ var extraClasspath = Seq (scalaLib, dottyLib)
550+
551+ if ((decompile || printTasty) && ! args.contains(" -classpath" ))
552+ extraClasspath ++= Seq (" ." )
553+
554+ if (args0.contains(" -with-compiler" )) {
555+ if (scalaVersion.value == referenceVersion) {
556+ log.error(" -with-compiler should only be used with a bootstrapped compiler" )
557+ }
558+ val dottyInterfaces = jars(" scala3-interfaces" )
559+ val dottyStaging = jars(" scala3-staging" )
560+ val dottyTastyInspector = jars(" scala3-tasty-inspector" )
561+ val tastyCore = jars(" tasty-core" )
562+ val asm = findArtifactPath(externalDeps, " scala-asm" )
563+ extraClasspath ++= Seq (dottyCompiler, dottyInterfaces, asm, dottyStaging, dottyTastyInspector, tastyCore)
564+ }
565+
566+ val fullArgs = main :: insertClasspathInArgs(args, extraClasspath.mkString(File .pathSeparator))
567+
568+ (runMain in Compile ).toTask(fullArgs.mkString(" " , " " , " " ))
569+ }.evaluated,
536570
537571 /* Add the sources of scalajs-ir.
538572 * To guarantee that dotty can bootstrap without depending on a version
@@ -569,48 +603,6 @@ object Build {
569603 }.taskValue,
570604 )
571605
572- def runCompilerMain (repl : Boolean = false ) = Def .inputTaskDyn {
573- val log = streams.value.log
574- val externalDeps = externalCompilerClasspathTask.value
575- val jars = packageAll.value
576- val scalaLib = findArtifactPath(externalDeps, " scala-library" )
577- val dottyLib = jars(" scala3-library" )
578- val dottyCompiler = jars(" scala3-compiler" )
579- val args0 : List [String ] = spaceDelimited(" <arg>" ).parsed.toList
580- val decompile = args0.contains(" -decompile" )
581- val printTasty = args0.contains(" -print-tasty" )
582- val debugFromTasty = args0.contains(" -Ythrough-tasty" )
583- val args = args0.filter(arg => arg != " -repl" && arg != " -decompile" &&
584- arg != " -with-compiler" && arg != " -Ythrough-tasty" )
585-
586- val main =
587- if (repl) " dotty.tools.repl.Main"
588- else if (decompile || printTasty) " dotty.tools.dotc.decompiler.Main"
589- else if (debugFromTasty) " dotty.tools.dotc.fromtasty.Debug"
590- else " dotty.tools.dotc.Main"
591-
592- var extraClasspath = Seq (scalaLib, dottyLib)
593-
594- if ((decompile || printTasty) && ! args.contains(" -classpath" ))
595- extraClasspath ++= Seq (" ." )
596-
597- if (args0.contains(" -with-compiler" )) {
598- if (scalaVersion.value == referenceVersion) {
599- log.error(" -with-compiler should only be used with a bootstrapped compiler" )
600- }
601- val dottyInterfaces = jars(" scala3-interfaces" )
602- val dottyStaging = jars(" scala3-staging" )
603- val dottyTastyInspector = jars(" scala3-tasty-inspector" )
604- val tastyCore = jars(" tasty-core" )
605- val asm = findArtifactPath(externalDeps, " scala-asm" )
606- extraClasspath ++= Seq (dottyCompiler, dottyInterfaces, asm, dottyStaging, dottyTastyInspector, tastyCore)
607- }
608-
609- val fullArgs = main :: insertClasspathInArgs(args, extraClasspath.mkString(File .pathSeparator))
610-
611- (runMain in Compile ).toTask(fullArgs.mkString(" " , " " , " " ))
612- }
613-
614606 def insertClasspathInArgs (args : List [String ], cp : String ): List [String ] = {
615607 val (beforeCp, fromCp) = args.span(_ != " -classpath" )
616608 val classpath = fromCp.drop(1 ).headOption.fold(cp)(_ + File .pathSeparator + cp)
0 commit comments