@@ -22,33 +22,40 @@ class PipelineMainClass {
2222 def process (args : Array [String ]): Boolean = {
2323 reporter = new ConsoleReporter (new Settings (scalacError))
2424
25- def commandFor (argFileArg : String ): CompilerCommand = {
25+ def commandFor (argFileArg : String ): Task = {
2626 val ss = new Settings (scalacError)
27- new CompilerCommand (args.toList , ss)
27+ Task (argFileArg, new CompilerCommand (( " @ " + argFileArg) :: Nil , ss) )
2828 }
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 ]()
3131 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()
3333 produces(outputDir) = p
3434 }
35- val dependsOn = mutable.HashMap [CompilerCommand , List [CompilerCommand ]]()
35+ val dependsOn = mutable.HashMap [Task , List [Task ]]()
3636 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 )
3838 dependsOn(p) = value.flatMap(s => produces.get(Paths .get(s).toAbsolutePath.normalize())).toList
3939 }
4040 var toProcess = projects.toList
41- val done = mutable.HashSet [CompilerCommand ]()
41+ val done = mutable.HashSet [Task ]()
42+ var round = 0
4243 while (toProcess.nonEmpty) {
44+ round += 1
4345 val (nextRound, blocked) = toProcess.partition(x => dependsOn.getOrElse(x, Nil ).forall(done))
46+ if (nextRound.isEmpty) throw new RuntimeException (" cyclic dependency" )
4447 toProcess = blocked
4548 for (p <- nextRound) {
46- if (! compile(p)) return false
49+ println(s " Round # $round: ${p.argsFile}" )
50+ if (! compile(p.command)) return false
4751 done += p
4852 }
4953 }
5054 true
5155 }
56+ private case class Task (argsFile : String , command : CompilerCommand ) {
57+ override def toString : String = argsFile
58+ }
5259
5360 def compile (command : CompilerCommand ): Boolean = {
5461 val compiler = newCompiler(command.settings)
0 commit comments