Skip to content

Commit cf0212f

Browse files
committed
Improve fromtasty.Debug
1 parent 19c13f3 commit cf0212f

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

compiler/src/dotty/tools/dotc/fromtasty/Debug.scala

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package fromtasty
44

55
import scala.util.control.NonFatal
66

7-
import dotty.tools.io.Path
7+
import dotty.tools.io.Directory
88

99
import java.nio.file.{Files, Paths}
1010

@@ -15,41 +15,45 @@ object Debug {
1515
// see <https://groups.google.com/forum/#!topic/scala-user/kte6nak-zPM>.
1616
val _ = NonFatal
1717

18-
19-
println("From tasty debug driver")
2018
assert(!args.contains("-d"))
2119

22-
val fromSourcesOut = Files.createTempDirectory(Paths.get("out").toAbsolutePath, "from-sources-tmp")
20+
val tmpOut = Files.createTempDirectory(Paths.get("out").toAbsolutePath, "from-tasty-tmp")
21+
22+
val fromSourcesOut = Files.createDirectory(tmpOut.resolve("from-source"))
2323

24-
println(s"Compiling scala to sources to $fromSourcesOut")
24+
println(s"Compiling .scala")
2525
val compilation1 = dotc.Main.process("-d" +: fromSourcesOut.toString +: args)
2626

2727
if (compilation1.hasErrors) {
2828
println("Failed compilation from sources")
2929
sys.exit(1)
3030
}
3131

32-
val fromTastyOut = Files.createTempDirectory(Paths.get("out").toAbsolutePath, "from-tasty-tmp")
32+
val fromTastyOut = Files.createDirectory(tmpOut.resolve("from-tasty"))
3333

3434
val ext = "hasTasty"
35-
val classes = Path(fromSourcesOut).walk.filter(x => x.isFile && x.extension == ext).map { x =>
35+
val classes = Directory(fromSourcesOut).walk.filter(x => x.isFile && x.extension == ext).map { x =>
3636
val source = x.toString
3737
source.substring(fromSourcesOut.toString.length + 1, source.length - ext.length - 1).replace('/', '.')
3838
}.toList
3939

40-
val fromTastyArgs =
41-
"-from-tasty" :: insertClasspathInArgs(args.filterNot(_.endsWith(".scala")).toList, fromSourcesOut.toString) ::: classes
40+
val fromTastyArgs = {
41+
"-from-tasty" ::
42+
"-d" :: fromTastyOut.toString ::
43+
insertClasspathInArgs(args.filterNot(_.endsWith(".scala")).toList, fromSourcesOut.toString) :::
44+
classes
45+
}
4246

43-
println(s"Compiling TASTY to sources from $fromSourcesOut to $fromTastyOut")
47+
println(s"Compiling TASTY")
4448
val compilation2 = dotc.Main.process(fromTastyArgs.toArray)
4549

4650
if (compilation2.hasErrors) {
47-
println("Failed compilation from sources")
51+
println("Failed compilation from TASTY")
52+
println("Compilation input: " + fromSourcesOut)
4853
sys.exit(1)
4954
}
5055

51-
Path(fromSourcesOut).deleteRecursively()
52-
Path(fromTastyOut).deleteRecursively()
56+
Directory(tmpOut).deleteRecursively()
5357
}
5458

5559
private def insertClasspathInArgs(args: List[String], cp: String): List[String] = {

0 commit comments

Comments
 (0)