forked from databricks/sjsonnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sc
197 lines (187 loc) · 6.57 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
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
191
192
193
194
195
196
197
import mill._, scalalib._, publish._, scalajslib._, scalanativelib._, scalanativelib.api._
val sjsonnetVersion = "0.4.9"
object sjsonnet extends Cross[SjsonnetModule]("2.12.13", "2.13.4")
class SjsonnetModule(val crossScalaVersion: String) extends Module {
def millSourcePath = super.millSourcePath / os.up
trait SjsonnetJvmNative extends SjsonnetCrossModule {
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"com.lihaoyi::os-lib::0.7.2",
ivy"com.lihaoyi::mainargs::0.2.0"
)
}
trait SjsonnetCrossModule extends CrossScalaModule with PublishModule{
def artifactName = "sjsonnet"
def crossScalaVersion = SjsonnetModule.this.crossScalaVersion
def ivyDeps = Agg(
ivy"com.lihaoyi::fastparse::2.3.1",
ivy"com.lihaoyi::pprint::0.6.1",
ivy"com.lihaoyi::ujson::1.3.7",
ivy"com.lihaoyi::scalatags::0.9.3",
ivy"org.scala-lang.modules::scala-collection-compat::2.4.0"
)
def publishVersion = sjsonnetVersion
def generatedSources = T{
os.write(
T.ctx().dest / "Version.scala",
s"""package sjsonnet
|object Version{
| val version = ${pprint.Util.literalize(sjsonnetVersion)}
|}
|""".stripMargin
)
Seq(PathRef(T.ctx().dest / "Version.scala"))
}
def pomSettings = PomSettings(
description = artifactName(),
organization = "com.databricks",
url = "https://github.com/lihaoyi/sjsonnet",
licenses = Seq(License.MIT),
versionControl = VersionControl.github("lihaoyi", "sjsonnet"),
developers = Seq(
Developer("lihaoyi", "Li Haoyi","https://github.com/lihaoyi")
)
)
trait CrossTests extends ScalaModule with TestModule {
def ivyDeps = Agg(ivy"com.lihaoyi::utest::0.7.7")
def testFrameworks = Seq("utest.runner.Framework")
}
}
object js extends SjsonnetCrossModule with ScalaJSModule{
def scalaJSVersion = "1.4.0"
def sources = T.sources(
millSourcePath / "src",
millSourcePath / "src-js",
millSourcePath / "src-jvm-js"
)
object test extends Tests with CrossTests {
def sources = T.sources(
millSourcePath / "src",
millSourcePath / "src-js",
millSourcePath / "src-jvm-js"
)
}
}
object native extends SjsonnetCrossModule with SjsonnetJvmNative with ScalaNativeModule{
def scalaNativeVersion = "0.4.0"
def sources = T.sources(
millSourcePath / "src",
millSourcePath / "src-native",
millSourcePath / "src-jvm-native"
)
def releaseMode = ReleaseMode.ReleaseFast
def nativeLTO = LTO.Thin
object test extends Tests with CrossTests {
def releaseMode = ReleaseMode.Debug
def nativeLTO = LTO.None
def sources = T.sources(
millSourcePath / "src",
millSourcePath / "src-native",
millSourcePath / "src-jvm-native"
)
}
object bench extends ScalaNativeModule{
def releaseMode = ReleaseMode.ReleaseFast
def nativeLTO = LTO.Thin
def moduleDeps = Seq(native)
def scalaNativeVersion = "0.4.0"
def scalaVersion = crossScalaVersion
def sources = T.sources(
millSourcePath / "src",
millSourcePath / "src-native",
millSourcePath / "src-jvm-native"
)
}
}
object jvm extends SjsonnetCrossModule with SjsonnetJvmNative {
def mainClass = Some("sjsonnet.SjsonnetMain")
def sources = T.sources(
millSourcePath / "src",
millSourcePath / "src-jvm",
millSourcePath / "src-jvm-native",
millSourcePath / "src-jvm-js"
)
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"org.json:json:20211205",
ivy"org.tukaani:xz::1.8",
ivy"org.lz4:lz4-java::1.8.0",
ivy"org.yaml:snakeyaml::1.30"
)
def scalacOptions = Seq("-opt:l:inline", "-opt-inline-from:sjsonnet.**")
//def compileIvyDeps = Agg( ivy"com.lihaoyi::acyclic:0.2.0")
//def scalacOptions = Seq("-P:acyclic:force")
//def scalacPluginIvyDeps = Agg( ivy"com.lihaoyi::acyclic:0.2.0")
object test extends Tests with CrossTests{
//def compileIvyDeps = Agg( ivy"com.lihaoyi::acyclic:0.2.0")
//def scalacOptions = Seq("-P:acyclic:force")
//def scalacPluginIvyDeps = Agg( ivy"com.lihaoyi::acyclic:0.2.0")
def forkOptions = Seq("-Xss100m")
def sources = T.sources(
millSourcePath / "src",
millSourcePath / "src-jvm",
millSourcePath / "src-jvm-native"
)
}
object bench extends ScalaModule {
def moduleDeps = Seq(jvm)
def scalaVersion = crossScalaVersion
def sources = T.sources(
millSourcePath / "src",
millSourcePath / "src-jvm",
millSourcePath / "src-jvm-native"
)
}
}
object client extends JavaModule {
def ivyDeps = Agg(
ivy"org.scala-sbt.ipcsocket:ipcsocket:1.0.0".exclude(
"net.java.dev.jna" -> "jna",
"net.java.dev.jna" -> "jna-platform"
)
)
object test extends Tests{
def testFrameworks = Seq("com.novocode.junit.JUnitFramework")
def ivyDeps = Agg(ivy"com.novocode:junit-interface:0.11")
}
}
object server extends ScalaModule{
def scalaVersion = crossScalaVersion
def moduleDeps = Seq(SjsonnetModule.this.jvm, client)
def ivyDeps = Agg(
ivy"org.scala-sbt.ipcsocket:ipcsocket:1.0.0".exclude(
"net.java.dev.jna" -> "jna",
"net.java.dev.jna" -> "jna-platform"
),
ivy"net.java.dev.jna:jna:4.5.0",
ivy"net.java.dev.jna:jna-platform:4.5.0"
)
override def prependShellScript = mill.modules.Jvm.universalScript(
shellCommands = {
def java(mainClass: String) =
s"""exec java -DSJSONNET_EXECUTABLE=$$0 -DSJSONNET_VERSION=$sjsonnetVersion $$JAVA_OPTS -cp $$0 $mainClass "$$@""""
s"""case "$$1" in
| -i | --interactive )
| ${java("sjsonnet.SjsonnetMain")}
| ;;
| *)
| ${java("sjsonnet.client.SjsonnetClientMain")}
| ;;
|esac""".stripMargin
},
cmdCommands = {
def java(mainClass: String) =
s"""java -DSJSONNET_EXECUTABLE=%~dpnx0 -DSJSONNET_VERSION=$sjsonnetVersion %JAVA_OPTS% -cp %~dpnx0 $mainClass %*"""
s"""if "%1" == "-i" set _I_=true
|if "%1" == "--interactive" set _I_=true
|if defined _I_ (
| ${java("sjsonnet.SjsonnetMain")}
|) else (
| ${java("sjsonnet.client.SjsonnetClientMain")}
|)""".stripMargin
}
)
object test extends Tests{
def testFrameworks = Seq("com.novocode.junit.JUnitFramework")
def ivyDeps = Agg(ivy"com.novocode:junit-interface:0.11")
}
}
}