@@ -4,7 +4,7 @@ package fromtasty
4
4
5
5
import scala .util .control .NonFatal
6
6
7
- import dotty .tools .io .Path
7
+ import dotty .tools .io .Directory
8
8
9
9
import java .nio .file .{Files , Paths }
10
10
@@ -15,41 +15,45 @@ object Debug {
15
15
// see <https://groups.google.com/forum/#!topic/scala-user/kte6nak-zPM>.
16
16
val _ = NonFatal
17
17
18
-
19
- println(" From tasty debug driver" )
20
18
assert(! args.contains(" -d" ))
21
19
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" ))
23
23
24
- println(s " Compiling scala to sources to $fromSourcesOut " )
24
+ println(s " Compiling . scala " )
25
25
val compilation1 = dotc.Main .process(" -d" +: fromSourcesOut.toString +: args)
26
26
27
27
if (compilation1.hasErrors) {
28
28
println(" Failed compilation from sources" )
29
29
sys.exit(1 )
30
30
}
31
31
32
- val fromTastyOut = Files .createTempDirectory( Paths .get( " out " ).toAbsolutePath, " from-tasty-tmp " )
32
+ val fromTastyOut = Files .createDirectory(tmpOut.resolve( " from-tasty" ) )
33
33
34
34
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 =>
36
36
val source = x.toString
37
37
source.substring(fromSourcesOut.toString.length + 1 , source.length - ext.length - 1 ).replace('/' , '.' )
38
38
}.toList
39
39
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
+ }
42
46
43
- println(s " Compiling TASTY to sources from $fromSourcesOut to $fromTastyOut " )
47
+ println(s " Compiling TASTY " )
44
48
val compilation2 = dotc.Main .process(fromTastyArgs.toArray)
45
49
46
50
if (compilation2.hasErrors) {
47
- println(" Failed compilation from sources" )
51
+ println(" Failed compilation from TASTY" )
52
+ println(" Compilation input: " + fromSourcesOut)
48
53
sys.exit(1 )
49
54
}
50
55
51
- Path (fromSourcesOut).deleteRecursively()
52
- Path (fromTastyOut).deleteRecursively()
56
+ Directory (tmpOut).deleteRecursively()
53
57
}
54
58
55
59
private def insertClasspathInArgs (args : List [String ], cp : String ): List [String ] = {
0 commit comments