Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-circt-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
matrix:
system: ["ubuntu-24.04"]
jvm: [21]
scala: ["2.13.18"]
scala: ["2.13"]
espresso: ["2.4"]
slang: ["7.0"]
circt: ["nightly"]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
matrix:
system: ["ubuntu-24.04"]
jvm: [21]
scala: ["2.13.18"]
scala: ["2.13"]
espresso: ["2.4"]
slang: ["7.0"]
uses: ./.github/workflows/test.yml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
type: number
scala:
description: 'The Scala version to use'
default: '2.13.18'
default: '2.13'
required: true
type: string
espresso:
Expand Down Expand Up @@ -265,7 +265,7 @@ jobs:
runs-on: ubuntu-24.04
strategy:
matrix:
scala: ["2.13.18"]
scala: ["2.13"]
steps:
- name: Checkout
uses: actions/checkout@v5
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Most testing can be done on just the Chisel build unit:
```

The `[]` exists because we are cross-compiling between Scala 2.13 and Scala 3.
You can pick a specific version, e.g. `./mill chisel[2.13.18]`.
You can pick a specific version, e.g. `./mill chisel[2.13]`.
Using `[]` will pick the first version in the list of supported versions which one can think about as the "default" version.

You can test everything with:
Expand Down
4 changes: 2 additions & 2 deletions benchmark/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import mill.contrib.jmh.JmhModule
import build._

object `package` extends ScalaModule with JmhModule with ScalafmtModule {
def scalaVersion = v.scalaVersion
def scalaVersion = v.defaultScalaVersion
def jmhCoreVersion = v.jmhVersion

override def moduleDeps = Seq(chisel(v.scalaVersion))
override def moduleDeps = Seq(chisel(v.scalaVersionToCross(v.defaultScalaVersion)))
}
49 changes: 37 additions & 12 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import mill.scalalib.scalafmt._

object v extends Module {

// Add support for later Scala 2.13 by bumping this.
val scala213MinorVersion: Int = 18

// Bump Scala 3 version by bumping this.
val scala3MinorVersion: String = "3.4"

val javaVersion = {
val rawVersion = sys.props("java.specification.version")
// Older versions of Java started with 1., e.g. 1.8 == 8
Expand All @@ -32,20 +38,26 @@ object v extends Module {
// Only publish plugin for 2.13.11+ when using Java > 11, but still
// publish all versions when Java version <= 11.
val pluginScalaCrossVersions = {
val latest213 = 18
val java21Min213 = 11
val minVersion = if (javaVersion > 11) java21Min213 else 0
val versions = minVersion to latest213
val versions = minVersion to scala213MinorVersion
val versionSeq = versions.map(v => s"2.13.$v").toSeq
versionSeq ++ Seq("3.3.4")
versionSeq :+ scalaCrossToVersion("3")
}

val scalaCrossVersions = Seq(
"2.13.18",
"3.3.4"
)
val scalaCrossVersions = Seq("2.13", "3")

def scalaCrossToVersion(major: String): String = major match {
case "2.13" => s"2.13.$scala213MinorVersion"
case "3" => s"3.$scala3MinorVersion"
}

def scalaVersionToCross(version: String): String =
if (version.startsWith("2.13")) "2.13"
else if (version.startsWith("3.")) "3"
else throw new Exception(s"Unsupported version $version")

def isScala3(ver: String): Boolean = ver.startsWith("3.")
def isScala3(ver: String): Boolean = ver.startsWith("3")

def buildUnits(): Seq[ScalaModule] = {
scalaCrossVersions.flatMap { ver =>
Expand All @@ -65,7 +77,10 @@ object v extends Module {
}
}

val scalaVersion = scalaCrossVersions.head
def defaultCrossVersion = scalaCrossVersions.head

def defaultScalaVersion = scalaCrossToVersion(defaultCrossVersion)

val jmhVersion = "1.37"
val osLib = mvn"com.lihaoyi::os-lib:0.10.7" // 0.11 requires Java 11
val upickle = mvn"com.lihaoyi::upickle:3.3.1" // upickle 4.0 requires Scala 3.4 (we target Scala 3.3 LTS)
Expand Down Expand Up @@ -181,6 +196,15 @@ def latestStableVersion() = Task.Command {
docs.latestStableVersion()
}

/** Our base trait that helps with our simplified cross versioning (2.13 instead of 2.13.18)
*
* Keep this lean, it's mixed in to firrtl and svsim as well.
*/
trait ChiselCrossModule extends CrossSbtModule {
protected def _scalaVersion = v.scalaCrossToVersion(crossScalaVersion)
def scalaVersion = _scalaVersion
}

trait HasScala2MacroAnno extends CrossModuleBase {
override def scalacOptions = Task {
if (!v.isScala3(crossScalaVersion)) {
Expand All @@ -189,9 +213,10 @@ trait HasScala2MacroAnno extends CrossModuleBase {
}
}

trait HasScalaPlugin extends CrossModuleBase {
trait HasScalaPlugin extends ChiselCrossModule {
import build_.plugin.Plugin
def pluginModule: Plugin

def pluginModule: Plugin = plugin.cross(_scalaVersion)

override def scalacOptions = Task {
super.scalacOptions() ++ Seq(s"-Xplugin:${pluginModule.jar().path}")
Expand Down Expand Up @@ -271,10 +296,10 @@ object circt extends Module {
object chisel extends Cross[Chisel](v.scalaCrossVersions)

trait Chisel extends CrossSbtModule with HasScala2MacroAnno with HasScalaPlugin with ScalafmtModule {

override def moduleDir = super.moduleDir / os.up
def svsimModule = svsim.cross(crossScalaVersion)
def coreModule = core.cross(crossScalaVersion)
def pluginModule = plugin.cross()

override def scalacOptions = Task {
if (v.isScala3(crossScalaVersion)) {
Expand Down
3 changes: 1 addition & 2 deletions core/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ object `package` extends Module {
object cross extends Cross[Core](v.scalaCrossVersions)
}

trait Core extends CrossSbtModule with HasScala2MacroAnno with HasCommonOptions with ScalafmtModule {
def scalaVersion = crossScalaVersion
trait Core extends ChiselCrossModule with HasScala2MacroAnno with HasCommonOptions with ScalafmtModule {

def moduleDir = super.moduleDir / os.up

Expand Down
10 changes: 4 additions & 6 deletions docs/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@ import mill.util.Jvm
import build._

/** MDoc project */
object `package` extends SbtModule with HasScalaPlugin with HasCommonOptions {
object `package` extends HasScalaPlugin with HasCommonOptions {

override def scalaVersion = v.scalaVersion
override def scalaVersion = v.defaultScalaVersion

// This not really a CrossModule but HasScala2Plugin and HasCommonOptions require it
override def crossValue = v.scalaVersion

def pluginModule = plugin.cross()
override def crossValue = v.scalaCrossVersions.head

// Our scala sources to be used by mdoc live here
override def moduleDir = super.moduleDir / os.up / "docs-target"

override def mvnDeps = Task { Seq(v.mdoc, v.scalatest) }

override def moduleDeps = Seq(chisel(v.scalaVersion))
override def moduleDeps = Seq(chisel(crossValue))

// Suppress missing interpolator warnings because mdoc appears to introduce them.
override def extraWarnConf = Seq("msg=possible missing interpolator:s")
Expand Down
8 changes: 1 addition & 7 deletions firrtl/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ object `package` extends Module {
object cross extends Cross[Firrtl](v.scalaCrossVersions)
}

trait Firrtl
extends CrossSbtModule
with Cross.Module[String]
with HasScala2MacroAnno
with HasCommonOptions
with ScalafmtModule {
def scalaVersion = crossScalaVersion
trait Firrtl extends ChiselCrossModule with HasScala2MacroAnno with HasCommonOptions with ScalafmtModule {

def moduleDir = super.moduleDir / os.up

Expand Down
6 changes: 3 additions & 3 deletions integration-tests/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ object `package` extends Module {
object cross extends Cross[IntegrationTests](v.scalaCrossVersions)
}

trait IntegrationTests extends CrossSbtModule with HasScalaPlugin with HasCommonOptions with ScalafmtModule {
def pluginModule = plugin.cross()
trait IntegrationTests extends HasScalaPlugin with HasCommonOptions with ScalafmtModule {

def moduleDir = super.moduleDir / os.up

// TODO enable
override def xsource3 = false

object test extends CrossSbtTests with TestModule.ScalaTest with ScalafmtModule {
override def moduleDeps = super.moduleDeps :+ chisel().test
override def moduleDeps = super.moduleDeps :+ chisel(crossScalaVersion).test
def mvnDeps = Seq(v.scalatest, v.scalacheck)

override def testForkGrouping = discoveredTestClasses().grouped(8).toSeq
Expand Down
1 change: 0 additions & 1 deletion lit/utility/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ trait LitUtility extends ScalaModule with CrossModuleBase with HasScalaPlugin wi
override def scalacOptions = Task { Seq("-Ymacro-annotations") }

def chiselModule = chisel(crossScalaVersion)
def pluginModule = plugin.cross(crossScalaVersion)
def moduleDir = super.moduleDir / os.up

override def moduleDeps = super.moduleDeps ++ Some(chiselModule)
Expand Down
3 changes: 2 additions & 1 deletion macros/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ object `package` extends Module {
object cross extends Cross[Macros](v.scalaCrossVersions)
}

trait Macros extends CrossSbtModule with HasScala2MacroAnno with HasCommonOptions with ScalafmtModule {
trait Macros extends ChiselCrossModule with HasScala2MacroAnno with HasCommonOptions with ScalafmtModule {

def moduleDir = super.moduleDir / os.up

override def mvnDeps =
Expand Down
6 changes: 3 additions & 3 deletions release.mill
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ trait ChiselPublishModule extends SonatypeCentralPublishModule {
*/
trait Unipublish extends ScalaModule with ChiselPublishModule with Mima {

def scalaVersion = v.scalaVersion
def scalaVersion = v.defaultScalaVersion

/** Is this a SNAPSHOT release? */
def isSnapshot = Task { publishVersion().endsWith("-SNAPSHOT") }
Expand Down Expand Up @@ -71,12 +71,12 @@ trait Unipublish extends ScalaModule with ChiselPublishModule with Mima {
transitive: Boolean = false
) = Task.Command {
// TODO consider making this parallel and publishing all cross-versions for plugin
plugin.cross(v.scalaVersion).publishLocal(localMvnRepo, sources, doc, transitive)()
plugin.cross(v.defaultScalaVersion).publishLocal(localMvnRepo, sources, doc, transitive)()
super.publishLocal(localMvnRepo, sources, doc, transitive)()
}

// Explicitly not using moduleDeps because that influences so many things
def components = Seq(firrtl.cross, svsim.cross, macros.cross, core.cross, chisel).map(_(v.scalaVersion))
def components = Seq(firrtl.cross, svsim.cross, macros.cross, core.cross, chisel).map(_(v.defaultCrossVersion))

/** Aggregated mvn deps to include as dependencies in POM */
def mvnDeps = Task { Task.traverse(components)(_.mvnDeps)().flatten }
Expand Down
6 changes: 3 additions & 3 deletions stdlib/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ object `package` extends Module {
object cross extends Cross[Stdlib](v.scalaCrossVersions)
}

trait Stdlib extends CrossSbtModule with HasScalaPlugin with HasCommonOptions with ScalafmtModule {
trait Stdlib extends HasScalaPlugin with HasCommonOptions with ScalafmtModule {
def moduleDir = super.moduleDir / os.up

def chiselModule = chisel(crossScalaVersion)
def pluginModule = plugin.cross(crossScalaVersion)

override def moduleDeps = Seq(chiselModule, pluginModule)
override def moduleDeps = Seq(chiselModule)
}
3 changes: 2 additions & 1 deletion svsim/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ object `package` extends Module {
object cross extends Cross[Svsim](v.scalaCrossVersions)
}

trait Svsim extends CrossSbtModule with HasCommonOptions with ScalafmtModule {
trait Svsim extends ChiselCrossModule with HasCommonOptions with ScalafmtModule {

def moduleDir = super.moduleDir / os.up

override def scalacOptions = Task {
Expand Down