Skip to content

Commit e186c68

Browse files
committed
Simplify Mill cross-build to only include major version
This simplifies commands from, e.g. `mill chisel[2.13.18].compile` to just `mill chisel[2.13].compile`. This makes it such that we no longer have to change CI and documentation whenever we add support for a new minor version of Scala.
1 parent 31ba852 commit e186c68

File tree

12 files changed

+39
-23
lines changed

12 files changed

+39
-23
lines changed

.github/workflows/ci-circt-nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
matrix:
5050
system: ["ubuntu-24.04"]
5151
jvm: [21]
52-
scala: ["2.13.18"]
52+
scala: ["2.13"]
5353
espresso: ["2.4"]
5454
slang: ["7.0"]
5555
circt: ["nightly"]

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
matrix:
2020
system: ["ubuntu-24.04"]
2121
jvm: [21]
22-
scala: ["2.13.18"]
22+
scala: ["2.13"]
2323
espresso: ["2.4"]
2424
slang: ["7.0"]
2525
uses: ./.github/workflows/test.yml

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
type: number
1616
scala:
1717
description: 'The Scala version to use'
18-
default: '2.13.18'
18+
default: '2.13'
1919
required: true
2020
type: string
2121
espresso:
@@ -265,7 +265,7 @@ jobs:
265265
runs-on: ubuntu-24.04
266266
strategy:
267267
matrix:
268-
scala: ["2.13.18"]
268+
scala: ["2.13"]
269269
steps:
270270
- name: Checkout
271271
uses: actions/checkout@v5

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Most testing can be done on just the Chisel build unit:
8181
```
8282

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

8787
You can test everything with:

benchmark/package.mill

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import mill.contrib.jmh.JmhModule
88
import build._
99

1010
object `package` extends ScalaModule with JmhModule with ScalafmtModule {
11-
def scalaVersion = v.scalaVersion
11+
def scalaVersion = v.defaultScalaVersion
1212
def jmhCoreVersion = v.jmhVersion
1313

14-
override def moduleDeps = Seq(chisel(v.scalaVersion))
14+
override def moduleDeps = Seq(chisel(v.defaultScalaVersion))
1515
}

build.mill

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import mill.scalalib.scalafmt._
1414

1515
object v extends Module {
1616

17+
// Add support for later Scala 2.13 by bumping this.
18+
val scala213MinorVersion: Int = 18
19+
20+
// Bump Scala 3 version by bumping this.
21+
val scala3MinorVersion: String = "3.4"
22+
1723
val javaVersion = {
1824
val rawVersion = sys.props("java.specification.version")
1925
// Older versions of Java started with 1., e.g. 1.8 == 8
@@ -32,18 +38,19 @@ object v extends Module {
3238
// Only publish plugin for 2.13.11+ when using Java > 11, but still
3339
// publish all versions when Java version <= 11.
3440
val pluginScalaCrossVersions = {
35-
val latest213 = 18
3641
val java21Min213 = 11
3742
val minVersion = if (javaVersion > 11) java21Min213 else 0
38-
val versions = minVersion to latest213
43+
val versions = minVersion to scala213MinorVersion
3944
val versionSeq = versions.map(v => s"2.13.$v").toSeq
40-
versionSeq ++ Seq("3.3.4")
45+
versionSeq :+ scalaCrossToVersion("3")
4146
}
4247

43-
val scalaCrossVersions = Seq(
44-
"2.13.18",
45-
"3.3.4"
46-
)
48+
val scalaCrossVersions = Seq("2.13", "3")
49+
50+
def scalaCrossToVersion(major: String): String = major match {
51+
case "2.13" => s"2.13.$scala213MinorVersion"
52+
case "3" => s"3.$scala3MinorVersion"
53+
}
4754

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

@@ -65,7 +72,10 @@ object v extends Module {
6572
}
6673
}
6774

68-
val scalaVersion = scalaCrossVersions.head
75+
def defaultCrossVersion = scalaCrossVersions.head
76+
77+
def defaultScalaVersion = scalaCrossToVersion(defaultCrossVersion)
78+
6979
val jmhVersion = "1.37"
7080
val osLib = mvn"com.lihaoyi::os-lib:0.10.7" // 0.11 requires Java 11
7181
val upickle = mvn"com.lihaoyi::upickle:3.3.1" // upickle 4.0 requires Scala 3.4 (we target Scala 3.3 LTS)
@@ -271,6 +281,8 @@ object circt extends Module {
271281
object chisel extends Cross[Chisel](v.scalaCrossVersions)
272282

273283
trait Chisel extends CrossSbtModule with HasScala2MacroAnno with HasScalaPlugin with ScalafmtModule {
284+
def scalaVersion = v.scalaCrossToVersion(crossScalaVersion)
285+
274286
override def moduleDir = super.moduleDir / os.up
275287
def svsimModule = svsim.cross(crossScalaVersion)
276288
def coreModule = core.cross(crossScalaVersion)

core/package.mill

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object `package` extends Module {
1313
}
1414

1515
trait Core extends CrossSbtModule with HasScala2MacroAnno with HasCommonOptions with ScalafmtModule {
16-
def scalaVersion = crossScalaVersion
16+
def scalaVersion = v.scalaCrossToVersion(crossScalaVersion)
1717

1818
def moduleDir = super.moduleDir / os.up
1919

docs/package.mill

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import build._
1313
/** MDoc project */
1414
object `package` extends SbtModule with HasScalaPlugin with HasCommonOptions {
1515

16-
override def scalaVersion = v.scalaVersion
16+
override def scalaVersion = v.defaultScalaVersion
1717

1818
// This not really a CrossModule but HasScala2Plugin and HasCommonOptions require it
19-
override def crossValue = v.scalaVersion
19+
override def crossValue = v.scalaCrossVersions.head
2020

2121
def pluginModule = plugin.cross()
2222

@@ -25,7 +25,7 @@ object `package` extends SbtModule with HasScalaPlugin with HasCommonOptions {
2525

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

28-
override def moduleDeps = Seq(chisel(v.scalaVersion))
28+
override def moduleDeps = Seq(chisel(crossValue))
2929

3030
// Suppress missing interpolator warnings because mdoc appears to introduce them.
3131
override def extraWarnConf = Seq("msg=possible missing interpolator:s")

firrtl/package.mill

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ trait Firrtl
1818
with HasScala2MacroAnno
1919
with HasCommonOptions
2020
with ScalafmtModule {
21-
def scalaVersion = crossScalaVersion
21+
def scalaVersion = v.scalaCrossToVersion(crossScalaVersion)
2222

2323
def moduleDir = super.moduleDir / os.up
2424

macros/package.mill

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ object `package` extends Module {
1313
}
1414

1515
trait Macros extends CrossSbtModule with HasScala2MacroAnno with HasCommonOptions with ScalafmtModule {
16+
def scalaVersion = v.scalaCrossToVersion(crossScalaVersion)
17+
1618
def moduleDir = super.moduleDir / os.up
1719

1820
override def mvnDeps =

0 commit comments

Comments
 (0)