forked from com-lihaoyi/fastparse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
146 lines (135 loc) · 5.06 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
import sbt.Keys._
publishArtifact := false
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))
crossScalaVersions := Seq("2.10.4", "2.11.5")
val shared = Seq(
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided"
) ++ (
if (scalaVersion.value startsWith "2.11.") Nil
else Seq(
compilerPlugin("org.scalamacros" % s"paradise" % "2.0.0" cross CrossVersion.full),
"org.scalamacros" %% s"quasiquotes" % "2.0.0"
)
),
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "utest" % "0.3.0" % "test"
),
scalaJSStage in Global := FullOptStage,
organization := "com.lihaoyi",
version := _root_.fastparse.Constants.version,
scalaVersion := "2.11.6",
libraryDependencies += "com.lihaoyi" %% "acyclic" % "0.1.2" % "provided",
addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.2"),
autoCompilerPlugins := true,
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
testFrameworks += new TestFramework("utest.runner.Framework"),
publishTo := Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"),
pomExtra :=
<url>https://github.com/lihaoyi/scala-parser</url>
<licenses>
<license>
<name>MIT license</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
<scm>
<url>git://github.com/lihaoyi/scala-parser.git</url>
<connection>scm:git://github.com/lihaoyi/scala-parser.git</connection>
</scm>
<developers>
<developer>
<id>lihaoyi</id>
<name>Li Haoyi</name>
<url>https://github.com/lihaoyi</url>
</developer>
</developers>
)
lazy val utils = crossProject.settings(
name := "fastparse-utils",
unmanagedSourceDirectories in Compile ++= {
if (scalaVersion.value startsWith "2.10.") Seq(baseDirectory.value / ".."/"shared"/"src"/ "main" / "scala-2.10")
else Seq(baseDirectory.value / ".."/"shared" / "src"/"main" / "scala-2.11")
}
).settings(shared:_*)
lazy val utilsJS = utils.js
lazy val utilsJVM= utils.jvm
lazy val fastparse = crossProject.dependsOn(utils).settings(
name := "fastparse",
sourceGenerators in Compile <+= sourceManaged in Compile map { dir =>
val file = dir/"fastparse"/"SequencerGen.scala"
val tuples = (2 to 10).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(shared:_*)
lazy val fastparseJS = fastparse.js
lazy val fastparseJVM = fastparse.jvm
lazy val scalaparse = crossProject.dependsOn(fastparse).settings(
name := "scalaparse"
).settings(shared:_*)
.jvmSettings(
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value % "test",
fork in (Test, testOnly) := true,
fork in (Test, test) := true
)
lazy val scalaparseJS = scalaparse.js
lazy val scalaparseJVM = scalaparse.jvm
lazy val modules = project.aggregate(
fastparseJS,
fastparseJVM,
scalaparseJS,
scalaparseJVM,
utilsJS,
utilsJVM
).settings(
publishArtifact := false,
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))
)
lazy val demo = project.enablePlugins(ScalaJSPlugin)
.dependsOn(fastparseJS % "compile->compile;compile->test", scalaparseJS)
.settings(shared:_*)
.settings(
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.8.0",
libraryDependencies += "com.lihaoyi" %%% "scalatags" % "0.5.1",
emitSourceMaps := false,
publishArtifact := false,
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))
)
lazy val readme = scalatex.ScalatexReadme(
projectId = "readme",
wd = file(""),
url = "https://github.com/lihaoyi/fastparse/tree/master",
source = "Readme",
autoResources = List("demo-opt.js")
).settings(
(resources in Compile) += {
(fullOptJS in (demo, Compile)).value
(artifactPath in (demo, Compile, fullOptJS)).value
},
(unmanagedSources in Compile) += baseDirectory.value/".."/"project"/"Constants.scala",
publishArtifact := false,
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))
)