Adjustments to the build structure (see below)
All 'addon' subprojects now have their sources aggregated into the addons subproject. This is done via a source copy (so that sbt will only rebuild sources that actually changed). To prevent caching issues the addons/src directory is CLEARED and then refilled every time addons is compiled. Thus, it is CRUCIAL NO SOURCES ARE MANUALLY ADDED TO addons/src AS THEY WILL BE WIPED BY addons/prepare. Due to sbt source caching, sbt will still be able to tell which sources have changed. (Strangely, sbt would not cache sources in extra unmanaged source directories and thus would always recompile them.) Also, cleaned up project/build.scala a bit to remove some warnings: Added import scala.language/postFixOps (so make! at the bottom no longer errors) and .toURI.toURL (as straight .toURL has been deprecated by the java standard library).
This commit is contained in:
parent
3b9624277a
commit
69d765744c
2
addons/.gitignore
vendored
Normal file
2
addons/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
src
|
||||||
|
target
|
3
addons/DO_NOT_ADD_FILES_HERE.README
Normal file
3
addons/DO_NOT_ADD_FILES_HERE.README
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
ANY FILES ADDED HERE WILL BE DELETED
|
||||||
|
|
||||||
|
The src directory is dynamically refreshed by the rocketchip project as part of the addons/prepare task.
|
@ -1,5 +1,6 @@
|
|||||||
import sbt._
|
import sbt._
|
||||||
import Keys._
|
import Keys._
|
||||||
|
import scala.language.postfixOps
|
||||||
//val extracted: Extracted = Project.extract(state)
|
//val extracted: Extracted = Project.extract(state)
|
||||||
//import extracted._
|
//import extracted._
|
||||||
|
|
||||||
@ -26,27 +27,35 @@ object BuildSettings extends Build {
|
|||||||
//)
|
//)
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val chisel = Project("chisel", file("chisel"), settings = buildSettings)
|
lazy val chisel = Project("chisel", file("chisel"), settings = buildSettings)
|
||||||
lazy val hardfloat = Project("hardfloat", file("hardfloat"), settings = buildSettings) dependsOn(chisel)
|
lazy val hardfloat = Project("hardfloat", file("hardfloat"), settings = buildSettings) dependsOn(chisel)
|
||||||
lazy val uncore = Project("uncore", file("uncore"), settings = buildSettings) dependsOn(hardfloat)
|
lazy val uncore = Project("uncore", file("uncore"), settings = buildSettings) dependsOn(hardfloat)
|
||||||
lazy val rocket = Project("rocket", file("rocket"), settings = buildSettings) dependsOn(uncore)
|
lazy val rocket = Project("rocket", file("rocket"), settings = buildSettings) dependsOn(uncore)
|
||||||
|
|
||||||
val baselist = Vector("chisel", "uncore", "rocket", "hardfloat")
|
val baselist = Vector("chisel", "uncore", "rocket", "hardfloat")
|
||||||
def show[A](in: Seq[A]) = in.map(_.toString).foldRight("")(_+" "+_)
|
|
||||||
def getsubdirs = {
|
def getsubdirs = {
|
||||||
val blacklist = (baselist ++ Vector("target", "project"))
|
val blacklist = (baselist ++ Vector("target", "project", "addons"))
|
||||||
IO.listFiles(file(".")) map (_.toString.split("/").last) filter (f=> !blacklist.contains(f)) filter (f=> !IO.listFiles(file(f+"/src/main/scala")).isEmpty)
|
IO.listFiles(file(".")) map (_.toString.split("/").last) filter (f=> !blacklist.contains(f)) filter (f=> !IO.listFiles(file(f+"/src/main/scala")).isEmpty)
|
||||||
}
|
}
|
||||||
// def buildsubproj(sproj: String) = Project(sproj, file(sproj), settings = buildSettings).dependsOn(chisel, uncore, rocket, hardfloat)
|
val addonsources = getsubdirs map (f=>s"${f}/src/main/scala") map (f=>file(f))
|
||||||
// val subprojs = (getsubprojs map (sproj=>buildsubproj(sproj)))
|
addonsources.foreach(a => println(s"[info] Found addon: " + a.toString.split("/").head))
|
||||||
// unfortunately, creating projects on the fly doesn't seem to quite work in sbt
|
|
||||||
|
|
||||||
val othersources = getsubdirs map (f=>s"${f}/src/main/scala") map (f=>file(f))
|
val prepareTask = TaskKey[Unit]("prepare","Remove old sources and copy over new ones to addon/src")
|
||||||
val addOtherFiles = Seq (
|
def prepareTaskImpl = {
|
||||||
unmanagedSourceDirectories in Compile ++= othersources.toSeq
|
import IO._
|
||||||
) // so instead, for dynamically expanding projects, just compile them all at once with rocket chip
|
delete(file("addons/src"))
|
||||||
|
createDirectory(file("addons/src/main/scala"))
|
||||||
|
addonsources.foreach(as => {
|
||||||
|
val addonname = as.toString.split("/").head
|
||||||
|
copyDirectory(as, file("addons/src/main/scala/"+addonname))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
lazy val rocketchip = Project("rocketchip", file("."), settings = buildSettings ++ chipSettings ++ addOtherFiles).dependsOn(chisel, hardfloat, uncore, rocket)
|
lazy val addons = Project("addons", file("addons"), settings = buildSettings ++ Seq(
|
||||||
|
prepareTask := prepareTaskImpl,
|
||||||
|
(compile in Compile) <<= (compile in Compile) dependsOn (prepareTask)
|
||||||
|
)) dependsOn(chisel, hardfloat, uncore, rocket)
|
||||||
|
lazy val rocketchip = Project("rocketchip", file("."), settings = buildSettings ++ chipSettings).dependsOn(chisel, uncore, rocket, addons)
|
||||||
|
|
||||||
val elaborateTask = InputKey[Unit]("elaborate", "convert chisel components into backend source code")
|
val elaborateTask = InputKey[Unit]("elaborate", "convert chisel components into backend source code")
|
||||||
val makeTask = InputKey[Unit]("make", "trigger backend-specific makefile command")
|
val makeTask = InputKey[Unit]("make", "trigger backend-specific makefile command")
|
||||||
@ -57,7 +66,7 @@ object BuildSettings extends Build {
|
|||||||
val projectName = pr.id
|
val projectName = pr.id
|
||||||
val packageName = projectName //TODO: valid convention?
|
val packageName = projectName //TODO: valid convention?
|
||||||
val componentName = args(0)
|
val componentName = args(0)
|
||||||
val classLoader = new java.net.URLClassLoader(cp.map(_.data.toURL).toArray, cp.getClass.getClassLoader)
|
val classLoader = new java.net.URLClassLoader(cp.map(_.data.toURI.toURL).toArray, cp.getClass.getClassLoader)
|
||||||
val chiselMainClass = classLoader.loadClass("Chisel.chiselMain$")
|
val chiselMainClass = classLoader.loadClass("Chisel.chiselMain$")
|
||||||
val chiselMainObject = chiselMainClass.getDeclaredFields.head.get(null)
|
val chiselMainObject = chiselMainClass.getDeclaredFields.head.get(null)
|
||||||
val chiselMain = chiselMainClass.getMethod("run", classOf[Array[String]], classOf[Function0[_]])
|
val chiselMain = chiselMainClass.getMethod("run", classOf[Array[String]], classOf[Function0[_]])
|
||||||
|
Loading…
Reference in New Issue
Block a user