forked from chipsalliance/chisel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sc
306 lines (231 loc) · 8.77 KB
/
build.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
import mill._
import mill.scalalib._
import mill.scalalib.publish._
import mill.scalalib.scalafmt._
import mill.define.Cross
import mill.scalalib.api.ZincWorkerUtil.matchingVersions
import $file.common
import $file.tests
object v {
val pluginScalaCrossVersions = Seq(
"2.13.11",
"2.13.12"
)
val scalaCrossVersions = Seq(
"2.13.12"
)
val osLib = ivy"com.lihaoyi::os-lib:0.9.1"
val upickle = ivy"com.lihaoyi::upickle:3.1.0"
val firtoolResolver = ivy"org.chipsalliance::firtool-resolver:2.0.0"
val scalatest = ivy"org.scalatest::scalatest:3.2.14"
val scalacheck = ivy"org.scalatestplus::scalacheck-1-15:3.2.11.0"
val json4s = ivy"org.json4s::json4s-native:4.0.6"
val dataclass = ivy"io.github.alexarchambault::data-class:0.2.5"
val commonText = ivy"org.apache.commons:commons-text:1.10.0"
val scopt = ivy"com.github.scopt::scopt:3.7.1"
def scalaReflect(scalaVersion: String) = ivy"org.scala-lang:scala-reflect:$scalaVersion"
def scalaCompiler(scalaVersion: String) = ivy"org.scala-lang:scala-compiler:$scalaVersion"
def scalaLibrary(scalaVersion: String) = ivy"org.scala-lang:scala-library:$scalaVersion"
}
object firrtl extends Cross[Firrtl](v.scalaCrossVersions)
trait Firrtl
extends common.FirrtlModule
with ChiselPublishModule
with CrossSbtModule
with ScalafmtModule {
def millSourcePath = super.millSourcePath / os.up / "firrtl"
def osLibModuleIvy = v.osLib
def json4sIvy = v.json4s
def dataclassIvy = v.dataclass
def commonTextIvy = v.commonText
def scoptIvy = v.scopt
}
object svsim extends Cross[Svsim](v.scalaCrossVersions)
trait Svsim
extends common.SvsimModule
with ChiselPublishModule
with CrossSbtModule
with ScalafmtModule {
def millSourcePath = super.millSourcePath / os.up / "svsim"
}
object firrtlut extends Cross[FirrtlUnitTest](v.scalaCrossVersions)
trait FirrtlUnitTest
extends tests.FirrtlUnitTestModule
with CrossModuleBase
with ScalafmtModule {
override def millSourcePath = firrtl(crossScalaVersion).millSourcePath
def firrtlModule = firrtl(crossScalaVersion)
def scalatestIvy = v.scalatest
def scalacheckIvy = v.scalacheck
override def sources = T.sources {
Seq(PathRef(millSourcePath / "src" / "test")) ++
matchingVersions(crossScalaVersion).map(s => PathRef(millSourcePath / "src" / "test" / s"scala-$s"))
}
}
object macros extends Cross[Macros](v.scalaCrossVersions)
trait Macros
extends common.MacrosModule
with ChiselPublishModule
with CrossSbtModule
with ScalafmtModule {
def millSourcePath = super.millSourcePath / os.up / "macros"
def scalaReflectIvy = v.scalaReflect(crossScalaVersion)
}
object core extends Cross[Core](v.scalaCrossVersions)
trait Core
extends common.CoreModule
with ChiselPublishModule
with CrossSbtModule
with ScalafmtModule {
def millSourcePath = super.millSourcePath / os.up / "core"
def firrtlModule = firrtl(crossScalaVersion)
def macrosModule = macros(crossScalaVersion)
def osLibModuleIvy = v.osLib
def upickleModuleIvy = v.upickle
def firtoolResolverModuleIvy = v.firtoolResolver
def firtoolVersion = T {
val contents = os.read(millSourcePath / os.up / "etc" / "circt.json")
val read = upickle.default.read[Map[String, String]](contents)
read("version").stripPrefix("firtool-")
}
def buildVersion = T("build-from-source")
private def generateBuildInfo = T {
val outputFile = T.dest / "chisel3" / "BuildInfo.scala"
val firtoolVersionString = "Some(\"" + firtoolVersion() + "\")"
val contents =
s"""
|package chisel3
|case object BuildInfo {
| val buildInfoPackage: String = "${artifactName()}"
| val version: String = "${buildVersion()}"
| val scalaVersion: String = "${scalaVersion()}"
| val firtoolVersion: scala.Option[String] = $firtoolVersionString
| override val toString: String = {
| "buildInfoPackage: %s, version: %s, scalaVersion: %s, firtoolVersion %s".format(
| buildInfoPackage, version, scalaVersion, firtoolVersion
| )
| }
|}
|""".stripMargin
os.write(outputFile, contents, createFolders = true)
PathRef(T.dest)
}
override def generatedSources = T {
super.generatedSources() :+ generateBuildInfo()
}
}
object plugin extends Cross[Plugin](v.pluginScalaCrossVersions)
trait Plugin
extends common.PluginModule
with ChiselPublishModule
with CrossSbtModule
with ScalafmtModule {
def millSourcePath = super.millSourcePath / os.up / "plugin"
def scalaLibraryIvy = v.scalaLibrary(crossScalaVersion)
def scalaReflectIvy = v.scalaReflect(crossScalaVersion)
def scalaCompilerIvy: Dep = v.scalaCompiler(crossScalaVersion)
}
object chisel extends Cross[Chisel](v.scalaCrossVersions)
trait Chisel
extends common.ChiselModule
with ChiselPublishModule
with CrossSbtModule
with ScalafmtModule {
override def millSourcePath = super.millSourcePath / os.up
def svsimModule = svsim(crossScalaVersion)
def macrosModule = macros(crossScalaVersion)
def coreModule = core(crossScalaVersion)
def pluginModule = plugin(crossScalaVersion)
}
object chiselut extends Cross[ChiselUnitTest](v.scalaCrossVersions)
trait ChiselUnitTest
extends tests.ChiselUnitTestModule
with CrossModuleBase
with ScalafmtModule {
override def millSourcePath = chisel(crossScalaVersion).millSourcePath
def chiselModule = chisel(crossScalaVersion)
def pluginModule = plugin(crossScalaVersion)
def scalatestIvy = v.scalatest
def scalacheckIvy = v.scalacheck
override def sources = T.sources {
Seq(PathRef(millSourcePath / "src" / "test")) ++
matchingVersions(crossScalaVersion).map(s => PathRef(millSourcePath / "src" / "test" / s"scala-$s"))
}
}
object stdlib extends Cross[Stdlib](v.scalaCrossVersions)
trait Stdlib
extends common.StdLibModule
with ChiselPublishModule
with CrossSbtModule
with ScalafmtModule {
def millSourcePath = super.millSourcePath / os.up / "stdlib"
def chiselModule = chisel(crossScalaVersion)
def pluginModule = plugin(crossScalaVersion)
}
trait ChiselPublishModule extends PublishModule {
def pomSettings = PomSettings(
description = artifactName(),
organization = "org.chipsalliance",
url = "https://www.chisel-lang.org",
licenses = Seq(License.`Apache-2.0`),
versionControl = VersionControl.github("chipsalliance", "chisel"),
developers = Seq()
)
def publishVersion = "5.0-SNAPSHOT"
}
object circtpanamabinding extends CIRCTPanamaBinding
trait CIRCTPanamaBinding
extends common.CIRCTPanamaBindingModule
with ChiselPublishModule {
def header = T(PathRef(millSourcePath / "jextract-headers.h"))
def circtInstallPath = T.input(os.Path(T.ctx().env.get("CIRCT_INSTALL_PATH").getOrElse("/usr/local")))
def includePaths = T(Seq(PathRef(circtInstallPath() / "include")))
def libraryPaths = T(Seq(PathRef(circtInstallPath() / "lib")))
}
object panamalib extends Cross[PanamaLib](v.scalaCrossVersions)
trait PanamaLib
extends common.PanamaLibModule
with CrossModuleBase
with ChiselPublishModule
with ScalafmtModule {
def circtPanamaBindingModule = circtpanamabinding
}
object panamaom extends Cross[PanamaOM](v.scalaCrossVersions)
trait PanamaOM
extends common.PanamaOMModule
with CrossModuleBase
with ChiselPublishModule
with ScalafmtModule {
def panamaLibModule = panamalib(crossScalaVersion)
}
object panamaconverter extends Cross[PanamaConverter](v.scalaCrossVersions)
trait PanamaConverter
extends common.PanamaConverterModule
with CrossModuleBase
with ChiselPublishModule
with ScalafmtModule {
def panamaOMModule = panamaom(crossScalaVersion)
def chiselModule = chisel(crossScalaVersion)
def pluginModule = plugin(crossScalaVersion)
}
object litutility extends Cross[LitUtility](v.scalaCrossVersions)
trait LitUtility
extends tests.LitUtilityModule
with CrossModuleBase
with ScalafmtModule {
def millSourcePath = super.millSourcePath / os.up / "lit" / "utility"
def panamaConverterModule = panamaconverter(crossScalaVersion)
def panamaOMModule = panamaom(crossScalaVersion)
}
object lit extends Cross[Lit](v.scalaCrossVersions)
trait Lit
extends tests.LitModule
with Cross.Module[String] {
def scalaVersion: T[String] = crossValue
def runClasspath: T[Seq[os.Path]] = T(litutility(crossValue).runClasspath().map(_.path))
def pluginJars: T[Seq[os.Path]] = T(Seq(litutility(crossValue).panamaConverterModule.pluginModule.jar().path))
def javaLibraryPath: T[Seq[os.Path]] = T(litutility(crossValue).panamaConverterModule.circtPanamaBindingModule.libraryPaths().map(_.path))
def javaHome: T[os.Path] = T(os.Path(sys.props("java.home")))
def chiselLitDir: T[os.Path] = T(millSourcePath)
def litConfigIn: T[PathRef] = T.source(millSourcePath / "tests" / "lit.site.cfg.py.in")
}