diff --git a/build.sbt b/build.sbt index cc25c4ee..726a6796 100644 --- a/build.sbt +++ b/build.sbt @@ -1,55 +1,39 @@ // See README.md for license details. -def scalacOptionsVersion(scalaVersion: String): Seq[String] = { - Seq() ++ { - // If we're building with Scala > 2.11, enable the compile option - // switch to support our anonymous Bundle definitions: - // https://github.com/scala/bug/issues/10047 - CrossVersion.partialVersion(scalaVersion) match { - case Some((2, scalaMajor: Long)) if scalaMajor < 12 => Seq() - case _ => Seq("-Xsource:2.11") - } - } -} - -def javacOptionsVersion(scalaVersion: String): Seq[String] = { - Seq() ++ { - // Scala 2.12 requires Java 8. We continue to generate - // Java 7 compatible code for Scala 2.11 - // for compatibility with old clients. - CrossVersion.partialVersion(scalaVersion) match { - case Some((2, scalaMajor: Long)) if scalaMajor < 12 => - Seq("-source", "1.7", "-target", "1.7") - case _ => - Seq("-source", "1.8", "-target", "1.8") - } - } -} - -name := "chisel-module-template" - -version := "3.3-SNAPSHOT" - -scalaVersion := "2.12.10" - -crossScalaVersions := Seq("2.12.10", "2.11.12") - -resolvers ++= Seq( - Resolver.sonatypeRepo("snapshots"), - Resolver.sonatypeRepo("releases") -) - -addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full) - -// Provide a managed dependency on X if -DXVersion="" is supplied on the command line. -val defaultVersions = Seq( - "chisel-iotesters" -> "1.5-SNAPSHOT", - "chiseltest" -> "0.3-SNAPSHOT" +// Common properties shared for a whole build +ThisBuild / scalaVersion := "2.12.12" +// These settings are mainly for publishing, they should be customized by the user +ThisBuild / organization := "edu.berkeley.cs" +ThisBuild / version := "3.3-SNAPSHOT" // SNAPSHOT is used to indicate development + +// A project is a compilation unit +// Many projects are fine with just one (like this example), but complex builds may have multiple +// The properties scoped in "ThisBuild" above are shared between all projects +lazy val chiselTemplate = (project in file(".")) + .settings( + name := "chisel-module-template", + libraryDependencies ++= Seq( + // Fundamentally, Chisel is just a Scala library, so we depend on it as a library + // Chisel 3 is versioning is of the style "3.." + // Chisel maintains binary compatibility between minor versions + // We use '+' to pull newest minor version + "edu.berkeley.cs" %% "chisel3" % "3.3.+", + // By default, dependencies are in the "main" scope, projects also have a "test" scope + // main code lives in "src/main/", test is found in "src/test/" + // The following depenencies will only be available in "src/test/" + "edu.berkeley.cs" %% "chisel-iotesters" % "1.4.+" % "test", + // Leading with a 0 indicates less stability so it's generally good to pin a specific version, + // It's also reasonable to pin specific versions for the above dependencies as well + "edu.berkeley.cs" %% "chiseltest" % "0.2.2" % "test" + ), + scalacOptions ++= Seq( + // Required options for Chisel code + "-Xsource:2.11", + // Recommended options + "-language:reflectiveCalls", + "-deprecation", + "-feature", + "-Xcheckinit" + ) ) -libraryDependencies ++= defaultVersions.map { case (dep, ver) => - "edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", ver) } - -scalacOptions ++= scalacOptionsVersion(scalaVersion.value) - -javacOptions ++= javacOptionsVersion(scalaVersion.value)