diff options
| author | Adam Izraelevitz | 2020-07-29 20:48:31 -0700 |
|---|---|---|
| committer | GitHub | 2020-07-29 20:48:31 -0700 |
| commit | 164490c8fbf132ca65644d05d6ff8d0d7a3beb20 (patch) | |
| tree | 862750b85dca5b8496c40c24b3a4e5e67c268bd4 /build.sbt | |
| parent | 8aeb39b9b3755ccd0e3aa600b813ed4220ac72d8 (diff) | |
Improved Chisel Naming via Compiler Plugins + Prefixing (#1448)
Added prefixing and a compiler plugin to improve naming. Only works for Scala 2.12 and above.
Co-authored-by: Jack Koenig <koenig@sifive.com>
Diffstat (limited to 'build.sbt')
| -rw-r--r-- | build.sbt | 51 |
1 files changed, 50 insertions, 1 deletions
@@ -125,6 +125,54 @@ lazy val chiselSettings = Seq ( } ) +autoCompilerPlugins := true + +// Plugin must be fully cross-versioned (published for Scala minor version) +// The plugin only works in Scala 2.12+ +lazy val pluginScalaVersions = Seq( + "2.11.12", // Only to support chisel3 cross building for 2.11, plugin does nothing in 2.11 + // scalamacros paradise version used is not published for 2.12.0 and 2.12.1 + "2.12.2", + "2.12.3", + "2.12.4", + "2.12.5", + "2.12.6", + "2.12.7", + "2.12.8", + "2.12.9", + "2.12.10", + "2.12.11" +) + +lazy val plugin = (project in file("plugin")). + settings(name := "chisel3-plugin"). + settings(commonSettings: _*). + settings(publishSettings: _*). + settings( + libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value, + scalacOptions += "-Xfatal-warnings", + crossScalaVersions := pluginScalaVersions, + // Must be published for Scala minor version + crossVersion := CrossVersion.full, + crossTarget := { + // workaround for https://github.com/sbt/sbt/issues/5097 + target.value / s"scala-${scalaVersion.value}" + }, + // Only publish for Scala 2.12 + publish / skip := !scalaVersion.value.startsWith("2.12") + ) + +lazy val usePluginSettings = Seq( + scalacOptions in Compile ++= { + val jar = (plugin / Compile / Keys.`package`).value + val addPlugin = "-Xplugin:" + jar.getAbsolutePath + // add plugin timestamp to compiler options to trigger recompile of + // main after editing the plugin. (Otherwise a 'clean' is needed.) + val dummy = "-Jdummy=" + jar.lastModified + Seq(addPlugin, dummy) + } +) + lazy val macros = (project in file("macros")). settings(name := "chisel3-macros"). settings(commonSettings: _*). @@ -162,9 +210,10 @@ lazy val chisel = (project in file(".")). settings(commonSettings: _*). settings(chiselSettings: _*). settings(publishSettings: _*). + settings(usePluginSettings: _*). dependsOn(macros). dependsOn(core). - aggregate(macros, core). + aggregate(macros, core, plugin). settings( scalacOptions in Test ++= Seq("-language:reflectiveCalls"), scalacOptions in Compile in doc ++= Seq( |
