forked from es-meta/esmeta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
302 lines (264 loc) · 10.4 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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
import sbtassembly.AssemblyPlugin.defaultUniversalScript
// ESMeta version
// NOTE: please update VERSION together in top-level package.scala
// NOTE: please update version info in the README.md file
ThisBuild / version := "0.3.3"
// Scala version
ThisBuild / scalaVersion := "3.2.2"
// ESMeta organization
ThisBuild / organization := "esmeta"
// Scala options
ThisBuild / scalacOptions := Seq(
"-language:implicitConversions", // allow implicit conversions
"-deprecation", // emit warning and location for usages of deprecated APIs
"-explain", // explain errors in more detail
"-explain-types", // explain type errors in more detail
"-feature", // emit warning for features that should be imported explicitly
"-unchecked", // enable warnings where generated code depends on assumptions
)
// Java options
ThisBuild / javacOptions ++= Seq(
"-encoding",
"UTF-8",
)
// automatic reload build.sbt
Global / onChangedBuildSource := ReloadOnSourceChanges
// Metals requires the semanticdb compiler plugin
Global / semanticdbEnabled := true
// setting for sbt-ghpages with scaladoc
// NOTE: If you want to update gh-pages, use `ghpagesPushSite` command.
// Please carefully use it. See https://index.scala-lang.org/sbt/sbt-ghpages
enablePlugins(GhpagesPlugin)
enablePlugins(SiteScaladocPlugin)
git.remoteRepo := "git@github.com:es-meta/esmeta.git"
// general
lazy val complTest = taskKey[Unit]("Launch .completion validity tests (tiny)")
// basic
lazy val basicTest = taskKey[Unit]("Launch basic tests")
// size
lazy val tinyTest = taskKey[Unit]("Launch tiny tests (maybe milliseconds)")
lazy val smallTest = taskKey[Unit]("Launch small tests (maybe seconds)")
lazy val middleTest = taskKey[Unit]("Launch middle tests (maybe minutes)")
lazy val largeTest = taskKey[Unit]("Launch large tests (may hours)")
// extractor
lazy val extractorTest = taskKey[Unit]("Launch extractor tests")
lazy val extractorValidityTest =
taskKey[Unit]("Launch validity tests for extractor (small)")
// spec
lazy val specTest = taskKey[Unit]("Launch spec tests")
lazy val specStringifyTest =
taskKey[Unit]("Launch stringify tests for spec (tiny)")
lazy val specJsonTest = taskKey[Unit]("Launch JSON tests for spec (tiny)")
// lang
lazy val langTest = taskKey[Unit]("Launch lang tests")
lazy val langStringifyTest =
taskKey[Unit]("Launch stringify tests for lang (tiny)")
lazy val langJsonTest = taskKey[Unit]("Launch JSON tests for lang (tiny)")
// ty
lazy val tyTest = taskKey[Unit]("Launch ty tests")
lazy val tyContainsTest = taskKey[Unit]("Launch contains tests for ty (tiny)")
lazy val tyStringifyTest =
taskKey[Unit]("Launch stringify tests for ty (tiny)")
lazy val tyJsonTest = taskKey[Unit]("Launch JSON tests for ty (tiny)")
// compiler
lazy val compilerTest = taskKey[Unit]("Launch compiler tests")
lazy val compilerValidityTest =
taskKey[Unit]("Launch validity tests for compiler (small)")
// ir
lazy val irTest = taskKey[Unit]("Launch ir tests")
lazy val irStringifyTest = taskKey[Unit]("Launch stringify tests for ir (tiny)")
lazy val irJsonTest = taskKey[Unit]("Launch JSON tests for ir (tiny)")
// cfgBuilder
lazy val cfgBuilderTest = taskKey[Unit]("Launch CFG builder tests")
lazy val cfgBuilderValidityTest =
taskKey[Unit]("Launch validity tests for CFG builder (small)")
// cfg
lazy val cfgTest = taskKey[Unit]("Launch cfg tests")
lazy val cfgStringifyTest =
taskKey[Unit]("Launch stringify tests for cfg (tiny)")
// interpreter
lazy val interpreterTest = taskKey[Unit]("Launch interpreter tests")
lazy val interpreterEvalTest =
taskKey[Unit]("Launch eval tests for interpreter (tiny)")
// state
lazy val stateTest = taskKey[Unit]("Launch state tests")
lazy val stateStringifyTest =
taskKey[Unit]("Launch stringify tests for state (tiny)")
// analyzer
lazy val analyzerTest = taskKey[Unit]("Launch analyzer tests")
lazy val analyzerStringifyTest =
taskKey[Unit]("Launch stringify tests for analyzer (tiny)")
// es
lazy val esTest = taskKey[Unit]("Launch ECMAScript tests")
lazy val esEvalTest = taskKey[Unit]("Launch eval tests for ECMAScript (small)")
lazy val esParseTest =
taskKey[Unit]("Launch parse tests for ECMAScript (small)")
lazy val esAnalyzeTest =
taskKey[Unit]("Launch analyze tests for ECMAScript (small)")
// test262
lazy val test262ParseTest =
taskKey[Unit]("Launch parse tests for Test262 (large)")
lazy val test262EvalTest =
taskKey[Unit]("Launch eval tests for Test262 (large)")
// Java options for assembly
lazy val assemblyJavaOpts = Seq(
"-Xms1g",
"-Xmx3g",
"-XX:ReservedCodeCacheSize=512m",
"-Dfile.encoding=utf8",
)
// assembly setting
ThisBuild / assemblyPrependShellScript := Some(
assemblyJavaOpts.map("JAVA_OPTS=\"" + _ + " $JAVA_OPTS\"") ++
defaultUniversalScript(shebang = false),
)
// Akka
val AkkaVersion = "2.6.19"
val AkkaHttpVersion = "10.2.8"
// project root
lazy val root = project
.in(file("."))
.settings(
name := "esmeta",
// libraries
libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % "0.14.1",
"io.circe" %% "circe-generic" % "0.14.1",
"io.circe" %% "circe-parser" % "0.14.1",
"org.scalatest" %% "scalatest" % "3.2.11" % Test,
"org.apache.commons" % "commons-text" % "1.9",
"org.jsoup" % "jsoup" % "1.14.3",
"org.jline" % "jline" % "3.13.3",
("org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2")
.cross(CrossVersion.for3Use2_13),
("com.typesafe.akka" %% "akka-actor-typed" % AkkaVersion)
.cross(CrossVersion.for3Use2_13),
("com.typesafe.akka" %% "akka-stream" % AkkaVersion)
.cross(CrossVersion.for3Use2_13),
("com.typesafe.akka" %% "akka-http" % AkkaHttpVersion)
.cross(CrossVersion.for3Use2_13),
("ch.megard" %% "akka-http-cors" % "1.1.2")
.cross(CrossVersion.for3Use2_13), // cors
),
// Copy all managed dependencies to <build-root>/lib_managed/ This is
// essentially a project-local cache. There is only one lib_managed/ in
// the build root (not per-project).
retrieveManaged := true,
// set the main class for 'sbt run'
Compile / mainClass := Some("esmeta.ESMeta"),
// test setting
Test / testOptions += Tests
.Argument("-fDG", baseDirectory.value + "/tests/detail"),
Test / parallelExecution := true,
// assembly setting
assembly / test := {},
assembly / assemblyOutputPath := file("bin/esmeta"),
/** tasks for tests */
// basic tests
basicTest := (Test / testOnly)
.toTask(
List(
"*TinyTest",
"*SmallTest",
).mkString(" ", " ", ""),
)
.value,
test := basicTest.dependsOn(format).value,
// size
tinyTest := (Test / testOnly).toTask(" *TinyTest").value,
smallTest := (Test / testOnly).toTask(" *SmallTest").value,
middleTest := (Test / testOnly).toTask(" *MiddleTest").value,
largeTest := (Test / testOnly).toTask(" *LargeTest").value,
// general
complTest := (Test / testOnly).toTask(" *.Compl*Test").value,
// extractor
extractorTest := (Test / testOnly).toTask(" *.extractor.*Test").value,
extractorValidityTest := (Test / testOnly)
.toTask(" *.extractor.Validity*Test")
.value,
// spec
specTest := (Test / testOnly).toTask(" *.spec.*Test").value,
specStringifyTest := (Test / testOnly)
.toTask(" *.spec.Stringify*Test")
.value,
specJsonTest := (Test / testOnly).toTask(" *.spec.Json*Test").value,
// lang
langTest := (Test / testOnly).toTask(" *.lang.*Test").value,
langStringifyTest := (Test / testOnly)
.toTask(" *.lang.Stringify*Test")
.value,
langJsonTest := (Test / testOnly).toTask(" *.lang.Json*Test").value,
// ty
tyTest := (Test / testOnly).toTask(" *.ty.*Test").value,
tyContainsTest := (Test / testOnly).toTask(" *.ty.Contains*Test").value,
tyStringifyTest := (Test / testOnly).toTask(" *.ty.Stringify*Test").value,
tyJsonTest := (Test / testOnly).toTask(" *.ty.Json*Test").value,
// compiler
compilerTest := (Test / testOnly).toTask(" *.compiler.*Test").value,
compilerValidityTest := (Test / testOnly)
.toTask(" *.compiler.Validity*Test")
.value,
// ir
irTest := (Test / testOnly).toTask(" *.ir.*Test").value,
irStringifyTest := (Test / testOnly).toTask(" *.ir.Stringify*Test").value,
irJsonTest := (Test / testOnly).toTask(" *.ir.Json*Test").value,
// cfgBuilder
cfgBuilderTest := (Test / testOnly).toTask(" *.cfgBuilder.*Test").value,
cfgBuilderValidityTest := (Test / testOnly)
.toTask(" *.cfgBuilder.Validity*Test")
.value,
// cfg
cfgTest := (Test / testOnly).toTask(" *.cfg.*Test").value,
cfgStringifyTest := (Test / testOnly).toTask(" *.cfg.Stringify*Test").value,
// interpreter
interpreterTest := (Test / testOnly).toTask(" *.interpreter.*Test").value,
interpreterEvalTest := (Test / testOnly)
.toTask(" *.interpreter.Eval*Test")
.value,
// state
stateTest := (Test / testOnly).toTask(" *.state.*Test").value,
stateStringifyTest := (Test / testOnly)
.toTask(" *.state.Stringify*Test")
.value,
// analyzer
analyzerTest := (Test / testOnly).toTask(" *.analyzer.*Test").value,
analyzerStringifyTest := (Test / testOnly)
.toTask(" *.analyzer.Stringify*Test")
.value,
// es
esTest := (Test / testOnly).toTask(" *.es.*Test").value,
esEvalTest := (Test / testOnly).toTask(" *.es.Eval*Test").value,
esParseTest := (Test / testOnly).toTask(" *.es.Parse*Test").value,
esAnalyzeTest := (Test / testOnly).toTask(" *.es.Analyze*Test").value,
// test262
test262ParseTest := (Test / testOnly).toTask(" *.test262.Parse*Test").value,
test262EvalTest := (Test / testOnly).toTask(" *.test262.Eval*Test").value,
)
// create the `.completion` file for autocompletion in shell
lazy val genCompl = taskKey[Unit]("generate autocompletion file (.completion)")
genCompl := (Compile / runMain).toTask(" esmeta.util.GenCompl").value
// build for release with genCompl and assembly
lazy val release = taskKey[Unit]("release with format, genCompl, and assembly")
release := Def
.sequential(
format,
assembly / assembly,
genCompl,
)
.value
// format all files
lazy val format = taskKey[Unit]("format all files")
format := Def
.sequential(
Compile / scalafmtAll,
Compile / scalafmtSbt,
)
.value
// format check all files
lazy val formatCheck = taskKey[Unit]("format check all files")
formatCheck := Def
.sequential(
Compile / scalafmtCheckAll,
Compile / scalafmtSbtCheck,
)
.value