2012-10-02 04:30:11 +02:00
|
|
|
import sbt._
|
|
|
|
import Keys._
|
2014-09-19 01:24:19 +02:00
|
|
|
import scala.language.postfixOps
|
2012-10-23 21:51:37 +02:00
|
|
|
//val extracted: Extracted = Project.extract(state)
|
|
|
|
//import extracted._
|
2012-10-02 04:30:11 +02:00
|
|
|
|
2012-10-21 02:27:49 +02:00
|
|
|
object BuildSettings extends Build {
|
2012-10-02 04:30:11 +02:00
|
|
|
val buildOrganization = "berkeley"
|
|
|
|
val buildVersion = "1.1"
|
2013-07-25 08:28:43 +02:00
|
|
|
val buildScalaVersion = "2.10.2"
|
2012-10-02 04:30:11 +02:00
|
|
|
|
|
|
|
val buildSettings = Defaults.defaultSettings ++ Seq (
|
|
|
|
//unmanagedBase <<= baseDirectory { base => base / ".." / custom_lib" },
|
|
|
|
organization := buildOrganization,
|
|
|
|
version := buildVersion,
|
2012-11-20 14:39:48 +01:00
|
|
|
scalaVersion := buildScalaVersion,
|
2013-11-09 00:30:08 +01:00
|
|
|
parallelExecution in Global := false,
|
2013-07-25 08:28:43 +02:00
|
|
|
traceLevel := 15,
|
|
|
|
scalacOptions ++= Seq("-deprecation","-unchecked"),
|
2013-09-26 21:01:46 +02:00
|
|
|
libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
|
|
|
|
// "edu.berkeley.cs" %% "chisel" % "2.3-SNAPSHOT",
|
|
|
|
// "edu.berkeley.cs" %% "hardfloat" % "1.2"),
|
|
|
|
//resolvers ++= Seq(
|
|
|
|
// "Sonatype Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
|
|
|
|
// "Sonatype Releases" at "http://oss.sonatype.org/content/repositories/releases",
|
|
|
|
// "scct-github-repository" at "http://mtkopone.github.com/scct/maven-repo"
|
|
|
|
//)
|
2012-10-02 04:30:11 +02:00
|
|
|
)
|
|
|
|
|
2014-09-19 01:24:19 +02:00
|
|
|
lazy val chisel = Project("chisel", file("chisel"), settings = buildSettings)
|
|
|
|
lazy val hardfloat = Project("hardfloat", file("hardfloat"), settings = buildSettings) dependsOn(chisel)
|
|
|
|
lazy val uncore = Project("uncore", file("uncore"), settings = buildSettings) dependsOn(hardfloat)
|
|
|
|
lazy val rocket = Project("rocket", file("rocket"), settings = buildSettings) dependsOn(uncore)
|
2015-07-08 05:38:47 +02:00
|
|
|
lazy val zscale = Project("zscale", file("zscale"), settings = buildSettings) dependsOn(rocket)
|
2014-09-25 15:45:09 +02:00
|
|
|
|
2015-07-08 05:38:47 +02:00
|
|
|
val baselist = Vector("chisel", "uncore", "rocket", "zscale", "hardfloat")
|
2014-09-12 10:08:11 +02:00
|
|
|
def getsubdirs = {
|
2014-09-19 06:22:13 +02:00
|
|
|
val blacklist = (baselist ++ Vector("target", "project"))
|
|
|
|
IO.listFiles(file(".")) map (_.toString.split("/").last) filter (f=> !blacklist.contains(f) && (f(0)!='.')) filter (f=> !IO.listFiles(file(f+"/src/main/scala")).isEmpty)
|
2014-09-12 10:08:11 +02:00
|
|
|
}
|
2014-09-19 01:24:19 +02:00
|
|
|
val addonsources = getsubdirs map (f=>s"${f}/src/main/scala") map (f=>file(f))
|
|
|
|
addonsources.foreach(a => println(s"[info] Found addon: " + a.toString.split("/").head))
|
2014-09-12 10:08:11 +02:00
|
|
|
|
2014-09-19 01:24:19 +02:00
|
|
|
val prepareTask = TaskKey[Unit]("prepare","Remove old sources and copy over new ones to addon/src")
|
|
|
|
def prepareTaskImpl = {
|
|
|
|
import IO._
|
2014-09-19 06:22:13 +02:00
|
|
|
delete(file(".addons-dont-touch/src"))
|
|
|
|
createDirectory(file(".addons-dont-touch/src/main/scala"))
|
2014-09-19 01:24:19 +02:00
|
|
|
addonsources.foreach(as => {
|
|
|
|
val addonname = as.toString.split("/").head
|
2014-09-19 06:22:13 +02:00
|
|
|
copyDirectory(as, file(".addons-dont-touch/src/main/scala/"+addonname))
|
2014-09-19 01:24:19 +02:00
|
|
|
})
|
|
|
|
}
|
2014-09-12 10:08:11 +02:00
|
|
|
|
2014-09-19 06:22:13 +02:00
|
|
|
lazy val addons = Project("addons", file(".addons-dont-touch"), settings = buildSettings ++ Seq(
|
2014-09-19 01:24:19 +02:00
|
|
|
prepareTask := prepareTaskImpl,
|
|
|
|
(compile in Compile) <<= (compile in Compile) dependsOn (prepareTask)
|
2015-07-08 05:38:47 +02:00
|
|
|
)) dependsOn(chisel, hardfloat, uncore, rocket, zscale)
|
|
|
|
lazy val rocketchip = Project("rocketchip", file("."), settings = buildSettings ++ chipSettings).dependsOn(chisel, uncore, rocket, zscale, addons)
|
2012-10-21 02:27:49 +02:00
|
|
|
|
2012-10-23 21:51:37 +02:00
|
|
|
val elaborateTask = InputKey[Unit]("elaborate", "convert chisel components into backend source code")
|
|
|
|
val makeTask = InputKey[Unit]("make", "trigger backend-specific makefile command")
|
2012-10-21 02:27:49 +02:00
|
|
|
|
2012-11-18 04:58:18 +01:00
|
|
|
def runChisel(args: Seq[String], cp: Classpath, pr: ResolvedProject) = {
|
|
|
|
val numArgs = 1
|
|
|
|
require(args.length >= numArgs, "syntax: elaborate <component> [chisel args]")
|
|
|
|
val projectName = pr.id
|
|
|
|
val packageName = projectName //TODO: valid convention?
|
|
|
|
val componentName = args(0)
|
2014-09-19 01:24:19 +02:00
|
|
|
val classLoader = new java.net.URLClassLoader(cp.map(_.data.toURI.toURL).toArray, cp.getClass.getClassLoader)
|
2012-11-18 04:58:18 +01:00
|
|
|
val chiselMainClass = classLoader.loadClass("Chisel.chiselMain$")
|
|
|
|
val chiselMainObject = chiselMainClass.getDeclaredFields.head.get(null)
|
|
|
|
val chiselMain = chiselMainClass.getMethod("run", classOf[Array[String]], classOf[Function0[_]])
|
|
|
|
val chiselArgs = args.drop(numArgs)
|
2014-02-05 12:29:23 +01:00
|
|
|
val component = classLoader.loadClass((if (!componentName.contains('.')) packageName+"." else "")+componentName)
|
2012-11-18 04:58:18 +01:00
|
|
|
val generator = () => component.newInstance()
|
|
|
|
chiselMain.invoke(chiselMainObject, Array(chiselArgs.toArray, generator):_*)
|
|
|
|
}
|
|
|
|
|
2012-10-23 21:51:37 +02:00
|
|
|
val chipSettings = Seq(
|
|
|
|
elaborateTask <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
|
2012-11-18 04:58:18 +01:00
|
|
|
(argTask, fullClasspath in Runtime, thisProject) map {
|
|
|
|
runChisel
|
2012-10-23 21:51:37 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
makeTask <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
|
2012-11-18 04:58:18 +01:00
|
|
|
(argTask, fullClasspath in Runtime, thisProject) map {
|
|
|
|
(args: Seq[String], cp: Classpath, pr: ResolvedProject) => {
|
2012-10-23 21:51:37 +02:00
|
|
|
require(args.length >= 2, "syntax: <dir> <target>")
|
2012-11-18 04:58:18 +01:00
|
|
|
runChisel(args.drop(2), cp, pr)
|
2012-10-23 21:51:37 +02:00
|
|
|
val makeDir = args(0)
|
|
|
|
val target = args(1)
|
|
|
|
val jobs = java.lang.Runtime.getRuntime.availableProcessors
|
|
|
|
val make = "make -C" + makeDir + " -j" + jobs + " " + target
|
|
|
|
make!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
2012-10-02 04:30:11 +02:00
|
|
|
}
|