forked from hkust-taco/mlscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sbt
More file actions
232 lines (199 loc) · 8.76 KB
/
build.sbt
File metadata and controls
232 lines (199 loc) · 8.76 KB
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
import Wart._
import org.scalajs.linker.interface.OutputPatterns
enablePlugins(ScalaJSPlugin)
val scala3Version = "3.8.3"
val directoryWatcherVersion = "0.18.0"
val scalaTestVersion = "3.2.19"
ThisBuild / scalaVersion := "2.13.18"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "hkust-taco.github.io"
ThisBuild / organizationName := "HKUST-TACO"
ThisBuild / scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-unchecked",
"-language:higherKinds",
"-language:implicitConversions",
if (insideCI.value) "-Wconf:any:error"
else "-Wconf:any:warning",
)
lazy val root = project.in(file("."))
.aggregate(mlscriptJS, mlscriptJVM, ts2mlsTest, compilerJVM, hkmc2AllTests, coreJS, coreJVM)
.settings(
publish := {},
publishLocal := {},
)
lazy val hkmc2 = crossProject(JSPlatform, JVMPlatform).in(file("hkmc2"))
.settings(
scalaVersion := scala3Version,
watchSources += WatchSource(
baseDirectory.value.getParentFile()/"shared"/"src"/"test"/"diff", "*.mls", NothingFilter),
// TODO remove when codebase becomes production-ready
scalacOptions -= "-Wconf:any:error",
// scalacOptions ++= Seq("-indent", "-rewrite"),
scalacOptions ++= Seq("-new-syntax", "-rewrite"),
// scalacOptions ++= Seq("-language:experimental.modularity"), // https://docs.scala-lang.org/scala3/reference/experimental/modularity.html
libraryDependencies += "io.methvin" % "directory-watcher" % directoryWatcherVersion,
libraryDependencies += "io.methvin" %% "directory-watcher-better-files" % directoryWatcherVersion,
libraryDependencies += "com.lihaoyi" %%% "fansi" % "0.5.0", // Scala.js or Scala-Native
libraryDependencies += "com.lihaoyi" %%% "sourcecode" % "0.4.2", // Scala.js / Scala Native
libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.9.3",
libraryDependencies += "org.scalactic" %%% "scalactic" % scalaTestVersion,
libraryDependencies += "org.scalatest" %%% "scalatest" % scalaTestVersion % "test",
watchSources += WatchSource(
baseDirectory.value.getParentFile()/"shared"/"src"/"test"/"mlscript", "*.mls", NothingFilter),
watchSources += WatchSource(
baseDirectory.value.getParentFile()/"shared"/"src"/"test"/"mlscript-compile", "*.mls", NothingFilter),
watchSources += WatchSource(
baseDirectory.value.getParentFile()/"shared"/"src"/"test"/"mlscript", "*.cmd", NothingFilter),
)
.jvmSettings(
)
.jsSettings(
scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.ESModule)
.withOutputPatterns(OutputPatterns.fromJSFile("MLscript.mjs"))
},
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.2.0",
)
.dependsOn(core)
lazy val hkmc2JVM = hkmc2.jvm
lazy val hkmc2JS = hkmc2.js
lazy val hkmc2DiffTests = project.in(file("hkmc2DiffTests"))
.dependsOn(hkmc2JVM % "compile->compile;test->test")
.settings(
scalaVersion := scala3Version,
libraryDependencies += "org.scalactic" %%% "scalactic" % scalaTestVersion,
libraryDependencies += "org.scalatest" %%% "scalatest" % scalaTestVersion % "test",
Test/run/fork := true, // so that CTRL+C actually terminates the watcher
)
/** Helper to create test subprojects that compile `.mls` files then run diff tests.
* Each subproject depends on `hkmc2JVM` and `hkmc2DiffTests` for shared test infrastructure,
* and uses `Def.sequential` to guarantee compile tests complete before diff tests start. */
def hkmc2TestSubproject(dirName: String, compileRunner: String, diffRunner: String): Project =
Project(dirName, file(dirName))
.dependsOn(hkmc2JVM % "compile->compile;test->test")
.dependsOn(hkmc2DiffTests % "compile->compile;test->test")
.settings(
scalaVersion := scala3Version,
libraryDependencies += "org.scalactic" %%% "scalactic" % scalaTestVersion,
libraryDependencies += "org.scalatest" %%% "scalatest" % scalaTestVersion % "test",
Test / test := Def.sequential(
(Test / testOnly).toTask(s" hkmc2.$compileRunner"),
(Test / testOnly).toTask(s" hkmc2.$diffRunner"),
).value,
Test/run/fork := true, // so that CTRL+C actually terminates the watcher
)
lazy val hkmc2NofibTests = hkmc2TestSubproject("hkmc2NofibTests", "NofibCompileTestRunner", "NofibDiffTestRunner")
lazy val hkmc2AppsTests = hkmc2TestSubproject("hkmc2AppsTests", "AppsCompileTestRunner", "AppsDiffTestRunner")
lazy val hkmc2WasmTests = hkmc2TestSubproject("hkmc2WasmTests", "WasmCompileTestRunner", "WasmDiffTestRunner")
lazy val hkmc2MainTests = project.in(file("hkmc2MainTests"))
.settings(
Test / test := (
(hkmc2DiffTests / Test / test)
.dependsOn(hkmc2JVM / Test / test)
).value
)
lazy val hkmc2MostTests = project.in(file("hkmc2MostTests"))
.settings(
Test / test := (
(hkmc2DiffTests / Test / test)
.dependsOn(hkmc2NofibTests / Test / test)
.dependsOn(hkmc2AppsTests / Test / test)
.dependsOn(hkmc2WasmTests / Test / test)
.dependsOn(hkmc2JVM / Test / test)
).value
)
lazy val hkmc2AllTests = project.in(file("hkmc2AllTests"))
.settings(
Test / test := (
(hkmc2DiffTests / Test / test)
.dependsOn(hkmc2NofibTests / Test / test)
.dependsOn(hkmc2AppsTests / Test / test)
.dependsOn(hkmc2WasmTests / Test / test)
.dependsOn(hkmc2JVM / Test / test)
.dependsOn(hkmc2JS / Test / test)
.dependsOn(hkmc2Benchmarks / Test / compile)
).value
)
lazy val core = crossProject(JSPlatform, JVMPlatform).in(file("core"))
.settings(
sourceDirectory := baseDirectory.value.getParentFile()/"shared",
)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val mlscript = crossProject(JSPlatform, JVMPlatform).in(file("."))
.settings(
name := "mlscript",
scalacOptions ++= Seq(
"-Ywarn-value-discard",
"-Ypatmat-exhaust-depth:160",
),
wartremoverWarnings ++= Warts.allBut(
Recursion, Throw, Nothing, Return, While, IsInstanceOf,
Var, MutableDataStructures, NonUnitStatements,
DefaultArguments, ImplicitParameter, ImplicitConversion,
StringPlusAny, Any, ToString,
JavaSerializable, Serializable, Product, ToString,
LeakingSealed, Overloading,
Option2Iterable, IterableOps, ListAppend, SeqApply,
TripleQuestionMark, PartialFunctionApply,
),
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.12" % Test,
libraryDependencies += "com.lihaoyi" %%% "sourcecode" % "0.3.1",
libraryDependencies += "com.lihaoyi" %%% "fastparse" % "2.3.3",
libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.8.0",
//
watchSources += WatchSource(
sourceDirectory.value.getParentFile().getParentFile()/"shared/src/test/diff", "*.fun", NothingFilter),
watchSources += WatchSource(
sourceDirectory.value.getParentFile().getParentFile()/"shared/src/test/diff", "*.mls", NothingFilter),
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oC"),
)
.jsSettings(
scalaJSUseMainModuleInitializer := true,
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.2.0",
)
.dependsOn(core)
lazy val mlscriptJVM = mlscript.jvm
lazy val mlscriptJS = mlscript.js
lazy val ts2mls = crossProject(JSPlatform, JVMPlatform).in(file("ts2mls"))
.settings(
name := "ts2mls",
)
.jvmSettings()
.jsSettings(
libraryDependencies += "org.scalatest" %%% "scalatest" % "3.2.12" % "test"
)
.dependsOn(mlscript % "compile->compile;test->test")
lazy val ts2mlsJS = ts2mls.js
lazy val ts2mlsJVM = ts2mls.jvm
lazy val ts2mlsTest = project.in(file("ts2mls"))
.settings(
Test / test := ((ts2mlsJVM / Test / test) dependsOn (ts2mlsJS / Test / test)).value
)
lazy val compiler = crossProject(JSPlatform, JVMPlatform).in(file("compiler"))
.settings(
name := "mlscript-compiler",
scalaVersion := scala3Version,
sourceDirectory := baseDirectory.value.getParentFile()/"shared",
watchSources += WatchSource(
baseDirectory.value.getParentFile()/"shared"/"test"/"diff", "*.mls", NothingFilter),
watchSources += WatchSource(
baseDirectory.value.getParentFile()/"shared"/"test"/"diff-ir", "*.mls", NothingFilter),
)
.dependsOn(mlscript % "compile->compile;test->test")
lazy val compilerJVM = compiler.jvm
lazy val compilerJS = compiler.js
lazy val hkmc2Benchmarks = project.in(file("hkmc2Benchmarks"))
.settings(
name := "benchmark",
scalaVersion := scala3Version,
sourceDirectory := baseDirectory.value/"src",
libraryDependencies += "org.scalatest" %%% "scalatest" % scalaTestVersion % "test",
watchSources += WatchSource(
baseDirectory.value/"src"/"test"/"bench", "*.mls", NothingFilter),
Test/run/fork := true, // so that CTRL+C actually terminates the watcher
)
.dependsOn(hkmc2JVM)
.dependsOn(hkmc2DiffTests % "compile->compile;test->test")