Skip to content

Commit

Permalink
build: update build.sc to adapt to mill 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyic00 committed Nov 26, 2023
1 parent bb9ff59 commit 6e005f3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ git submodule update --init --recursive
Run verification:

```shell
mill chiselModule.test.testOnly formal.NutCoreFormalSpec
mill "chiselModule[3.5.4]".test.testOnly formal.NutCoreFormalSpec
```

This will run the test case `formal.NutCoreFormalSpec`, which transforms NutCore
Expand Down
70 changes: 39 additions & 31 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,57 +1,65 @@
import mill._, scalalib._
import coursier.maven.MavenRepository

trait CommonModule extends ScalaModule {
override def scalaVersion = "2.12.13"
object ivys {
val scala = "2.12.13"
val chiselCrossVersions = Map(
"3.5.4" -> (ivy"edu.berkeley.cs::chisel3:3.5.4", ivy"edu.berkeley.cs:::chisel3-plugin:3.5.4"),
)
}

override def scalacOptions = Seq("-Xsource:2.11")
trait CommonModule extends ScalaModule {
override def scalaVersion = ivys.scala
}

trait HasXsource211 extends ScalaModule {
override def scalacOptions = T {
super.scalacOptions() ++ Seq(
"-deprecation",
"-unchecked",
"-feature",
"-language:reflectiveCalls",
"-Xsource:2.11"
trait HasChiselCross extends ScalaModule with Cross.Module[String]{
override def repositoriesTask = T.task {
super.repositoriesTask() ++ Seq(
MavenRepository("https://oss.sonatype.org/content/repositories/snapshots")
)
}
override def ivyDeps = Agg(ivys.chiselCrossVersions(crossValue)._1)
override def scalacPluginIvyDeps = Agg(ivys.chiselCrossVersions(crossValue)._2)
}

trait HasChisel3 extends ScalaModule {
trait HasRiscvSpecCore extends ScalaModule with Cross.Module[String]{
override def repositoriesTask = T.task {
super.repositoriesTask() ++ Seq(
MavenRepository("https://oss.sonatype.org/content/repositories/snapshots"),
MavenRepository("https://s01.oss.sonatype.org/content/repositories/snapshots")
)
}
override def ivyDeps = Agg(
ivy"edu.berkeley.cs::chisel3:3.5.4",
ivy"cn.ac.ios.tis::riscvspeccore:1.0-SNAPSHOT"
)
override def scalacPluginIvyDeps = Agg(
ivy"edu.berkeley.cs:::chisel3-plugin:3.5.4",
ivy"org.scalamacros:::paradise:2.1.1"
)
override def ivyDeps = Agg(ivy"cn.ac.ios.tis::riscvspeccore:1.0.0")
}

trait HasChiselTests extends CrossSbtModule {
object test extends Tests with TestModule.ScalaTest{
override def ivyDeps = Agg(
ivy"org.scalatest::scalatest:3.0.4",
ivy"edu.berkeley.cs::chiseltest:0.5.4"
)
trait HasChiselTests extends SbtModule {
object test extends SbtModuleTests with TestModule.ScalaTest {
override def ivyDeps = Agg(ivy"edu.berkeley.cs::chiseltest:0.5.4")
}
}

object difftest extends SbtModule with CommonModule with HasChisel3 {
trait CommonNS extends SbtModule with CommonModule with HasChiselCross with HasRiscvSpecCore

object difftest extends Cross[CommonNS](ivys.chiselCrossVersions.keys.toSeq){
override def millSourcePath = os.pwd / "difftest"
}

object chiselModule extends CrossSbtModule with HasChisel3 with HasChiselTests with HasXsource211 {
def crossScalaVersion = "2.12.13"
object chiselModule extends Cross[ChiselModule](ivys.chiselCrossVersions.keys.toSeq)

trait ChiselModule extends CommonNS with Cross.Module[String] with HasChiselTests {
override def millSourcePath = os.pwd

override def moduleDeps = super.moduleDeps ++ Seq(
difftest
difftest(crossValue)
)
}

object generator extends Cross[Generator](ivys.chiselCrossVersions.keys.toSeq)

trait Generator extends CommonNS with HasChiselTests with Cross.Module[String] {
private val directory = if (crossValue.startsWith("3")) "chisel3" else "chisel"
override def millSourcePath = os.pwd / "generator" / directory

override def moduleDeps = super.moduleDeps ++ Seq(
chiselModule(crossValue)
)
}

0 comments on commit 6e005f3

Please sign in to comment.