-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sc
195 lines (149 loc) · 5.62 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
import mill._
import mill.scalalib._
import mill.scalalib.publish._
import coursier.maven.MavenRepository
import $ivy.`com.lihaoyi::mill-contrib-buildinfo:$MILL_VERSION`
import mill.contrib.buildinfo.BuildInfo
object chisel3 extends mill.Cross[chisel3CrossModule]("2.12.13")
// The following stanza is searched for and used when preparing releases.
// Please retain it.
// Provide a managed dependency on X if -DXVersion="" is supplied on the command line.
val defaultVersions = Map(
"firrtl" -> "1.5-SNAPSHOT"
)
val testDefaultVersions = Map(
"treadle" -> "1.5-SNAPSHOT"
)
def getVersion(dep: String, org: String = "edu.berkeley.cs") = {
val version = sys.env.getOrElse(dep + "Version", defaultVersions(dep))
ivy"$org::$dep:$version"
}
def getTestVersion(dep: String, org: String = "edu.berkeley.cs") = {
val version = sys.env.getOrElse(dep + "Version", testDefaultVersions(dep))
ivy"$org::$dep:$version"
}
// Since chisel contains submodule core and macros, a CommonModule is needed
trait CommonModule extends CrossSbtModule with PublishModule {
def firrtlModule: Option[PublishModule] = None
def firrtlIvyDeps = if (firrtlModule.isEmpty) Agg(
getVersion("firrtl")
) else Agg.empty[Dep]
def treadleModule: Option[PublishModule] = None
def treadleIvyDeps = if (treadleModule.isEmpty) Agg(
getTestVersion("treadle")
) else Agg.empty[Dep]
override def moduleDeps = super.moduleDeps ++ firrtlModule
override def ivyDeps = super.ivyDeps() ++ firrtlIvyDeps
def publishVersion = "3.5-SNAPSHOT"
// 2.12.10 -> Array("2", "12", "10") -> "12" -> 12
protected def majorVersion = crossScalaVersion.split('.')(1).toInt
override def repositories = super.repositories ++ Seq(
MavenRepository("https://oss.sonatype.org/content/repositories/snapshots"),
MavenRepository("https://oss.sonatype.org/content/repositories/releases")
)
override def scalacOptions = T {
super.scalacOptions() ++ Agg(
"-deprecation",
"-feature"
)
}
private val macroParadise = ivy"org.scalamacros:::paradise:2.1.1"
override def compileIvyDeps = Agg(macroParadise)
override def scalacPluginIvyDeps = Agg(macroParadise)
def pomSettings = PomSettings(
description = artifactName(),
organization = "edu.berkeley.cs",
url = "https://www.chisel-lang.org",
licenses = Seq(License.`Apache-2.0`),
versionControl = VersionControl.github("freechipsproject", "chisel3"),
developers = Seq(
Developer("jackbackrack", "Jonathan Bachrach", "https://eecs.berkeley.edu/~jrb/")
)
)
}
class chisel3CrossModule(val crossScalaVersion: String) extends CommonModule with BuildInfo {
m =>
/** Default behavior assumes `build.sc` in the upper path of `src`.
* This override makes `src` folder stay with `build.sc` in the same directory,
* If chisel3 is used as a sub-project, [[millSourcePath]] should be overridden to the folder where `src` located.
*/
override def millSourcePath = super.millSourcePath / os.up
override def mainClass = T {
Some("chisel3.stage.ChiselMain")
}
override def moduleDeps = super.moduleDeps ++ Seq(macros, core)
override def scalacPluginClasspath = T {
super.scalacPluginClasspath() ++ Agg(
plugin.jar()
)
}
object test extends Tests {
override def scalacPluginClasspath = m.scalacPluginClasspath
override def ivyDeps = m.ivyDeps() ++ Agg(
ivy"org.scalatest::scalatest:3.1.2",
ivy"org.scalatestplus::scalacheck-1-14:3.1.1.1",
ivy"com.github.scopt::scopt:4.0.1"
) ++ m.treadleIvyDeps
override def moduleDeps = super.moduleDeps ++ treadleModule
def testFrameworks = T {
Seq("org.scalatest.tools.Framework")
}
// a sbt-like testOnly command.
// for example, mill -i "chisel3[2.12.12].test.testOnly" "chiselTests.BitwiseOpsSpec"
def testOnly(args: String*) = T.command {
super.runMain("org.scalatest.run", args: _*)
}
}
override def buildInfoPackageName = Some("chisel3")
override def buildInfoMembers = T {
Map(
"buildInfoPackage" -> artifactName(),
"version" -> publishVersion(),
"scalaVersion" -> scalaVersion()
)
}
object macros extends CommonModule {
/** millOuterCtx.segment.pathSegments didn't detect error here. */
override def millSourcePath = m.millSourcePath / "macros"
override def crossScalaVersion = m.crossScalaVersion
override def firrtlModule = m.firrtlModule
}
object core extends CommonModule {
/** millOuterCtx.segment.pathSegments didn't detect error here. */
override def millSourcePath = m.millSourcePath / "core"
override def crossScalaVersion = m.crossScalaVersion
override def moduleDeps = super.moduleDeps ++ Seq(macros)
override def firrtlModule = m.firrtlModule
def scalacOptions = T {
super.scalacOptions() ++ Seq(
"-deprecation",
"-explaintypes",
"-feature",
"-language:reflectiveCalls",
"-unchecked",
"-Xcheckinit",
"-Xlint:infer-any"
)
}
override def generatedSources = T {
Seq(generatedBuildInfo()._2)
}
}
object plugin extends CommonModule {
/** millOuterCtx.segment.pathSegments didn't detect error here. */
override def millSourcePath = m.millSourcePath / "plugin"
override def crossScalaVersion = m.crossScalaVersion
override def firrtlModule = m.firrtlModule
override def ivyDeps = Agg(
ivy"${scalaOrganization()}:scala-library:$crossScalaVersion"
)
def scalacOptions = T {
Seq(
"-Xfatal-warnings"
)
}
override def artifactName = "chisel3-plugin"
}
// make mill publish sbt compatible package
override def artifactName = "chisel3"
}