@@ -22,33 +22,40 @@ class PipelineMainClass {
22
22
def process (args : Array [String ]): Boolean = {
23
23
reporter = new ConsoleReporter (new Settings (scalacError))
24
24
25
- def commandFor (argFileArg : String ): CompilerCommand = {
25
+ def commandFor (argFileArg : String ): Task = {
26
26
val ss = new Settings (scalacError)
27
- new CompilerCommand (args.toList , ss)
27
+ Task (argFileArg, new CompilerCommand (( " @ " + argFileArg) :: Nil , ss) )
28
28
}
29
- val projects : List [CompilerCommand ] = args.toList.map(commandFor)
30
- val produces = mutable.HashMap [Path , CompilerCommand ]()
29
+ val projects : List [Task ] = args.toList.map(commandFor)
30
+ val produces = mutable.HashMap [Path , Task ]()
31
31
for (p <- projects) {
32
- val outputDir = p.settings.outputDirs.getSingleOutput.get.file.toPath.toAbsolutePath.normalize()
32
+ val outputDir = p.command. settings.outputDirs.getSingleOutput.get.file.toPath.toAbsolutePath.normalize()
33
33
produces(outputDir) = p
34
34
}
35
- val dependsOn = mutable.HashMap [CompilerCommand , List [CompilerCommand ]]()
35
+ val dependsOn = mutable.HashMap [Task , List [Task ]]()
36
36
for (p <- projects) {
37
- val value : Seq [String ] = ClassPath .expandPath(p.settings.classpath.value, expandStar = true )
37
+ val value : Seq [String ] = ClassPath .expandPath(p.command. settings.classpath.value, expandStar = true )
38
38
dependsOn(p) = value.flatMap(s => produces.get(Paths .get(s).toAbsolutePath.normalize())).toList
39
39
}
40
40
var toProcess = projects.toList
41
- val done = mutable.HashSet [CompilerCommand ]()
41
+ val done = mutable.HashSet [Task ]()
42
+ var round = 0
42
43
while (toProcess.nonEmpty) {
44
+ round += 1
43
45
val (nextRound, blocked) = toProcess.partition(x => dependsOn.getOrElse(x, Nil ).forall(done))
46
+ if (nextRound.isEmpty) throw new RuntimeException (" cyclic dependency" )
44
47
toProcess = blocked
45
48
for (p <- nextRound) {
46
- if (! compile(p)) return false
49
+ println(s " Round # $round: ${p.argsFile}" )
50
+ if (! compile(p.command)) return false
47
51
done += p
48
52
}
49
53
}
50
54
true
51
55
}
56
+ private case class Task (argsFile : String , command : CompilerCommand ) {
57
+ override def toString : String = argsFile
58
+ }
52
59
53
60
def compile (command : CompilerCommand ): Boolean = {
54
61
val compiler = newCompiler(command.settings)
0 commit comments