-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
73 lines (66 loc) · 2.17 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
lazy val stage = taskKey[File]("stage")
import scala.scalanative.build._
import scala.sys.process._
def pkgConfig(pkg: String, arg: String) = {
import sys.process.*
s"pkg-config --$arg $pkg".!!.trim.split(" ").toList
}
inThisBuild(Seq(
scalaVersion := "3.6.2",
version := "0.3.0-SNAPSHOT",
organization := "com.coreyoconnor",
versionScheme := Some("early-semver")
))
lazy val shell = project
.in(file("shell"))
.enablePlugins(ScalaNativePlugin)
.settings(
// https://github.com/indoorvivants/scala-native-gtk-bindings
libraryDependencies += "com.indoorvivants.gnome" %%% "gtk4" % "0.1.0",
nativeConfig := {
nativeConfig.value
.withLTO(LTO.thin)
.withMode(Mode.releaseFast)
.withCompileOptions(pkgConfig("gtk4", "cflags") :+ "-Wno-unused-command-line-argument")
.withLinkingOptions(pkgConfig("gtk4", "libs") :+ "-Wno-unused-command-line-argument")
}
)
lazy val root = project
.in(file("."))
.dependsOn(shell)
.enablePlugins(ScalaNativePlugin)
.settings(
nativeConfig := {
nativeConfig.value
.withLTO(LTO.thin)
.withMode(Mode.releaseFast)
.withCompileOptions(pkgConfig("gtk4", "cflags") :+ "-Wno-unused-command-line-argument")
.withLinkingOptions(pkgConfig("gtk4", "libs") :+ "-Wno-unused-command-line-argument")
},
stage := {
val exeFile = (Compile / nativeLink).value
val targetFile = target.value / "scalatromino"
sbt.IO.copyFile(exeFile, targetFile)
targetFile
},
publish := (shell / publish).value,
publishLocal := (shell / publishLocal).value,
Compile / resourceGenerators += Def.task {
val inputDir = (Compile / resourceDirectory).value
val input = inputDir / "main.gresource.xml"
val file = (Compile / resourceManaged).value / "scala-native" / "gresources.c"
IO.createDirectory(file.getParentFile())
val processResult = Process(
Seq(
"glib-compile-resources",
"--generate-source",
"--target",
file.toString(),
input.toString()
),
inputDir
) ! streams.value.log
assert(processResult == 0)
Seq(file)
}.taskValue
)