-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sc
110 lines (93 loc) · 3.69 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
import $file.deps, deps.{Deps, MingwCommands, Scala, WindowsJvm}
import $file.settings, settings.{GenerateHeaders, HasCSources, JniUtilsPublishModule, JniUtilsPublishVersion, WithDllNameJava, downloadWindowsJvmArchive, isWindows, unpackWindowsJvmArchive}
import mill._, scalalib._
import scala.concurrent.duration._
object `windows-jni-utils` extends WindowsUtils with HasCSources with JniUtilsPublishModule with WithDllNameJava {
def linkingLibs = Seq("ole32")
def compile = T{
headers.`windows-jni-utils`.compile()
headers.`windows-jni-utils-bootstrap`.compile()
headers.`windows-jni-utils-lmcoursier`.compile()
headers.`windows-jni-utils-coursierapi`.compile()
super.compile()
}
def msysShell = MingwCommands.msysShell
def gcc = MingwCommands.gcc
def windowsJavaHome = sharedWindowsJavaHome()
}
object `windows-jni-utils-bootstrap` extends WindowsUtils with JniUtilsPublishModule {
def moduleDeps = Seq(`windows-jni-utils`)
}
object `windows-jni-utils-lmcoursier` extends WindowsUtils with JniUtilsPublishModule {
def moduleDeps = Seq(`windows-jni-utils`)
}
object `windows-jni-utils-coursierapi` extends WindowsUtils with JniUtilsPublishModule {
def moduleDeps = Seq(`windows-jni-utils`)
}
object `windows-jni-utils-tests` extends ScalaModule with JniUtilsPublishModule {
def scalaVersion = Scala.scala213
def moduleDeps = Seq(`windows-jni-utils`)
object test extends Tests {
def moduleDeps = super.moduleDeps ++ Seq(
`windows-jni-utils-bootstrap`,
`windows-jni-utils-lmcoursier`,
`windows-jni-utils-coursierapi`
)
def ivyDeps = Agg(Deps.utest)
def testFrameworks = Seq("utest.runner.Framework")
}
}
// compile these projects to generate or update JNI header files
object headers extends Module {
object `windows-jni-utils` extends WindowsUtils with GenerateHeaders with WithDllNameJava
object `windows-jni-utils-bootstrap` extends WindowsUtils with GenerateHeaders {
def moduleDeps = Seq(`windows-jni-utils`)
def cDirectory = `windows-jni-utils`.cDirectory()
}
object `windows-jni-utils-lmcoursier` extends WindowsUtils with GenerateHeaders {
def moduleDeps = Seq(`windows-jni-utils`)
def cDirectory = `windows-jni-utils`.cDirectory()
}
object `windows-jni-utils-coursierapi` extends WindowsUtils with GenerateHeaders {
def moduleDeps = Seq(`windows-jni-utils`)
def cDirectory = `windows-jni-utils`.cDirectory()
}
implicit def millModuleBasePath: define.BasePath =
define.BasePath(super.millModuleBasePath.value / os.up)
}
trait WindowsUtils extends MavenModule with JniUtilsPublishVersion {
def compileIvyDeps = Agg(Deps.svm)
}
def windowsJvmArchive = T.persistent {
downloadWindowsJvmArchive(WindowsJvm.url, WindowsJvm.archiveName)
}
def sharedWindowsJavaHome: T[String] =
if (isWindows)
T{
import java.io.File
val value = sys.props("java.home")
val dir = new File(value)
// Seems required with Java 8
if (dir.getName == "jre") dir.getParent
else value
}
else
T.persistent {
// On Linux / macOS, get a Windows JDK for the Windows JNI header files
val windowsJvmArchive0 = windowsJvmArchive()
unpackWindowsJvmArchive(windowsJvmArchive0.path, WindowsJvm.archiveName).toString
}
def publishSonatype(tasks: mill.main.Tasks[PublishModule.PublishData]) =
T.command {
val timeout = 10.minutes
val credentials = sys.env("SONATYPE_USERNAME") + ":" + sys.env("SONATYPE_PASSWORD")
val pgpPassword = sys.env("PGP_PASSWORD")
val data = define.Task.sequence(tasks.value)()
settings.publishSonatype(
credentials = credentials,
pgpPassword = pgpPassword,
data = data,
timeout = timeout,
log = T.ctx().log
)
}