-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.sbt
executable file
·207 lines (186 loc) · 5.07 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
commands += DFHDLCommands.quickTestSetup
// format: off
val projectName = "dfhdl"
val compilerVersion = "3.5.1"
inThisBuild(
List(
homepage := Some(url("https://dfianthdl.github.io/")),
licenses := List(
"LGPL" -> url("https://www.gnu.org/licenses/lgpl-3.0.txt")
),
developers := List(
Developer(
"soronpo",
"Oron Port",
"",
url("https://twitter.com/soronpo")
)
)
)
)
name := projectName
ThisBuild / organization := "io.github.dfianthdl"
ThisBuild / scalaVersion := compilerVersion
ThisBuild / versionScheme := Some("semver-spec")
//ThisBuild / version := "0.3.0-SNAPSHOT"
// PROJECTS
lazy val root = (project in file("."))
.settings(
settings,
publish / skip := true
)
.aggregate(
internals,
plugin,
compiler_ir,
core,
compiler_stages,
lib
)
lazy val internals = project
.settings(
name := s"$projectName-internals",
settings,
libraryDependencies ++= commonDependencies
)
def additionalSources(scalaVersion: String, base: File): Seq[File] = {
CrossVersion.partialVersion(scalaVersion) match {
case Some((3, minor)) if minor <= 4 =>
Seq(base / "src" / "main" / "scala-3.4-")
case Some((3, minor)) if minor >= 5 =>
Seq(base / "src" / "main" / "scala-3.5+")
case _ =>
Seq.empty
}
}
lazy val plugin = project
.settings(
name := s"$projectName-plugin",
settings,
crossTarget := target.value / s"scala-${scalaVersion.value}", // workaround for https://github.com/sbt/sbt/issues/5097
crossVersion := CrossVersion.full,
Compile / unmanagedSourceDirectories ++= {
val base = baseDirectory.value
additionalSources(scalaVersion.value, base)
},
libraryDependencies += "org.scala-lang" %% "scala3-compiler" % compilerVersion % "provided"
).dependsOn(internals)
lazy val compiler_ir = (project in file("compiler/ir"))
.settings(
name := s"$projectName-compiler-ir",
settings
).dependsOn(internals)
lazy val core = project
.settings(
name := s"$projectName-core",
settings,
pluginTestUseSettings,
libraryDependencies ++= commonDependencies :+ dependencies.scalafmt,
Compile / resourceGenerators += Def.task {
val file = (Compile / resourceManaged).value / "version.properties"
val contents = s"version=${version.value}"
IO.write(file, contents)
Seq(file)
}.taskValue
)
.dependsOn(
plugin,
internals,
compiler_ir
)
lazy val compiler_stages = (project in file("compiler/stages"))
.settings(
name := s"$projectName-compiler-stages",
settings,
pluginTestUseSettings,
libraryDependencies ++= commonDependencies
)
.dependsOn(
plugin,
internals,
compiler_ir,
core
)
lazy val lib = project
.settings(
name := projectName,
settings,
pluginUseSettings,
libraryDependencies ++= commonDependencies
)
.dependsOn(
core % "test->test;compile->compile",
compiler_stages
)
// DEPENDENCIES
lazy val dependencies =
new {
private val scodecV = "1.2.1"
private val munitV = "1.0.3"
private val scalafmtV = "3.8.3"
private val airframelogV = "24.12.2"
private val oslibV = "0.9.2"
private val scallopV = "5.2.0"
val scodec = "org.scodec" %% "scodec-bits" % scodecV
val munit = "org.scalameta" %% "munit" % munitV % Test
val scalafmt = ("org.scalameta" %% "scalafmt-dynamic" % scalafmtV).cross(CrossVersion.for3Use2_13)
val airframelog = "org.wvlet.airframe" %% "airframe-log" % airframelogV
val oslib = "com.lihaoyi" %% "os-lib" % oslibV
val scallop = "org.rogach" %% "scallop" % scallopV
}
lazy val commonDependencies = Seq(
dependencies.scodec,
dependencies.munit,
dependencies.airframelog,
dependencies.scallop
)
// SETTINGS
lazy val settings =
commonSettings
def compilerOptionsVersionDependent(scalaVersion: String) = {
CrossVersion.partialVersion(scalaVersion) match {
case Some((3, minor)) if minor <= 4 =>
Seq.empty
case Some((3, minor)) if minor >= 5 =>
Seq.empty
case _ =>
Seq.empty
}
}
lazy val compilerOptions = Seq(
"-unchecked",
"-feature",
"-language:strictEquality",
"-language:implicitConversions",
"-deprecation",
//TODO: remove when fixed scalac issues:
//https://github.com/lampepfl/dotty/issues/19299
"-Wconf:msg=or backticked identifier `equals`:s",
//https://github.com/lampepfl/dotty/issues/19301
"-Wconf:msg=not declared infix:s",
//ignore warning given by the plugin Jdummy dependency trick
"-Wconf:msg=bad option '-Jdummy:s"
)
lazy val pluginUseSettings = Seq(
Compile / scalacOptions ++= {
val jar = (plugin / Compile / packageBin).value
Seq(
s"-Xplugin:${jar.getAbsolutePath}",
s"-Jdummy=${jar.lastModified}"
)
}
)
lazy val pluginTestUseSettings = Seq(
Test / scalacOptions ++= {
val jar = (plugin / Compile / packageBin).value
Seq(
s"-Xplugin:${jar.getAbsolutePath}",
s"-Jdummy=${jar.lastModified}"
)
}
)
lazy val commonSettings = Seq(
scalacOptions ++= {
compilerOptions ++ compilerOptionsVersionDependent(scalaVersion.value)
}
)