forked from chipsalliance/rocket-chip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.sc
116 lines (92 loc) · 3.17 KB
/
common.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
import mill._
import mill.scalalib._
import mill.scalalib.publish._
import coursier.maven.MavenRepository
val defaultVersions = Map(
"chisel3" -> "3.5.5",
"chisel3-plugin" -> "3.5.5"
)
def getVersion(dep: String, org: String = "edu.berkeley.cs", cross: Boolean = false) = {
val version = sys.env.getOrElse(dep + "Version", defaultVersions(dep))
if (cross)
ivy"$org:::$dep:$version"
else
ivy"$org::$dep:$version"
}
/** The reason to split build.sc to two file is
* [[CommonRocketChip]] doesn't need to import `$file.chisel3` and `$file.firrtl`.
*
* You can extends from [[CommonRocketChip]] to use rocket-chip as build-from-source dependency.
* When doing this, you may like to override `chisel3Module`, `hardfloatModule`, `configModule`,
* setting them to your favorite commit of those packages.
*
* If you don't override `chisel3Module`, which will default to be `None`,
* and mill will automatically use chisel3 from ivy.
*/
trait CommonRocketChip extends SbtModule with PublishModule {
m =>
object macros extends SbtModule with PublishModule {
override def scalaVersion = T {
m.scalaVersion()
}
override def ivyDeps = T {
m.ivyDeps()
}
override def pomSettings = T {
m.pomSettings()
}
override def publishVersion = T {
m.publishVersion()
}
}
object test extends Tests {
override def scalacPluginClasspath = m.scalacPluginClasspath
override def ivyDeps = m.ivyDeps() ++ Agg(
ivy"org.scalatest::scalatest:3.2.0"
)
def testFrameworks = T {
Seq("org.scalatest.tools.Framework")
}
}
override def millSourcePath = super.millSourcePath / os.up
def chisel3Module: Option[PublishModule] = None
def hardfloatModule: PublishModule
def configModule: PublishModule
def chisel3IvyDeps = if (chisel3Module.isEmpty) Agg(
getVersion("chisel3")
) else Agg.empty[Dep]
override def mainClass = T {
Some("freechips.rocketchip.system.Generator")
}
override def moduleDeps = Seq(macros) ++ chisel3Module :+ hardfloatModule :+ configModule
override def scalacOptions = T {
Seq("-deprecation", "-unchecked")
}
override def ivyDeps = T {
Agg(
ivy"${scalaOrganization()}:scala-reflect:${scalaVersion()}",
ivy"org.json4s::json4s-jackson:3.6.6",
ivy"org.scalatest::scalatest:3.2.0"
) ++ chisel3IvyDeps
}
private val chisel3Plugin = getVersion("chisel3-plugin", cross = true)
override def repositories = super.repositories ++ Seq(
MavenRepository("https://oss.sonatype.org/content/repositories/snapshots"),
MavenRepository("https://oss.sonatype.org/content/repositories/releases")
)
override def scalacPluginIvyDeps = if(chisel3Module.isEmpty) Agg(chisel3Plugin) else Agg.empty[Dep]
def publishVersion = T {
"1.6.0"
}
def pomSettings = T {
PomSettings(
description = artifactName(),
organization = "edu.berkeley.cs",
url = "https://github.com/chipsalliance/rocket-chip",
licenses = Seq(License.`Apache-2.0`, License.`BSD-3-Clause`),
versionControl = VersionControl.github("chipsalliance", "rocket-chip"),
developers = Seq.empty
)
}
override def artifactName = "rocketchip"
}