diff options
author | Josh Suereth <joshua.suereth@gmail.com> | 2012-05-23 21:08:49 -0400 |
---|---|---|
committer | Josh Suereth <joshua.suereth@gmail.com> | 2012-05-23 21:08:49 -0400 |
commit | 4b2dad431755a1428b1bb1506faaab3c98b6fc63 (patch) | |
tree | 83507c19fdfc7b97e5b344f086f751527149ae62 | |
parent | de98920e42bef0cc63a14dfbf9ea27426ed16f1f (diff) | |
download | scala-4b2dad431755a1428b1bb1506faaab3c98b6fc63.tar.gz scala-4b2dad431755a1428b1bb1506faaab3c98b6fc63.tar.bz2 scala-4b2dad431755a1428b1bb1506faaab3c98b6fc63.zip |
Added lock by default and did a minor amount of cleanup. More to come hopefully.
-rw-r--r-- | project/Build.scala | 79 | ||||
-rw-r--r-- | project/Layers.scala | 19 |
2 files changed, 40 insertions, 58 deletions
diff --git a/project/Build.scala b/project/Build.scala index 0cc0c5c5d7..610f756a34 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -2,25 +2,11 @@ import sbt._ import Keys._ import partest._ import SameTest._ +import ScalaBuildKeys._ + + object ScalaBuild extends Build with Layers { - // New tasks/settings specific to the scala build. - lazy val lockerLock: TaskKey[Unit] = TaskKey("locker-lock", - "Locks the locker layer of the compiler build such that it won't rebuild on changed source files.") - lazy val lockerUnlock: TaskKey[Unit] = TaskKey("locker-unlock", - "Unlocks the locker layer of the compiler so that it will be recompiled on changed source files.") - lazy val lockFile: SettingKey[File] = SettingKey("lock-file", - "Location of the lock file compiling this project.") - // New tasks/settings specific to the scala build. - lazy val lock: TaskKey[Unit] = TaskKey("lock", "Locks this project so it won't be recompiled.") - lazy val unlock: TaskKey[Unit] = TaskKey("unlock", "Unlocks this project so it will be recompiled.") - lazy val makeDist: TaskKey[File] = TaskKey("make-dist", - "Creates a mini-distribution (scala home directory) for this build in a zip file.") - lazy val makeExplodedDist: TaskKey[File] = TaskKey("make-exploded-dist", - "Creates a mini-distribution (scala home directory) for this build in a directory.") - lazy val makeDistMappings: TaskKey[Map[File, String]] = TaskKey("make-dist-mappings", - "Creates distribution mappings for creating zips,jars,directorys,etc.") - lazy val buildFixed = AttributeKey[Boolean]("build-uri-fixed") // Build wide settings: override lazy val settings = super.settings ++ Versions.settings ++ Seq( @@ -35,22 +21,7 @@ object ScalaBuild extends Build with Layers { ), organization := "org.scala-lang", version <<= Versions.mavenVersion, - pomExtra := <xml:group> - <inceptionYear>2002</inceptionYear> - <licenses> - <license> - <name>BSD-like</name> - <url>http://www.scala-lang.org/downloads/license.html</url> - </license> - </licenses> - <scm> - <connection>scm:git:git://github.com/scala/scala.git</connection> - </scm> - <issueManagement> - <system>jira</system> - <url>http://issues.scala-lang.org</url> - </issueManagement> - </xml:group>, + pomExtra := epflPomExtra, commands += Command.command("fix-uri-projects") { (state: State) => if(state.get(buildFixed) getOrElse false) state else { @@ -154,26 +125,26 @@ object ScalaBuild extends Build with Layers { // These are setting overrides for most artifacts in the Scala build file. def settingOverrides: Seq[Setting[_]] = publishSettings ++ Seq( - crossPaths := false, - autoScalaLibrary := false, - // Work around a bug where scala-library (and forkjoin) is put on classpath for analysis. - classpathOptions := ClasspathOptions.manual, - publishArtifact in packageDoc := false, - publishArtifact in packageSrc := false, - target <<= (baseDirectory, name) apply (_ / "target" / _), - (classDirectory in Compile) <<= target(_ / "classes"), - javacOptions ++= Seq("-target", "1.5", "-source", "1.5"), - scalaSource in Compile <<= (baseDirectory, name) apply (_ / "src" / _), - javaSource in Compile <<= (baseDirectory, name) apply (_ / "src" / _), - autoScalaLibrary := false, - unmanagedJars in Compile := Seq(), - // Most libs in the compiler use this order to build. - compileOrder in Compile := CompileOrder.JavaThenScala, - lockFile <<= target(_ / "compile.lock"), - skip in Compile <<= lockFile map (_.exists), - lock <<= lockFile map (f => IO.touch(f)), - unlock <<= lockFile map IO.delete - ) + crossPaths := false, + autoScalaLibrary := false, + // Work around a bug where scala-library (and forkjoin) is put on classpath for analysis. + classpathOptions := ClasspathOptions.manual, + publishArtifact in packageDoc := false, + publishArtifact in packageSrc := false, + target <<= (baseDirectory, name) apply (_ / "target" / _), + (classDirectory in Compile) <<= target(_ / "classes"), + javacOptions ++= Seq("-target", "1.5", "-source", "1.5"), + scalaSource in Compile <<= (baseDirectory, name) apply (_ / "src" / _), + javaSource in Compile <<= (baseDirectory, name) apply (_ / "src" / _), + autoScalaLibrary := false, + unmanagedJars in Compile := Seq(), + // Most libs in the compiler use this order to build. + compileOrder in Compile := CompileOrder.JavaThenScala, + lockFile <<= target(_ / "compile.lock"), + skip in Compile <<= lockFile map (_.exists), + lock <<= lockFile map (f => IO.touch(f)), + unlock <<= lockFile map IO.delete + ) // -------------------------------------------------------------- // Libraries used by Scalac that change infrequently @@ -206,7 +177,7 @@ object ScalaBuild extends Build with Layers { } // Locker is a lockable Scala compiler that can be built of 'current' source to perform rapid development. - lazy val (lockerLib, lockerComp) = makeLayer("locker", STARR) + lazy val (lockerLib, lockerComp) = makeLayer("locker", STARR, autoLock = true) lazy val locker = Project("locker", file(".")) aggregate(lockerLib, lockerComp) // Quick is the general purpose project layer for the Scala compiler. diff --git a/project/Layers.scala b/project/Layers.scala index 58fcb1b254..6d0c68f2a4 100644 --- a/project/Layers.scala +++ b/project/Layers.scala @@ -1,6 +1,7 @@ import sbt._ import Keys._ import com.jsuereth.git.GitKeys.gitRunner +import ScalaBuildKeys.lock /** This trait stores all the helper methods to generate layers in Scala's layered build. */ trait Layers extends Build { @@ -24,7 +25,7 @@ trait Layers extends Build { /** Creates a reference Scala version that can be used to build other projects. This takes in the raw * library, compiler and fjbg libraries as well as a string representing the layer name (used for compiling the compile-interface). */ - def makeScalaReference(layer : String, library: Project, compiler: Project) = + def makeScalaReference(layer: String, library: Project, compiler: Project) = scalaInstance <<= (appConfiguration in library, version in library, (exportedProducts in library in Compile), @@ -50,8 +51,18 @@ trait Layers extends Build { * Returns the library project and compiler project from the next layer. * Note: The library and compiler are not *complete* in the sense that they are missing things like "actors" and "fjbg". */ - def makeLayer(layer: String, referenceScala: Setting[Task[ScalaInstance]]) : (Project, Project) = { - val library = Project(layer + "-library", file(".")) settings(settingOverrides: _*) settings( + def makeLayer(layer: String, referenceScala: Setting[Task[ScalaInstance]], autoLock: Boolean = false) : (Project, Project) = { + val autoLockSettings: Seq[Setting[_]] = + if(autoLock) Seq(compile in Compile <<= (compile in Compile, lock) apply { (c, l) => + c flatMapR { cResult => + val result = Result.tryValue(cResult) + l mapR { tx => result } + } + }) + else Seq.empty + + + val library = Project(layer + "-library", file(".")) settings(settingOverrides: _*) settings(autoLockSettings:_*) settings( version := layer, // TODO - use depends on. unmanagedClasspath in Compile <<= (exportedProducts in forkjoin in Compile).identity, @@ -66,7 +77,7 @@ trait Layers extends Build { ) // Define the compiler - val compiler = Project(layer + "-compiler", file(".")) settings(settingOverrides:_*) settings( + val compiler = Project(layer + "-compiler", file(".")) settings(settingOverrides:_*) settings(autoLockSettings:_*) settings( version := layer, scalaSource in Compile <<= (baseDirectory) apply (_ / "src" / "compiler"), resourceDirectory in Compile <<= baseDirectory apply (_ / "src" / "compiler"), |