Skip to content

Commit ed1b1b1

Browse files
committed
Fix for reflection. Review/Use by @adriaanm
1 parent 87e23f5 commit ed1b1b1

File tree

3 files changed

+53
-14
lines changed

3 files changed

+53
-14
lines changed

project/Build.scala

+10-8
Original file line numberDiff line numberDiff line change
@@ -177,20 +177,20 @@ object ScalaBuild extends Build with Layers {
177177
}
178178

179179
// Locker is a lockable Scala compiler that can be built of 'current' source to perform rapid development.
180-
lazy val (lockerLib, lockerComp) = makeLayer("locker", STARR, autoLock = true)
181-
lazy val locker = Project("locker", file(".")) aggregate(lockerLib, lockerComp)
180+
lazy val (lockerLib, lockerReflect, lockerComp) = makeLayer("locker", STARR, autoLock = true)
181+
lazy val locker = Project("locker", file(".")) aggregate(lockerLib, lockerReflect, lockerComp)
182182

183183
// Quick is the general purpose project layer for the Scala compiler.
184-
lazy val (quickLib, quickComp) = makeLayer("quick", makeScalaReference("locker", lockerLib, lockerComp))
185-
lazy val quick = Project("quick", file(".")) aggregate(quickLib, quickComp)
184+
lazy val (quickLib, quickReflect, quickComp) = makeLayer("quick", makeScalaReference("locker", lockerLib, lockerReflect, lockerComp))
185+
lazy val quick = Project("quick", file(".")) aggregate(quickLib, quickReflect, quickComp)
186186

187187
// Reference to quick scala instance.
188-
lazy val quickScalaInstance = makeScalaReference("quick", quickLib, quickComp)
188+
lazy val quickScalaInstance = makeScalaReference("quick", quickLib, quickReflect, quickComp)
189189
def quickScalaLibraryDependency = unmanagedClasspath in Compile <++= (exportedProducts in quickLib in Compile).identity
190190
def quickScalaCompilerDependency = unmanagedClasspath in Compile <++= (exportedProducts in quickComp in Compile).identity
191191

192192
// Strapp is used to test binary 'sameness' between things built with locker and things built with quick.
193-
lazy val (strappLib, strappComp) = makeLayer("strapp", quickScalaInstance)
193+
lazy val (strappLib, strappReflect, strappComp) = makeLayer("strapp", quickScalaInstance)
194194

195195
// --------------------------------------------------------------
196196
// Projects dependent on layered compilation (quick)
@@ -282,6 +282,8 @@ object ScalaBuild extends Build with Layers {
282282
)
283283
lazy val scalaLibrary = Project("scala-library", file(".")) settings(publishSettings:_*) settings(scalaLibArtifactSettings:_*)
284284

285+
// TODO - Real Reflect instance
286+
285287
// --------------------------------------------------------------
286288
// Real Compiler Artifact
287289
// --------------------------------------------------------------
@@ -297,7 +299,7 @@ object ScalaBuild extends Build with Layers {
297299
target <<= (baseDirectory, name) apply (_ / "target" / _)
298300
)
299301
lazy val scalaCompiler = Project("scala-compiler", file(".")) settings(publishSettings:_*) settings(scalaBinArtifactSettings:_*) dependsOn(scalaLibrary)
300-
lazy val fullQuickScalaReference = makeScalaReference("pack", scalaLibrary, scalaCompiler)
302+
lazy val fullQuickScalaReference = makeScalaReference("pack", scalaLibrary, quickReflect, scalaCompiler)
301303

302304
// --------------------------------------------------------------
303305
// Testing
@@ -341,7 +343,7 @@ object ScalaBuild extends Build with Layers {
341343

342344
// TODO - Migrate this into the dist project.
343345
// Scaladocs
344-
def distScalaInstance = makeScalaReference("dist", scalaLibrary, scalaCompiler)
346+
def distScalaInstance = makeScalaReference("dist", scalaLibrary, quickReflect, scalaCompiler)
345347
lazy val documentationSettings: Seq[Setting[_]] = dependentProjectSettings ++ Seq(
346348
// TODO - Make these work for realz.
347349
defaultExcludes in unmanagedSources in Compile := ((".*" - ".") || HiddenFileFilter ||

project/Layers.scala

+21-6
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@ trait Layers extends Build {
2525
/** Creates a reference Scala version that can be used to build other projects. This takes in the raw
2626
* library, compiler and fjbg libraries as well as a string representing the layer name (used for compiling the compile-interface).
2727
*/
28-
def makeScalaReference(layer: String, library: Project, compiler: Project) =
28+
def makeScalaReference(layer: String, library: Project, reflect: Project, compiler: Project) =
2929
scalaInstance <<= (appConfiguration in library,
3030
version in library,
3131
(exportedProducts in library in Compile),
32+
(exportedProducts in reflect in Compile),
3233
(exportedProducts in compiler in Compile),
3334
(exportedProducts in fjbg in Compile),
3435
(fullClasspath in jline in Runtime),
3536
(exportedProducts in asm in Runtime)) map {
36-
(app, version: String, lib: Classpath, comp: Classpath, fjbg: Classpath, jline: Classpath, asm: Classpath) =>
37+
(app, version: String, lib: Classpath, reflect: Classpath, comp: Classpath, fjbg: Classpath, jline: Classpath, asm: Classpath) =>
3738
val launcher = app.provider.scalaProvider.launcher
3839
(lib,comp) match {
3940
case (Seq(libraryJar), Seq(compilerJar)) =>
@@ -42,7 +43,7 @@ trait Layers extends Build {
4243
libraryJar.data,
4344
compilerJar.data,
4445
launcher,
45-
((fjbg.files++jline.files ++ asm.files):_*))
46+
((fjbg.files ++ jline.files ++ asm.files ++ reflect.files):_*))
4647
case _ => error("Cannot build a ScalaReference with more than one classpath element")
4748
}
4849
}
@@ -51,7 +52,7 @@ trait Layers extends Build {
5152
* Returns the library project and compiler project from the next layer.
5253
* Note: The library and compiler are not *complete* in the sense that they are missing things like "actors" and "fjbg".
5354
*/
54-
def makeLayer(layer: String, referenceScala: Setting[Task[ScalaInstance]], autoLock: Boolean = false) : (Project, Project) = {
55+
def makeLayer(layer: String, referenceScala: Setting[Task[ScalaInstance]], autoLock: Boolean = false) : (Project, Project, Project) = {
5556
val autoLockSettings: Seq[Setting[_]] =
5657
if(autoLock) Seq(compile in Compile <<= (compile in Compile, lock) apply { (c, l) =>
5758
c flatMapR { cResult =>
@@ -76,6 +77,20 @@ trait Layers extends Build {
7677
referenceScala
7778
)
7879

80+
// Define the reflection
81+
val reflect = Project(layer + "-reflect", file(".")) settings(settingOverrides:_*) settings(autoLockSettings:_*) settings(
82+
version := layer,
83+
scalaSource in Compile <<= (baseDirectory) apply (_ / "src" / "reflect"),
84+
resourceDirectory in Compile <<= baseDirectory apply (_ / "src" / "reflect"),
85+
defaultExcludes := ("tests"),
86+
defaultExcludes in unmanagedResources := "*.scala",
87+
resourceGenerators in Compile <+= (resourceManaged, Versions.scalaVersions, skip in Compile, streams) map Versions.generateVersionPropertiesFile("reflect.properties"),
88+
// TODO - Use depends on *and* SBT's magic dependency mechanisms...
89+
unmanagedClasspath in Compile <<= Seq(forkjoin, library).map(exportedProducts in Compile in _).join.map(_.flatten),
90+
externalDeps,
91+
referenceScala
92+
)
93+
7994
// Define the compiler
8095
val compiler = Project(layer + "-compiler", file(".")) settings(settingOverrides:_*) settings(autoLockSettings:_*) settings(
8196
version := layer,
@@ -93,13 +108,13 @@ trait Layers extends Build {
93108
dirs.descendentsExcept( ("*.xml" | "*.html" | "*.gif" | "*.png" | "*.js" | "*.css" | "*.tmpl" | "*.swf" | "*.properties" | "*.txt"),"*.scala").get
94109
},
95110
// TODO - Use depends on *and* SBT's magic dependency mechanisms...
96-
unmanagedClasspath in Compile <<= Seq(forkjoin, library, fjbg, jline, asm).map(exportedProducts in Compile in _).join.map(_.flatten),
111+
unmanagedClasspath in Compile <<= Seq(forkjoin, library, reflect, fjbg, jline, asm).map(exportedProducts in Compile in _).join.map(_.flatten),
97112
externalDeps,
98113
referenceScala
99114
)
100115

101116
// Return the generated projects.
102-
(library, compiler)
117+
(library, reflect, compiler)
103118
}
104119

105120
}

project/ScalaBuildKeys.scala

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import sbt._
2+
import Keys._
3+
4+
object ScalaBuildKeys {
5+
val lockerLock: TaskKey[Unit] = TaskKey("locker-lock",
6+
"Locks the locker layer of the compiler build such that it won't rebuild on changed source files.")
7+
val lockerUnlock: TaskKey[Unit] = TaskKey("locker-unlock",
8+
"Unlocks the locker layer of the compiler so that it will be recompiled on changed source files.")
9+
val lockFile: SettingKey[File] = SettingKey("lock-file",
10+
"Location of the lock file compiling this project.")
11+
// New tasks/settings specific to the scala build.
12+
val lock: TaskKey[Unit] = TaskKey("lock", "Locks this project so it won't be recompiled.")
13+
val unlock: TaskKey[Unit] = TaskKey("unlock", "Unlocks this project so it will be recompiled.")
14+
val makeDist: TaskKey[File] = TaskKey("make-dist",
15+
"Creates a mini-distribution (scala home directory) for this build in a zip file.")
16+
val makeExplodedDist: TaskKey[File] = TaskKey("make-exploded-dist",
17+
"Creates a mini-distribution (scala home directory) for this build in a directory.")
18+
val makeDistMappings: TaskKey[Map[File, String]] = TaskKey("make-dist-mappings",
19+
"Creates distribution mappings for creating zips,jars,directorys,etc.")
20+
val buildFixed = AttributeKey[Boolean]("build-uri-fixed")
21+
22+
}

0 commit comments

Comments
 (0)