forked from chipsalliance/chisel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
187 lines (174 loc) · 6.36 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
// See LICENSE for license details.
enablePlugins(SiteScaladocPlugin)
def scalacOptionsVersion(scalaVersion: String): Seq[String] = {
Seq() ++ {
// If we're building with Scala > 2.11, enable the compile option
// switch to support our anonymous Bundle definitions:
// https://github.com/scala/bug/issues/10047
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, scalaMajor: Long)) if scalaMajor < 12 => Seq()
case _ => Seq("-Xsource:2.11")
}
}
}
def javacOptionsVersion(scalaVersion: String): Seq[String] = {
Seq() ++ {
// Scala 2.12 requires Java 8. We continue to generate
// Java 7 compatible code for Scala 2.11
// for compatibility with old clients.
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, scalaMajor: Long)) if scalaMajor < 12 =>
Seq("-source", "1.7", "-target", "1.7")
case _ =>
Seq("-source", "1.8", "-target", "1.8")
}
}
}
val defaultVersions = Map("firrtl" -> "1.3-SNAPSHOT")
lazy val commonSettings = Seq (
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
),
organization := "edu.berkeley.cs",
version := "3.3-SNAPSHOT",
autoAPIMappings := true,
scalaVersion := "2.12.11",
crossScalaVersions := Seq("2.12.11", "2.11.12"),
scalacOptions := Seq("-deprecation", "-feature") ++ scalacOptionsVersion(scalaVersion.value),
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value,
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full),
(scalastyleConfig in Test) := (baseDirectory in root).value / "scalastyle-test-config.xml",
// Use the root project's unmanaged base for all sub-projects.
unmanagedBase := (unmanagedBase in root).value,
// Since we want to examine the classpath to determine if a dependency on firrtl is required,
// this has to be a Task setting.
// Fortunately, allDependencies is a Task Setting, so we can modify that.
allDependencies := {
allDependencies.value ++ Seq("firrtl").collect {
// If we have an unmanaged jar file on the classpath, assume we're to use that,
case dep: String if !(unmanagedClasspath in Compile).value.toString.contains(s"$dep.jar") =>
// otherwise let sbt fetch the appropriate version.
"edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", defaultVersions(dep))
}
}
)
lazy val publishSettings = Seq (
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { x => false },
// Don't add 'scm' elements if we have a git.remoteRepo definition,
// but since we don't (with the removal of ghpages), add them in below.
pomExtra := <url>http://chisel.eecs.berkeley.edu/</url>
<licenses>
<license>
<name>BSD-style</name>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/freechipsproject/chisel3.git</url>
<connection>scm:git:github.com/freechipsproject/chisel3.git</connection>
</scm>
<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",
// sbt 1.2.6 fails with `Symbol 'term org.junit' is missing from the classpath`
// when compiling tests under 2.11.12
// An explicit dependency on junit seems to alleviate this.
libraryDependencies ++= Seq(
"junit" % "junit" % "4.13" % "test",
"org.scalatest" %% "scalatest" % "3.1.2" % "test",
"org.scalatestplus" %% "scalacheck-1-14" % "3.1.1.1" % "test",
"com.github.scopt" %% "scopt" % "3.7.1"
),
javacOptions ++= javacOptionsVersion(scalaVersion.value)
) ++ (
// 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 )
}
)
lazy val macros = (project in file("macros")).
settings(name := "chisel3-macros").
settings(commonSettings: _*).
settings(publishSettings: _*)
lazy val core = (project in file("core")).
settings(commonSettings: _*).
settings(publishSettings: _*).
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(BuildInfoPlugin).
enablePlugins(ScalaUnidocPlugin).
settings(
buildInfoPackage := name.value,
buildInfoUsePackageAsPath := true,
buildInfoKeys := Seq[BuildInfoKey](buildInfoPackage, version, scalaVersion, sbtVersion)
).
settings(commonSettings: _*).
settings(chiselSettings: _*).
settings(publishSettings: _*).
dependsOn(macros).
dependsOn(core).
aggregate(macros, core).
settings(
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/freechipsproject/chisel3/tree/$branch/€{FILE_PATH}.scala"
}
)
)