-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sc
157 lines (140 loc) · 4.46 KB
/
build.sc
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
import $ivy.`com.github.lolgab::mill-crossplatform::0.2.3`
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import com.github.lolgab.mill.crossplatform._
import de.tobiasroeser.mill.vcs.version.VcsVersion
import mill._
import mill.scalalib._
import mill.scalalib.publish._
import mill.scalalib.scalafmt.ScalafmtModule
import mill.scalanativelib._
import os.{/, GlobSyntax}
val scalaVersions = Seq("2.13.11", "3.3.0")
trait Common extends ScalaModule with ScalafmtModule {
def scalacOptions =
Seq(
"-deprecation",
"-encoding",
"utf-8",
"-feature",
"-unchecked",
// Above options from https://tpolecat.github.io/2017/04/25/scalac-flags.html
"-Xfatal-warnings",
) ++
(if (scalaVersion().startsWith("3"))
Seq(
// "-explain",
"-print-lines",
"-Wunused:all",
)
else
Seq("-Xsource:3", "-Xlint"))
}
trait CommonNative extends ScalaNativeModule {
def scalaNativeVersion = "0.4.14"
def nativeOptimize = false
}
object sline extends Cross[SlineModule](scalaVersions)
trait SlineModule extends CrossPlatform {
trait Shared
extends CrossPlatformCrossScalaModule
with Common
with PublishModule {
def publishVersion = VcsVersion.vcsState().format()
def pomSettings =
PomSettings(
description = "A cross-platform library for making interactive CLIs",
organization = "io.github.ysthakur",
url = "https://github.com/ysthakur/sline",
licenses = Seq(License.MIT),
versionControl = VersionControl.github("ysthakur", "sline"),
developers = Seq(
Developer("ysthakur", "Yash Thakur", "https://github.com/ysthakur")
),
)
def ivyDeps =
T(
super.ivyDeps() ++
Seq(ivy"com.lihaoyi::fansi::0.4.0", ivy"com.outr::scribe::3.11.5")
)
}
object jvm extends Shared {
def ivyDeps = T(super.ivyDeps() ++ Seq(ivy"org.jline:jline:3.23.0"))
object test extends ScalaTests with SlineTestModule
}
object native extends Shared with CommonNative {
/** Copy everything from replxx's src folder to resources/scala-native */
def updateReplxx =
T.sources {
val resourcesFolder = millSourcePath / "resources" / "scala-native"
os.remove.all(resourcesFolder)
val replxxFolder = resourcesFolder / "replxx"
os.makeDir.all(replxxFolder)
os.proc(
"git",
"clone",
"--depth",
"1",
"git@github.com:AmokHuginnsson/replxx.git",
replxxFolder,
)
.call()
def removeXX(file: os.Path): Unit =
os.write
.over(
file,
os.read(file).replace(".cxx", ".cpp").replace(".hxx", ".hpp"),
)
os.walk(replxxFolder / "src")
.collect {
os.move
.matching {
case _ / g"$file.cxx" =>
resourcesFolder / g"$file.cpp"
case _ / g"$file.hxx" =>
resourcesFolder / g"$file.hpp"
case _ / g"$file" =>
resourcesFolder / g"$file"
}
}
os.walk(replxxFolder / "include")
.collect {
os.move
.matching {
case _ / g"$file.hxx" =>
resourcesFolder / g"$file.hpp"
case _ / g"$file" =>
resourcesFolder / g"$file"
}
}
os.remove.all(replxxFolder)
os.walk(resourcesFolder)
.foreach { file =>
removeXX(file)
}
Seq(PathRef(resourcesFolder))
}
object test extends ScalaNativeTests with SlineTestModule
}
trait SlineTestModule extends TestModule.ScalaTest with ScalafmtModule {
def defaultCommandName() = "testQuiet"
def ivyDeps =
T(super.ivyDeps() ++ Seq(ivy"org.scalatest::scalatest::3.2.16"))
/** Like testOnly, but suppresses the output of failed tests */
def testQuiet(args: String*) =
T.command {
testOnly(
(if (args.contains("--"))
args
else
args :+ "--") :+ "-oNCXEOPQRM": _*
)()
}
}
}
object demo extends Cross[DemoModule](scalaVersions)
trait DemoModule extends CrossPlatform {
def moduleDeps = Seq(sline())
trait Shared extends CrossPlatformCrossScalaModule with Common
object jvm extends Shared
object native extends Shared with CommonNative
}