From 8bef04a234b9c9005504a6fcd3f4f3dd10973ff8 Mon Sep 17 00:00:00 2001 From: moix Date: Thu, 19 Aug 2010 15:06:34 +0000 Subject: Extending sbt capabilities : - building continuation plugin - building and replacing fjgb, msil and forkjoin - building and replacing starr - layer cleaning tasks --- project/build/ScalaSBTBuilder.scala | 178 ++++++++++++++++++++++++++++++++---- 1 file changed, 159 insertions(+), 19 deletions(-) (limited to 'project/build/ScalaSBTBuilder.scala') diff --git a/project/build/ScalaSBTBuilder.scala b/project/build/ScalaSBTBuilder.scala index 10b90247bb..2720e82c82 100644 --- a/project/build/ScalaSBTBuilder.scala +++ b/project/build/ScalaSBTBuilder.scala @@ -1,19 +1,30 @@ import sbt._ -import BasicLayer._ +import ScalaBuildProject._ /** * This class is the entry point for building scala with SBT. * @author Grégory Moix */ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectiveProject { - override def dependencies: Iterable[Project] = info.dependencies ++ locker.dependencies ++ quick.dependencies ++ strap.dependencies + override def dependencies: Iterable[Project] = info.dependencies ++ locker.dependencies ++ quick.dependencies ++ strap.dependencies ++ libs.dependencies override def shouldCheckOutputDirectories = false - // Main Tasks - - lazy val replaceLocker=task{None}.dependsOn(locker.unlock) + // Top Level Tasks lazy val build = task{None}.dependsOn(quick.binPack,quick.binQuick) + lazy val clean = locker.clean lazy val docs = quick.scaladoc + lazy val palo = locker.pack + lazy val pasta = quick.pasta + lazy val newStarr = quick.newStarr + lazy val newLocker=locker.newLocker + lazy val buildForkjoin=libs.buildForkjoin + lazy val newForkjoin = libs.newForkjoin + lazy val buildFjbg = libs.buildFjbg + lazy val newFjbg = libs.newFjbg + lazy val buildMsil = libs.buildMsil + lazy val newMsil = libs.newMsil + + // Top level variables @@ -56,6 +67,8 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro lazy val locker=project(info.projectPath,"locker", new LockerLayer(_)) lazy val quick=project(info.projectPath,"quick",new QuickLayer(_,locker)) lazy val strap=project(info.projectPath,"strap", new StrapLayer(_, quick)) + lazy val libs=project(info.projectPath,"libs", new LibsBuilder(_)) + /** * Definition of what is specific to the locker layer. It implements SimplePacker in order to @@ -63,8 +76,8 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro */ class LockerLayer(info:ProjectInfo) extends BasicLayer(info,versionNumber,None) with Packer{ - import BasicLayer._ + override lazy val nextLayer=Some(quick) lazy val instantiationCompilerJar = lib / compilerJarName lazy val instantiationLibraryJar = lib / libraryJarName lazy val lockFile = layerOutput / "locker.lock" @@ -83,26 +96,43 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro else action } + def deleteLock = FileUtilities.clean(lockFile,log) + def createLock = { + log.info("locking "+name) + FileUtilities.touch(lockFile,log) + } + /** * Task for locking locker */ lazy val lock = super.task{ - log.info("locking "+name) - FileUtilities.touch(lockFile,log) + createLock } /** * Task for unlocking locker */ lazy val unlock = super.task{ - FileUtilities.clean(lockFile,log) + deleteLock } + lazy val newLocker = super.task{ + createNewLocker + } + def createNewLocker = { + deleteLock orElse + buildLayer orElse + createLock + } + + /** * Making locker being locked when it has finished building */ override lazy val finishLayer = lock.dependsOn(build) + override lazy val pack = super.task{packF}.dependsOn(finishLayer) + override lazy val packingDestination:Path = outputRootPath /"palo" @@ -112,11 +142,11 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro */ override lazy val libraryWS = { new WrapperStep(libraryConfig::Nil) with WrapperPackaging{ - def jarName = libraryJarName - def packagingDestination = packingDestination + lazy val packagingConfig = new PackagingConfiguration(libsDestination/libraryJarName, jarContent) } } override val minimalCompilation = true + override lazy val pluginsWS:WrapperStep = new WrapperStep(Nil) override lazy val toolsWS = new WrapperStep(Nil) } @@ -128,24 +158,61 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro class QuickLayer(info:ProjectInfo, previous:BasicLayer) extends BasicLayer(info,versionNumber,Some(previous)) with Packer with ScalaTools with Scaladoc{ + override lazy val nextLayer=Some(strap) + + lazy val instantiationCompilerJar = previous.compilerOutput lazy val instantiationLibraryJar = previous.libraryOutput override lazy val packingDestination:Path = outputRootPath/ "pack" + override def libraryToCopy = jlineJar::Nil override def compilerAdditionalJars = msilJar::fjbgJar::Nil override def libraryAdditionalJars = forkJoinJar::Nil + override lazy val libraryWS = new WrapperStep(libraryConfig::actorsConfig::dbcConfig::swingConfig::Nil)with Packaging{ - def jarName = libraryJarName - def packagingDestination = packingDestination - def jarContent = List(libraryConfig.outputDirectory ## , actorsConfig.outputDirectory ## ) - override def jarsToInclude = libraryAdditionalJars - } + def jarContent = List(libraryConfig , actorsConfig, continuationLibraryConfig).map(_.outputDirectory ##) + lazy val starrJarContent=List(libraryConfig , actorsConfig,dbcConfig,swingConfig, continuationLibraryConfig).map(_.outputDirectory ##) + lazy val packagingConfig = new PackagingConfiguration(libsDestination/libraryJarName,jarContent,libraryAdditionalJars) + lazy val starrPackagingConfig = new PackagingConfiguration(packedStarrOutput/libraryJarName,starrJarContent) + + } + override lazy val toolsWS = new WrapperStep(scalapConfig::partestConfig::Nil) + // An additional task for building only the library of quick + // Used for compiling msil + lazy val compileLibraryOnly = task{ + compile(libraryConfig, cleanCompilation _) + } + lazy val externalCompileLibraryOnly = task{ + val runner = new ExternalTaskRunner(projectRoot,this.name,compileLibraryOnly.name, log) + runner.runTask + }.dependsOn(startLayer) + + + def createNewStarrJar:Option[String]={ + import Packer._ + createJar(libraryWS.starrPackagingConfig,log) orElse + createJar(compilerConfig.starrPackagingConfig,log) + } + lazy val pasta = task{ + createNewStarrJar + }.dependsOn(build) + + lazy val newStarr = task{ + val files = (packedStarrOutput ##) * "*.jar" + FileUtilities.copy(files.get,lib,true,log) match{ + case Right(_) =>None + case Left(_) =>Some("Error occured when copying the new starr to its destination") + } + + }.dependsOn(pasta) + + /* @@ -169,11 +236,84 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro lazy val instantiationLibraryJar = previous.libraryOutput override lazy val libraryWS = new WrapperStep(libraryConfig::actorsConfig::dbcConfig::swingConfig::Nil) with WrapperPackaging{ - def jarName = libraryJarName - def packagingDestination = packingDestination + lazy val packagingConfig = new PackagingConfiguration(libsDestination/libraryJarName,Set()) + } override lazy val toolsWS= new WrapperStep(scalapConfig::partestConfig::Nil) } -} + + + + /** + * An additional subproject used to build new version of forkjoin,fjbg and msil + */ + class LibsBuilder(val info:ProjectInfo) extends ScalaBuildProject with ReflectiveProject with Compilation with BuildInfoEnvironment { + override def dependencies = info.dependencies + + def buildInfoEnvironmentLocation:Path=outputRootPath / ("build-"+name+".properties") + + def instantiationCompilerJar:Path=locker.compilerOutput + def instantiationLibraryJar:Path=locker.libraryOutput + + def libsDestination = layerOutput + + lazy val checkJavaVersion = task{ + val version = System.getProperty("java.specification.version") + log.debug("java.specification.version="+version) + val required = "1.6" + if (version.startsWith(required)) None else Some("Incompatible java version : required "+required) + } + + + private def simpleBuild(step:CompilationStep with Packaging)=task{ + import Packer._ + compile(step) orElse createJar(step,log) + }.dependsOn(locker.finishLayer) + + private def copyJar(step:CompilationStep with Packaging, name:String) = task { + FileUtilities.copyFile(step.packagingConfig.jarDestination,lib/name,log) + } + + lazy val newForkjoin = copyJar(forkJoinConfig,forkjoinJarName).dependsOn(buildForkjoin) + lazy val buildForkjoin= simpleBuild(forkJoinConfig).dependsOn(checkJavaVersion) + lazy val newFjbg = copyJar(fjbgConfig, fjbgJarName).dependsOn(buildFjbg) + lazy val buildFjbg = simpleBuild(fjbgConfig) + lazy val newMsil = copyJar(msilConfig,msilJarName).dependsOn(buildMsil) + // TODO As msil contains scala files, maybe needed compile it with an ExternalSBTRunner + lazy val buildMsil = simpleBuild(msilConfig).dependsOn(quick.externalCompileLibraryOnly) + + lazy val forkJoinConfig = new CompilationStep("forkjoin",pathLayout,log) with Packaging{ + def label = "new forkjoin library" + override def sources: PathFinder = sourceRoots.descendentsExcept("*.java", ".svn") + def dependencies = Seq() + def options = Seq() + override def javaOptions = Seq("-target","1.5","-source","1.5","-g") + lazy val packagingConfig = new PackagingConfiguration(libsDestination/forkjoinJarName,List(outputDirectory ##)) + + // TODO Verify java options + } + + lazy val fjbgConfig = new CompilationStep("fjbg",pathLayout,log) with Packaging{ + def label = "new fjbg library" + override def sources: PathFinder = sourceRoots.descendentsExcept("*.java", ".svn") + def dependencies = Seq() + def options = Seq() + override def javaOptions = Seq("-target","1.5","-source","1.4","-g") + lazy val packagingConfig = new PackagingConfiguration(libsDestination/fjbgJarName,List(outputDirectory ##)) + + } + + lazy val msilConfig = new CompilationStep("msil",pathLayout,log) with Packaging{ + def label = "new msil library" + override def sources: PathFinder = sourceRoots.descendentsExcept("*.java"|"*.scala", ".svn"|"tests") + def dependencies = Seq() + override def classpath = super.classpath +++ quick.libraryOutput + def options = Seq() + override def javaOptions = Seq("-target","1.5","-source","1.4","-g") + lazy val packagingConfig = new PackagingConfiguration(libsDestination/msilJarName,List(outputDirectory ##)) + + } + } + } -- cgit v1.2.3