-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
242 lines (223 loc) · 7.23 KB
/
build.sbt
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
// See LICENSE for license details.
enablePlugins(SiteScaladocPlugin)
val defaultVersions = Map(
"firrtl" -> "edu.berkeley.cs" %% "firrtl" % "1.5-SNAPSHOT",
"treadle" -> "edu.berkeley.cs" %% "treadle" % "1.5-SNAPSHOT"
)
lazy val commonSettings = Seq (
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
),
organization := "edu.berkeley.cs",
version := "3.5-SNAPSHOT",
autoAPIMappings := true,
scalaVersion := "2.13.5",
crossScalaVersions := Seq("2.13.5", "2.12.13"),
scalacOptions := Seq("-deprecation", "-feature"),
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value,
// Macros paradise is integrated into 2.13 but requires a scalacOption
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 13 => "-Ymacro-annotations" :: Nil
case _ => Nil
}
},
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 13 => Nil
case _ => compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full) :: Nil
}
}
)
lazy val publishSettings = Seq (
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { x => false },
pomExtra := <url>http://chisel.eecs.berkeley.edu/</url>
<licenses>
<license>
<name>apache-v2</name>
<url>https://opensource.org/licenses/Apache-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>jackbackrack</id>
<name>Jonathan Bachrach</name>
<url>http://www.eecs.berkeley.edu/~jrb/</url>
</developer>
</developers>,
publishTo := {
val v = version.value
val nexus = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT")) {
Some("snapshots" at nexus + "content/repositories/snapshots")
}
else {
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
}
)
lazy val chiselSettings = Seq (
name := "chisel3",
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.1.2" % "test",
"org.scalatestplus" %% "scalacheck-1-14" % "3.1.1.1" % "test",
"com.github.scopt" %% "scopt" % "4.0.1"
),
) ++ (
// Tests from other projects may still run concurrently
// if we're not running with -DminimalResources.
// Another option would be to experiment with:
// concurrentRestrictions in Global += Tags.limit(Tags.Test, 1),
sys.props.contains("minimalResources") match {
case true => Seq( Test / parallelExecution := false )
case false => Seq( fork := true,
Test / testForkedParallel := true )
}
)
autoCompilerPlugins := true
// Plugin must be fully cross-versioned (published for Scala minor version)
// The plugin only works in Scala 2.12+
lazy val pluginScalaVersions = Seq(
// scalamacros paradise version used is not published for 2.12.0 and 2.12.1
"2.12.2",
"2.12.3",
"2.12.4",
"2.12.5",
"2.12.6",
"2.12.7",
"2.12.8",
"2.12.9",
"2.12.10",
"2.12.11",
"2.12.12",
"2.12.13",
"2.13.0",
"2.13.1",
"2.13.2",
"2.13.3",
"2.13.4",
"2.13.5"
)
lazy val plugin = (project in file("plugin")).
settings(name := "chisel3-plugin").
settings(commonSettings: _*).
settings(publishSettings: _*).
settings(
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value,
scalacOptions += "-Xfatal-warnings",
crossScalaVersions := pluginScalaVersions,
// Must be published for Scala minor version
crossVersion := CrossVersion.full,
crossTarget := {
// workaround for https://github.com/sbt/sbt/issues/5097
target.value / s"scala-${scalaVersion.value}"
}
).
settings(
mimaPreviousArtifacts := {
Set()
}
)
lazy val usePluginSettings = Seq(
scalacOptions in Compile ++= {
val jar = (plugin / Compile / Keys.`package`).value
val addPlugin = "-Xplugin:" + jar.getAbsolutePath
// add plugin timestamp to compiler options to trigger recompile of
// main after editing the plugin. (Otherwise a 'clean' is needed.)
val dummy = "-Jdummy=" + jar.lastModified
Seq(addPlugin, dummy)
}
)
lazy val macros = (project in file("macros")).
settings(name := "chisel3-macros").
settings(commonSettings: _*).
settings(publishSettings: _*).
settings(mimaPreviousArtifacts := Set())
lazy val firrtlRef = ProjectRef(workspaceDirectory / "firrtl", "firrtl")
lazy val core = (project in file("core")).
sourceDependency(firrtlRef, defaultVersions("firrtl")).
settings(commonSettings: _*).
enablePlugins(BuildInfoPlugin).
settings(
buildInfoPackage := "chisel3",
buildInfoUsePackageAsPath := true,
buildInfoKeys := Seq[BuildInfoKey](buildInfoPackage, version, scalaVersion, sbtVersion)
).
settings(publishSettings: _*).
settings(mimaPreviousArtifacts := Set()).
settings(
name := "chisel3-core",
scalacOptions := scalacOptions.value ++ Seq(
"-deprecation",
"-explaintypes",
"-feature",
"-language:reflectiveCalls",
"-unchecked",
"-Xcheckinit",
"-Xlint:infer-any"
// , "-Xlint:missing-interpolator"
)
).
dependsOn(macros)
// This will always be the root project, even if we are a sub-project.
lazy val root = RootProject(file("."))
lazy val chisel = (project in file(".")).
enablePlugins(ScalaUnidocPlugin).
settings(commonSettings: _*).
settings(chiselSettings: _*).
settings(publishSettings: _*).
settings(usePluginSettings: _*).
dependsOn(macros).
dependsOn(core).
aggregate(macros, core, plugin).
settings(
mimaPreviousArtifacts := Set(),
libraryDependencies += defaultVersions("treadle") % "test",
scalacOptions in Test ++= Seq("-language:reflectiveCalls"),
scalacOptions in Compile in doc ++= Seq(
"-diagrams",
"-groups",
"-skip-packages", "chisel3.internal",
"-diagrams-max-classes", "25",
"-doc-version", version.value,
"-doc-title", name.value,
"-doc-root-content", baseDirectory.value+"/root-doc.txt",
"-sourcepath", (baseDirectory in ThisBuild).value.toString,
"-doc-source-url",
{
val branch =
if (version.value.endsWith("-SNAPSHOT")) {
"master"
} else {
s"v${version.value}"
}
s"https://github.com/chipsalliance/chisel3/tree/$branch€{FILE_PATH_EXT}#L€{FILE_LINE}"
}
)
)
lazy val noPluginTests = (project in file ("no-plugin-tests")).
dependsOn(chisel).
settings(commonSettings: _*).
settings(chiselSettings: _*)
lazy val docs = project // new documentation project
.in(file("docs-target")) // important: it must not be docs/
.dependsOn(chisel)
.enablePlugins(MdocPlugin)
.settings(usePluginSettings: _*)
.settings(commonSettings)
.settings(
scalacOptions += "-language:reflectiveCalls",
mdocIn := file("docs/src"),
mdocOut := file("docs/generated"),
mdocExtraArguments := Seq("--cwd", "docs"),
mdocVariables := Map(
"BUILD_DIR" -> "docs-target" // build dir for mdoc programs to dump temp files
)
)
addCommandAlias("com", "all compile")
addCommandAlias("lint", "; compile:scalafix --check ; test:scalafix --check")
addCommandAlias("fix", "all compile:scalafix test:scalafix")