-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
154 lines (135 loc) · 3.86 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
import bindgen.plugin.BindgenMode
import java.nio.file.Paths
Global / onChangedBuildSource := ReloadOnSourceChanges
val Versions = new {
val Scala = "3.3.3"
val circe = "0.14.9"
val munit = "1.0.0"
val upickle = "4.0.2"
}
import bindgen.interface.*
lazy val root =
project
.in(file("."))
.aggregate(core, circe, upickle)
.settings(publish / skip := true)
lazy val core =
project
.in(file("module-core"))
.enablePlugins(
ScalaNativePlugin,
ScalaNativeJUnitPlugin,
BindgenPlugin,
VcpkgNativePlugin
)
.settings(common)
.settings(
Test / nativeConfig ~= (_.withEmbedResources(true)),
Compile / bindgenBindings += {
val configurator = vcpkgConfigurator.value
Binding(configurator.includes("libpq") / "libpq-fe.h", "libpq")
.withLinkName("pq")
.addCImport("libpq-fe.h")
.withClangFlags(
configurator.pkgConfig
.updateCompilationFlags(List("-std=gnu99"), "libpq")
.toList
)
.withNoLocation(true)
},
bindgenMode := BindgenMode.Manual(
sourceDirectory.value / "main" / "scala" / "generated",
(Compile / resourceDirectory).value / "scala-native"
),
moduleName := "core",
configurePlatform
)
lazy val upickle =
project
.in(file("module-upickle"))
.dependsOn(core % "compile->compile;test->test")
.enablePlugins(ScalaNativePlugin, VcpkgNativePlugin, BindgenPlugin)
.settings(
libraryDependencies += "com.lihaoyi" %%% "upickle" % Versions.upickle
)
.settings(moduleName := "upickle")
.settings(common)
.settings(configurePlatform)
lazy val circe =
project
.in(file("module-circe"))
.dependsOn(core % "compile->compile;test->test")
.enablePlugins(ScalaNativePlugin, VcpkgNativePlugin, BindgenPlugin)
.settings(
libraryDependencies += "io.circe" %%% "circe-parser" % Versions.circe
)
.settings(moduleName := "circe")
.settings(common)
.settings(configurePlatform)
val common = Seq(
organization := "com.indoorvivants.roach",
scalaVersion := Versions.Scala,
libraryDependencies += "org.scalameta" %%% "munit" % Versions.munit % Test,
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
vcpkgDependencies := VcpkgDependencies("libpq")
)
lazy val docs =
project
.in(file("target/.docs-target"))
.enablePlugins(MdocPlugin)
.settings(scalaVersion := Versions.Scala)
.dependsOn(core, circe, upickle)
.settings(
publish / skip := true,
Compile / resourceGenerators += Def.task {
val folder = (Compile / unmanagedResourceDirectories).value.head
for {
i <- (1 to 3).toSeq
name = s"v00$i.sql"
_ = IO.write(folder / name, "")
} yield folder / name
}
)
inThisBuild(
Seq(
organization := "com.indoorvivants",
organizationName := "Anton Sviridov",
homepage := Some(
url("https://github.com/indoorvivants/roach")
),
startYear := Some(2022),
licenses := List(
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")
),
developers := List(
Developer(
"keynmol",
"Anton Sviridov",
"velvetbaldmime@protonmail.com",
url("https://blog.indoorvivants.com")
)
)
)
)
addCommandAlias("checkDocs", "docs/mdoc --in README.md")
val configurePlatform = Seq(
nativeConfig := {
import com.indoorvivants.detective.*
val conf = nativeConfig.value
val arch64 =
if (
Platform.arch == Platform.Arch.Arm && Platform.bits == Platform.Bits.x64
)
List("-arch", "arm64")
else Nil
conf
.withLinkingOptions(
conf.linkingOptions ++ arch64
)
.withCompileOptions(
conf.compileOptions ++ arch64
)
.withIncrementalCompilation(true)
.withMultithreading(true)
}
)