From 6e005f33409082f08d0c055c2ef6ba131c3da473 Mon Sep 17 00:00:00 2001 From: liuyic00 Date: Sun, 26 Nov 2023 19:46:56 +0800 Subject: [PATCH] build: update build.sc to adapt to mill 0.11 --- README.md | 2 +- build.sc | 70 +++++++++++++++++++++++++++++++------------------------ 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 58aabd63..24d1249d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build.sc b/build.sc index e64637ea..c69da7c1 100644 --- a/build.sc +++ b/build.sc @@ -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) + ) +} \ No newline at end of file