blob: 3512d17bb8e3f2722221cad2db5ea1dcece37987 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
package scala.tools.nsc
package interactive
import scala.collection._
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
import util.FakePos
import dependencies._
import io.AbstractFile
trait BuildManager {
/** Add the given source files to the managed build process. */
def addSourceFiles(files: Set[AbstractFile])
/** Remove the given files from the managed build process. */
def removeFiles(files: Set[AbstractFile])
/** The given files have been modified by the user. Recompile
* them and their dependent files.
*/
def update(added: Set[AbstractFile], removed: Set[AbstractFile])
/** Notification that the supplied set of files is being built */
def buildingFiles(included: Set[AbstractFile]) {}
/** Load saved dependency information. */
def loadFrom(file: AbstractFile, toFile: String => AbstractFile) : Boolean
/** Save dependency information to `file'. */
def saveTo(file: AbstractFile, fromFile: AbstractFile => String)
def compiler: scala.tools.nsc.Global
}
/** Simple driver for testing the build manager. It presents
* the user to a 'resident compiler' prompt. Each line is
* interpreted as a set of files that have changed. The builder
* then derives the dependent files and recompiles them.
*/
object BuildManagerTest extends EvalLoop {
def prompt = "builder > "
def error(msg: String) {
println(msg + "\n scalac -help gives more information")
}
def main(args: Array[String]) {
implicit def filesToSet(fs: List[String]): Set[AbstractFile] =
Set.empty ++ (fs map AbstractFile.getFile)
val settings = new Settings(error)
val command = new CompilerCommand(List.fromArray(args), settings, error, false)
// settings.make.value = "off"
// val buildManager: BuildManager = new SimpleBuildManager(settings)
val buildManager: BuildManager = new RefinedBuildManager(settings)
buildManager.addSourceFiles(command.files)
// enter resident mode
loop { line =>
val args = List.fromString(line, ' ')
val command = new CompilerCommand(args, new Settings(error), error, true)
buildManager.update(command.files, Set.empty)
}
}
}
|