diff options
| -rw-r--r-- | build.sbt | 19 | ||||
| -rw-r--r-- | project/plugins.sbt | 2 | ||||
| -rw-r--r-- | src/main/scala/chisel3/Driver.scala | 4 | ||||
| -rw-r--r-- | src/test/scala/chiselTests/BuildInfoTests.scala | 13 |
4 files changed, 38 insertions, 0 deletions
@@ -93,6 +93,25 @@ lazy val chiselFrontend = (project in file("chiselFrontend")). dependsOn(coreMacros) lazy val chisel = (project in file(".")). + enablePlugins(BuildInfoPlugin). + settings( + // We should really be using name.value, but currently, the package is "Chisel" (uppercase first letter) + buildInfoPackage := /* name.value */ "chisel3", + buildInfoOptions += BuildInfoOption.BuildTime, + buildInfoKeys := Seq[BuildInfoKey](buildInfoPackage, version, scalaVersion, sbtVersion), + // Move the managed source directory where git won't complain about it, + // and where we can easily package its files as part of the source jar artifact. + // We'd like to use versionToArray(), slice(), and mkString() to convert an explicit + // Scala version (like 2.10.6), into the leftmost two components (2.10), + // but this seems to run afoul of assumptions sbt makes about the inclusion + // of Scala-version-specfic code (we get + // BuildInfo is already defined as case class BuildInfo + // so use the full version spec. + //sourceManaged in Compile <<= (sourceDirectory in Compile, scalaVersion){ (s,v) => s / ("scala-" + versionToArray(v).slice(0,2).mkString(".") + "/src_managed") }, + sourceManaged in Compile <<= (sourceDirectory in Compile, scalaVersion){ (s,v) => s / ("scala-" + v + "/src_managed") }, + // Add the generated sources to the packagedSrc artifact since they are excluded by default. + mappings in (Compile, packageSrc) += { ((sourceManaged in Compile).value / "sbt-buildinfo" / "BuildInfo.scala") -> "BuildInfo.scala" } + ). settings(commonSettings: _*). settings(chiselSettings: _*). dependsOn(coreMacros). diff --git a/project/plugins.sbt b/project/plugins.sbt index 585435a0..70e12de8 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -13,3 +13,5 @@ addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.5") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.4") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.8.2") + +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.6.1") diff --git a/src/main/scala/chisel3/Driver.scala b/src/main/scala/chisel3/Driver.scala index 5e0a3a0f..2216bbbd 100644 --- a/src/main/scala/chisel3/Driver.scala +++ b/src/main/scala/chisel3/Driver.scala @@ -7,6 +7,7 @@ import java.io._ import internal._ import internal.firrtl._ +import BuildInfo._ trait BackendCompilationUtilities { /** Create a temporary directory with the prefix name. Exists here because it doesn't in Java 6. @@ -132,4 +133,7 @@ object Driver extends BackendCompilationUtilities { } def targetDir(): String = { target_dir getOrElse new File(".").getCanonicalPath } + + val version = BuildInfo.version + val chiselVersionString = BuildInfo.toString } diff --git a/src/test/scala/chiselTests/BuildInfoTests.scala b/src/test/scala/chiselTests/BuildInfoTests.scala new file mode 100644 index 00000000..21eae17c --- /dev/null +++ b/src/test/scala/chiselTests/BuildInfoTests.scala @@ -0,0 +1,13 @@ +package chiselTests + +import org.scalatest.FlatSpec + +//import Chisel._ + +class BuildInfoTests extends FlatSpec { + behavior of "BuildInfoTests" + + it should "provide correct BuildInfo" in { + println(Chisel.Driver.chiselVersionString) + } +} |
