-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.sbt
190 lines (171 loc) · 6.43 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
import org.scalajs.linker.interface.{CheckedBehavior, ESVersion}
import sbt.*
import scala.collection.Seq
import scala.scalanative.build.{GC, LTO, Mode}
import scala.sys.process.*
lazy val oldVersion = "git describe --abbrev=0".!!.trim.replaceAll("^v", "")
lazy val isWindows = System.getProperty("os.name", "").toLowerCase().indexOf("win") >= 0
lazy val commonSettings = Seq(
organization := "com.github.plokhotnyuk.rtree2d",
organizationHomepage := Some(url("https://github.com/plokhotnyuk")),
homepage := Some(url("https://github.com/plokhotnyuk/rtree2d")),
licenses := Seq(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html"))),
startYear := Some(2018),
developers := List(
Developer(
id = "loony-bean",
name = "Alexey Suslov",
email = "[email protected]",
url = url("https://github.com/loony-bean")
),
Developer(
id = "AnderEnder",
name = "Andrii Radyk",
email = "[email protected]",
url = url("https://github.com/AnderEnder")
),
Developer(
id = "plokhotnyuk",
name = "Andriy Plokhotnyuk",
email = "[email protected]",
url = url("https://github.com/plokhotnyuk")
)
),
scalaVersion := "2.12.20",
scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-unchecked",
) ++ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => Seq("-language:higherKinds")
case Some((2, 13)) => Seq("-Wnonunit-statement")
case _ => Seq()
}),
Test / testOptions += Tests.Argument("-oDF"),
ThisBuild / parallelExecution := false,
publishTo := sonatypePublishToBundle.value,
sonatypeProfileName := "com.github.plokhotnyuk",
versionScheme := Some("early-semver"),
scmInfo := Some(
ScmInfo(
url("https://github.com/plokhotnyuk/rtree2d"),
"scm:[email protected]:plokhotnyuk/rtree2d.git"
)
),
publishMavenStyle := true,
pomIncludeRepository := { _ => false }
)
lazy val jsSettings = Seq(
scalacOptions ++= {
val localSourcesPath = (LocalRootProject / baseDirectory).value.toURI
val remoteSourcesPath = s"https://raw.githubusercontent.com/plokhotnyuk/rtree2d/${git.gitHeadCommit.value.get}/"
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) => Seq(
s"-P:scalajs:mapSourceURI:$localSourcesPath->$remoteSourcesPath",
"-P:scalajs:genStaticForwardersForNonTopLevelObjects"
)
case _ => Seq(
s"-scalajs-mapSourceURI:$localSourcesPath->$remoteSourcesPath",
"-scalajs-genStaticForwardersForNonTopLevelObjects"
)
}
},
scalaJSLinkerConfig ~= {
_.withSemantics({
_.optimized
.withProductionMode(true)
.withAsInstanceOfs(CheckedBehavior.Unchecked)
.withStringIndexOutOfBounds(CheckedBehavior.Unchecked)
.withArrayIndexOutOfBounds(CheckedBehavior.Unchecked)
.withArrayStores(CheckedBehavior.Unchecked)
.withNegativeArraySizes(CheckedBehavior.Unchecked)
.withNullPointers(CheckedBehavior.Unchecked)
}).withClosureCompiler(true)
.withESFeatures(_.withESVersion(ESVersion.ES2015))
.withModuleKind(ModuleKind.CommonJSModule)
},
coverageEnabled := false // FIXME: Unexpected crash of scalac
)
lazy val nativeSettings = Seq(
scalacOptions ++= Seq("-P:scalanative:genStaticForwardersForNonTopLevelObjects"),
nativeConfig ~= {
_.withMode(Mode.releaseFast) // TODO: test with `Mode.releaseSize` and `Mode.releaseFull`
.withLTO(LTO.none)
.withGC(GC.immix)
},
coverageEnabled := false // FIXME: Unexpected linking error
)
lazy val noPublishSettings = Seq(
publish / skip := true,
mimaPreviousArtifacts := Set()
)
lazy val publishSettings = Seq(
packageOptions += Package.ManifestAttributes("Automatic-Module-Name" -> moduleName.value),
mimaCheckDirection := {
def isPatch = {
val Array(newMajor, newMinor, _) = version.value.split('.')
val Array(oldMajor, oldMinor, _) = oldVersion.split('.')
newMajor == oldMajor && newMinor == oldMinor
}
if (isPatch) "both" else "backward"
},
mimaPreviousArtifacts := {
def isCheckingRequired = {
val Array(newMajor, newMinor, _) = version.value.split('.')
val Array(oldMajor, oldMinor, _) = oldVersion.split('.')
newMajor == oldMajor && (newMajor != "0" || newMinor == oldMinor)
}
if (isCheckingRequired) Set(organization.value %%% moduleName.value % oldVersion)
else Set()
},
mimaReportSignatureProblems := true
)
lazy val rtree2d = project.in(file("."))
.aggregate((if (isWindows) winProjects else unixProjects)*)
.settings(commonSettings)
.settings(noPublishSettings)
lazy val winProjects = Seq[ProjectReference](`rtree2d-coreJVM`, `rtree2d-coreJS`, `rtree2d-benchmark`)
lazy val unixProjects = Seq[ProjectReference](`rtree2d-coreJVM`, `rtree2d-coreJS`, `rtree2d-coreNative`, `rtree2d-benchmark`)
lazy val `rtree2d-core` = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Full)
.settings(commonSettings)
.settings(publishSettings)
.settings(
crossScalaVersions := Seq("3.3.4", "2.13.15", "2.12.20"),
libraryDependencies ++= Seq(
"org.scalatestplus" %%% "scalacheck-1-18" % "3.2.19.0" % Test,
"org.scalatest" %%% "scalatest" % "3.2.19" % Test
)
)
lazy val `rtree2d-coreJVM` = `rtree2d-core`.jvm
lazy val `rtree2d-coreJS` = `rtree2d-core`.js
.settings(jsSettings)
lazy val `rtree2d-coreNative` = `rtree2d-core`.native
.settings(nativeSettings)
lazy val `rtree2d-benchmark` = project
.enablePlugins(JmhPlugin)
.dependsOn(`rtree2d-coreJVM`)
.settings(commonSettings)
.settings(noPublishSettings)
.settings(
crossScalaVersions := Seq(scalaVersion.value),
libraryDependencies ++= Seq(
"org.locationtech.jts" % "jts-core" % "1.20.0",
"com.github.davidmoten" % "rtree2" % "0.9.3",
"org.spire-math" %% "archery" % "0.6.0",
"org.scalatest" %%% "scalatest" % "3.2.19" % Test
),
charts := Def.inputTaskDyn {
val jmhParams = Def.spaceDelimited().parsed
val targetDir = crossTarget.value
val jmhReport = targetDir / "benchmark.json"
val runTask = Jmh / run
Def.inputTask {
val _ = runTask.evaluated
Bencharts(jmhReport, "Execution time (ns/op)", targetDir)
targetDir
}.toTask(s" -rf json -rff ${jmhReport.absolutePath} ${jmhParams.mkString(" ")}")
}.evaluated
)
lazy val charts = inputKey[File]("Runs the benchmarks and produce charts")