blob: 5391e2da6ea452d86bd29e9f9b8dcb0cc22c76f3 (
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
72
73
74
75
76
77
78
79
80
81
|
package cbt
import java.io._
import java.time.LocalTime.now
import scala.collection.immutable.Seq
import scala.collection.JavaConverters._
import paths._
object CheckAlive{
def main(args: Array[String]): Unit = {
System.exit(33)
}
}
private[cbt] class Init(args: Array[String]) {
/**
* Raw parameters including their `-D` flag.
**/
val propsRaw: Seq[String] = args.toVector.filter(_.startsWith("-D"))
/**
* All arguments that weren't `-D` property declarations.
**/
val argsV: Seq[String] = args.toVector diff propsRaw
/**
* Parsed properties, as a map of keys to values.
**/
lazy val props = propsRaw
.map(_.drop(2).split("=")).map({
case Array(key, value) =>
key -> value
}).toMap ++ System.getProperties.asScala
val logger = new Logger(props.get("log"))
val cwd = argsV(0)
}
object Stage1 extends Stage1Base{
def mainClass = ("cbt.Stage2")
}
object AdminStage1 extends Stage1Base{
def mainClass = ("cbt.AdminStage2")
}
abstract class Stage1Base{
def mainClass: String
protected def newerThan( a: File, b: File ) ={
a.lastModified > b.lastModified
}
def main(args: Array[String]): Unit = {
val init = new Init(args)
val lib = new Stage1Lib(init.logger)
lib.logger.stage1(s"[$now] Stage1 start")
lib.logger.stage1("Stage1: after creating lib")
val cwd = args(0)
val src = stage2.listFiles.toVector.filter(_.isFile).filter(_.toString.endsWith(".scala"))
val changeIndicator = new File(stage2Target+"/cbt/Build.class")
lib.logger.stage1("before conditionally running zinc to recompile CBT")
if( src.exists(newerThan(_, changeIndicator)) ) {
val stage1Classpath = CbtDependency(init.logger).dependencyClasspath
lib.logger.stage1("cbt.lib has changed. Recompiling with cp: "+stage1Classpath)
lib.zinc( true, src, stage2Target, stage1Classpath )( zincVersion = "0.3.9", scalaVersion = constants.scalaVersion )
}
lib.logger.stage1(s"[$now] calling CbtDependency.classLoader")
lib.logger.stage1(s"[$now] Run Stage2")
lib.runMain( mainClass, cwd +: args.drop(1).toVector, CbtDependency(init.logger).classLoader )
lib.logger.stage1(s"[$now] Stage1 end")
}
}
|