From 17d2bd8926528fa33458b0d5a26f5c0aeb7502c3 Mon Sep 17 00:00:00 2001 From: Henry Cook Date: Sat, 20 Oct 2012 17:27:49 -0700 Subject: [PATCH] Initial version of sbt tasks (elaborate task with no parameters) --- chisel | 2 +- project/build.scala | 34 ++++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/chisel b/chisel index da1d0bf1..bc4e7688 160000 --- a/chisel +++ b/chisel @@ -1 +1 @@ -Subproject commit da1d0bf1ea94ded2088d5812b53eac5eb379cdbb +Subproject commit bc4e7688efe1630c50a06aa114a4e827f367a04e diff --git a/project/build.scala b/project/build.scala index a2c03c50..4e6999a0 100644 --- a/project/build.scala +++ b/project/build.scala @@ -1,21 +1,38 @@ import sbt._ import Keys._ -object BuildSettings { +object BuildSettings extends Build { val buildOrganization = "berkeley" val buildVersion = "1.1" val buildScalaVersion = "2.9.2" + val packageDependencies = TaskKey[Seq[java.io.File]]("package-dependencies", "get package deps") + val elaborateTask = TaskKey[Unit]("elaborate", "convert chisel components into backend source code") + + val buildSettings = Defaults.defaultSettings ++ Seq ( //unmanagedBase <<= baseDirectory { base => base / ".." / custom_lib" }, organization := buildOrganization, version := buildVersion, - scalaVersion := buildScalaVersion - ) -} + scalaVersion := buildScalaVersion, + elaborateTask <<= fullClasspath in Runtime map { + (cp: Classpath) => { + val projName = "ReferenceChip" + val dir = "../emulator/generated-src" + val backend = "c" + val chiselArgs = Array[String]( "--targetDir", dir, "--backend", backend) + val classLoader = new java.net.URLClassLoader(cp.map(_.data.toURL).toArray, cp.getClass.getClassLoader) + val chiselMainClass = classLoader.loadClass("Chisel.chiselMain$") + val chiselMainObject = chiselMainClass.getDeclaredFields.head.get(null) + val chiselMain = chiselMainClass.getMethod("run", classOf[Array[String]], classOf[Function0[_]]) + val component = classLoader.loadClass(projName+".Top") + val generator = () => component.newInstance() + chiselMain.invoke(chiselMainObject, Array(chiselArgs, generator):_*) + } + } + + ) -object ChiselBuild extends Build{ - import BuildSettings._ lazy val chisel = Project("chisel", file("chisel"), settings = buildSettings) lazy val hardfloat = Project("hardfloat", file("hardfloat"), settings = buildSettings) dependsOn(chisel) @@ -23,4 +40,9 @@ object ChiselBuild extends Build{ lazy val uncore = Project("uncore", file("uncore"), settings = buildSettings) dependsOn(chisel) lazy val rocket = Project("rocket", file("rocket"), settings = buildSettings) dependsOn(uncore,hwacha,hardfloat,chisel) lazy val referencechip = Project("referencechip", file("referencechip"), settings = buildSettings) dependsOn(chisel,rocket) + + + + + }