forked from chipsalliance/chisel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.sc
179 lines (129 loc) · 3.61 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
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
import mill._
import mill.scalalib._
// 12 or 13
private def majorScalaVersion(scalaVersion: String) = scalaVersion.split('.')(1).toInt
trait HasMacroAnnotations
extends ScalaModule {
def macroParadiseIvy: Option[Dep]
def scalacPluginIvyDeps = super.scalacPluginIvyDeps() ++ macroParadiseIvy
override def scalacOptions = T {
if (scalaVersion() == 12) {
require(macroParadiseIvy.isDefined, "macroParadiseIvy must be defined for Scala 2.12")
}
super.scalacOptions() ++
(if (majorScalaVersion(scalaVersion()) == 13) Agg("-Ymacro-annotations") else Agg.empty[String])
}
}
trait MacrosModule
extends ScalaModule
with HasMacroAnnotations {
def scalaReflectIvy: Dep
override def ivyDeps = super.ivyDeps() ++ Some(scalaReflectIvy)
override def scalacPluginIvyDeps = super.scalacPluginIvyDeps() ++ macroParadiseIvy
}
trait FirrtlModule
extends ScalaModule
with HasMacroAnnotations {
def osLibModuleIvy: Dep
def json4sIvy: Dep
def dataclassIvy: Dep
def commonTextIvy: Dep
def scoptIvy: Dep
override def ivyDeps = super.ivyDeps() ++ Agg(
osLibModuleIvy,
json4sIvy,
dataclassIvy,
commonTextIvy,
scoptIvy
)
}
trait SvsimModule
extends ScalaModule {
}
trait SvsimUnitTestModule
extends ScalaModule {
def svsimModule: SvsimModule
def scalatestIvy: Dep
def scalacheckIvy: Dep
override def moduleDeps = Seq(svsimModule)
override def ivyDeps = super.ivyDeps() ++ Agg(
scalatestIvy,
scalacheckIvy
)
}
trait FirrtlUnitTestModule
extends TestModule
with ScalaModule
with TestModule.ScalaTest {
def firrtlModule: FirrtlModule
def scalatestIvy: Dep
def scalacheckIvy: Dep
override def moduleDeps = Seq(firrtlModule)
override def ivyDeps = super.ivyDeps() ++ Agg(
scalatestIvy,
scalacheckIvy
)
}
trait CoreModule
extends ScalaModule
with HasMacroAnnotations {
def firrtlModule: FirrtlModule
def macrosModule: MacrosModule
def osLibModuleIvy: Dep
def upickleModuleIvy: Dep
override def moduleDeps = super.moduleDeps ++ Seq(macrosModule, firrtlModule)
override def ivyDeps = super.ivyDeps() ++ Agg(
osLibModuleIvy,
upickleModuleIvy
)
}
trait PluginModule
extends ScalaModule {
def scalaLibraryIvy: Dep
def scalaReflectIvy: Dep
def scalaCompilerIvy: Dep
override def ivyDeps = super.ivyDeps() ++ Agg(scalaLibraryIvy, scalaReflectIvy, scalaCompilerIvy)
}
trait HasChiselPlugin
extends ScalaModule {
def pluginModule: PluginModule
override def scalacOptions = T {
super.scalacOptions() ++ Agg(s"-Xplugin:${pluginModule.jar().path}")
}
override def scalacPluginClasspath = T {
super.scalacPluginClasspath() ++ Agg(
pluginModule.jar()
)
}
}
trait StdLibModule
extends ScalaModule
with HasChiselPlugin {
def chiselModule: ChiselModule
override def moduleDeps = super.moduleDeps ++ Seq(chiselModule)
}
trait ChiselModule
extends ScalaModule
with HasChiselPlugin
with HasMacroAnnotations {
def macrosModule: MacrosModule
def svsimModule: SvsimModule
def coreModule: CoreModule
override def scalacPluginClasspath = T(super.scalacPluginClasspath() ++ Agg(pluginModule.jar()))
override def moduleDeps = super.moduleDeps ++ Seq(macrosModule, coreModule, svsimModule)
}
trait ChiselUnitTestModule
extends TestModule
with ScalaModule
with HasChiselPlugin
with HasMacroAnnotations
with TestModule.ScalaTest {
def chiselModule: ChiselModule
def scalatestIvy: Dep
def scalacheckIvy: Dep
override def moduleDeps = Seq(chiselModule)
override def ivyDeps = super.ivyDeps() ++ Agg(
scalatestIvy,
scalacheckIvy
)
}