Skip to content

Commit 3b54fd2

Browse files
committed
Add repl command
1 parent 46a455c commit 3b54fd2

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

project/Build.scala

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sbt.Keys._
22
import sbt._
3+
import complete.DefaultParsers._
34
import java.io.{ RandomAccessFile, File }
45
import java.nio.channels.FileLock
56
import scala.reflect.io.Path
@@ -25,7 +26,12 @@ object DottyBuild extends Build {
2526
// "-XX:+HeapDumpOnOutOfMemoryError", "-Xmx1g", "-Xss2m"
2627
)
2728

28-
lazy val packageAll = taskKey[Unit]("Package everything needed to run tests")
29+
// Packages all subprojects to their jars
30+
lazy val packageAll =
31+
taskKey[Map[String, String]]("Package everything needed to run tests")
32+
33+
// Spawns a repl with the correct classpath
34+
lazy val repl = inputKey[Unit]("run the REPL with correct classpath")
2935

3036
override def settings: Seq[Setting[_]] = {
3137
super.settings ++ Seq(
@@ -67,6 +73,7 @@ object DottyBuild extends Build {
6773
dependsOn(`dotty-library`).
6874
dependsOn(`dotty-interfaces`).
6975
settings(
76+
addCommandAlias("repl", "dotty-compiler/repl") ++
7077
addCommandAlias(
7178
"partest",
7279
";packageAll" +
@@ -150,14 +157,24 @@ object DottyBuild extends Build {
150157
// enable improved incremental compilation algorithm
151158
incOptions := incOptions.value.withNameHashing(true),
152159

153-
160+
// packageAll packages all and then returns a map with the abs location
154161
packageAll := {
155-
val p1 = (packageBin in (`dotty-interfaces`, Compile)).value
156-
val p2 = (packageBin in Compile).value
157-
val p3 = (packageBin in (`dotty-library`, Compile)).value
158-
val p4 = (packageBin in Test).value
162+
Map(
163+
"dotty-interfaces" -> (packageBin in (`dotty-interfaces`, Compile)).value,
164+
"dotty-compiler" -> (packageBin in Compile).value,
165+
"dotty-library" -> (packageBin in (`dotty-library`, Compile)).value,
166+
"dotty-compiler-test" -> (packageBin in Test).value
167+
) map { case (k, v) => (k, v.getAbsolutePath) }
159168
},
160169

170+
repl := Def.inputTaskDyn {
171+
val args: Seq[String] = spaceDelimited("<arg>").parsed
172+
val dottyLib = packageAll.value("dotty-library")
173+
(runMain in Compile).toTask(
174+
s" dotty.tools.dotc.repl.Main -classpath $dottyLib " + args.mkString(" ")
175+
)
176+
}.evaluated,
177+
161178
// enable verbose exception messages for JUnit
162179
testOptions in Test += Tests.Argument(
163180
TestFrameworks.JUnit, "-a", "-v",

0 commit comments

Comments
 (0)