Skip to content

Commit 5c293d0

Browse files
felixmuldersmarter
authored andcommitted
Add repl command
1 parent 7879d0f commit 5c293d0

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
@@ -26,7 +27,12 @@ object DottyBuild extends Build {
2627
// "-XX:+HeapDumpOnOutOfMemoryError", "-Xmx1g", "-Xss2m"
2728
)
2829

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

3137
override def settings: Seq[Setting[_]] = {
3238
super.settings ++ Seq(
@@ -68,6 +74,7 @@ object DottyBuild extends Build {
6874
dependsOn(`dotty-library`).
6975
dependsOn(`dotty-interfaces`).
7076
settings(
77+
addCommandAlias("repl", "dotty-compiler/repl") ++
7178
addCommandAlias(
7279
"partest",
7380
";packageAll" +
@@ -151,14 +158,24 @@ object DottyBuild extends Build {
151158
// enable improved incremental compilation algorithm
152159
incOptions := incOptions.value.withNameHashing(true),
153160

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

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

0 commit comments

Comments
 (0)