forked from com-lihaoyi/fastparse
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sbt
167 lines (150 loc) · 5.62 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
lazy val readme = scalatex.ScalatexReadme(
projectId = "readme",
wd = file(""),
url = "https://github.com/lihaoyi/fastparse/tree/master",
source = "Readme",
autoResources = List("out.js", "JProfiler.png")
).settings(
(resources in Compile) += baseDirectory.value/".."/"out"/"demo"/"fullOpt"/"dest"/"out.js",
scalaVersion := Scala212
)
val Scala212 = "2.12.8"
val Scala213 = "2.13.0"
lazy val root = project in file(".")
scalaVersion in ThisBuild := Scala213
lazy val commonTestSettings = libraryDependencies ++= Seq(
"com.lihaoyi" %% "utest" % "0.7.0",
"org.scala-lang" % "scala-reflect" % Scala213,
"org.scala-lang" % "scala-compiler" % Scala213,
)
lazy val fastparse = (project in file("fastparse"))
.settings(
name := "fastparse",
fork in (Test, run) := true,
libraryDependencies += "com.lihaoyi" %% "sourcecode" % "0.1.7",
unmanagedSourceDirectories in Compile ++= {
val base = baseDirectory.value
Seq(base / "src", base / "src-jvm")
},
unmanagedSourceDirectories in Test += baseDirectory.value / "test" / "src",
sourceGenerators in Compile += Def.task {
val dir = (sourceManaged in Compile).value
val file = dir/"fastparse"/"SequencerGen.scala"
// Only go up to 21, because adding the last element makes it 22
val tuples = (2 to 21).map{ i =>
val ts = (1 to i) map ("T" + _)
val chunks = (1 to i) map { n =>
s"t._$n"
}
val tsD = (ts :+ "D").mkString(",")
s"""
implicit def Sequencer$i[$tsD]: Sequencer[(${ts.mkString(", ")}), D, ($tsD)] =
Sequencer0((t, d) => (${chunks.mkString(", ")}, d))
"""
}
val output = s"""
package fastparse
trait SequencerGen[Sequencer[_, _, _]] extends LowestPriSequencer[Sequencer]{
protected[this] def Sequencer0[A, B, C](f: (A, B) => C): Sequencer[A, B, C]
${tuples.mkString("\n")}
}
trait LowestPriSequencer[Sequencer[_, _, _]]{
protected[this] def Sequencer0[A, B, C](f: (A, B) => C): Sequencer[A, B, C]
implicit def Sequencer1[T1, T2]: Sequencer[T1, T2, (T1, T2)] = Sequencer0{case (t1, t2) => (t1, t2)}
}
""".stripMargin
IO.write(file, output)
Seq(file)
}
)
.settings(commonTestSettings)
.settings(dottySettings)
lazy val cssparse = (project in file("cssparse"))
.settings(
name := "cssparse",
fork in (Test, run) := true,
libraryDependencies += "net.sourceforge.cssparser" % "cssparser" % "0.9.18",
scalaSource in Compile := baseDirectory.value / "src",
unmanagedSourceDirectories in Test ++= {
val base = baseDirectory.value / "test"
Seq(base / "src", base / "src-jvm")
}
)
.settings(commonTestSettings)
.settings(dottySettings)
.dependsOn(fastparse)
lazy val scalaparse = (project in file("scalaparse"))
.settings(
name := "scalaparse",
fork in (Test, run) := true,
scalaSource in Compile := baseDirectory.value / "src",
unmanagedSourceDirectories in Test ++= {
val base = baseDirectory.value / "test"
Seq(base / "src", base / "src-jvm")
},
unmanagedResourceDirectories in Test += baseDirectory.value / "test" / "resources"
)
.settings(commonTestSettings)
.settings(dottySettings)
.dependsOn(fastparse)
lazy val pythonparse = (project in file("pythonparse"))
.settings(
name := "pythonparse",
fork in (Test, run) := true,
scalaSource in Compile := baseDirectory.value / "src",
unmanagedSourceDirectories in Test ++= {
val base = baseDirectory.value / "test"
Seq(base / "src", base / "src-jvm")
},
unmanagedResourceDirectories in Test += baseDirectory.value / "test" / "resources"
)
.settings(commonTestSettings)
.settings(dottySettings)
.dependsOn(fastparse)
lazy val `perftests-common` =
unmanagedResourceDirectories in Compile += (baseDirectory in LocalRootProject).value / "perftests" / "resources"
lazy val `perftests-bench2` = (project in file("perftests/bench2"))
.settings(
scalaSource in Compile := baseDirectory.value / "src"
)
.settings(`perftests-common`)
.settings(commonTestSettings)
.settings(dottySettings)
.dependsOn(
fastparse % "compile->compile;compile->test",
scalaparse % "compile->compile;compile->test",
cssparse,
pythonparse
)
lazy val `perftests-compare` = (project in file("perftests/compare"))
.settings(
scalaSource in Compile := baseDirectory.value / "src",
libraryDependencies ++= Seq(
"org.json4s" %% "json4s-ast" % "3.6.7",
"org.json4s" %% "json4s-native" % "3.6.7",
"org.json4s" %% "json4s-jackson" % "3.6.7",
"io.circe" %% "circe-parser" % "0.12.0-RC3",
"io.argonaut" %% "argonaut" % "6.2.3",
"com.typesafe.play" %% "play-json" % "2.8.0-M5",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9.3",
"com.lihaoyi" %% "ujson" % "0.7.5",
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2",
"org.python" % "jython" % "2.7.1b3"
)
)
.settings(`perftests-common`)
.settings(commonTestSettings)
.settings(dottySettings)
.dependsOn(
fastparse % "compile->compile;compile->test",
scalaparse % "compile->compile;compile->test",
cssparse,
pythonparse
)
lazy val `dotty-community-build` = (project in file(".dotty-community-build"))
.aggregate(fastparse, cssparse, scalaparse, pythonparse, `perftests-bench2`, `perftests-compare`)
.settings(dottySettings)
lazy val dottySettings = List(
libraryDependencies := libraryDependencies.value.map(_.withDottyCompat(scalaVersion.value)),
scalacOptions ++= List("-language:Scala2Compat,implicitConversions", "-Xignore-scala2-macros")
)