-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sc
147 lines (101 loc) · 3.17 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
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.3.0`
import de.tobiasroeser.mill.vcs.version.VcsVersion
import mill._, scalalib._, scalajslib._, define.Source
import $file.fix, fix.FixedScalaNativeModule
def projectVersion = T { VcsVersion.vcsState().format(commitCountPad = -1, countSep = "") }
object main extends ScalaModule {
def scalaVersion = "3.1.3"
def ivyDeps = Agg(
ivy"org.scala-lang.modules::scala-parser-combinators::2.1.1"
)
def testAll() = T.command {
T.sequence {
Seq(jvm.test.test(), native.test.test())
}
}
object test extends Tests {
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.11"
)
def testFramework = "utest.runner.Framework"
}
trait ChildModule extends ScalaModule {
def scalaVersion = main.scalaVersion
def ivyDeps = super.ivyDeps() ++ main.ivyDeps()
def sources = T.sources(
super.sources() ++ main.sources()
)
def resources = T.sources(
super.resources() ++ main.resources()
)
}
trait ChildTestModule extends TestModule {
def ivyDeps = super.ivyDeps() ++ main.test.ivyDeps()
def testFramework = main.test.testFramework
def sources = T.sources(
super.sources() ++ main.test.sources()
)
def resources = T.sources(
super.resources() ++ main.test.resources()
)
}
object jvm extends ChildModule {
object test extends Tests with ChildTestModule
}
object native extends ChildModule with FixedScalaNativeModule {
def scalaNativeVersion = "0.4.4"
//TODO submit changes to Mill
def scalaLibraryIvyDeps = T {
Agg(
ivy"${scalaOrganization()}::scala3-library:${scalaVersion()}".forceVersion()
)
}
object test extends Tests with ChildTestModule
}
object js extends ChildModule with ScalaJSModule {
def scalaJSVersion = "1.11.0"
}
}
object cli extends FixedScalaNativeModule {
def scalaVersion = main.scalaVersion
def scalaNativeVersion = "0.4.4"
def moduleDeps = Seq(main.native)
def versionFile: Source = T.source {
val file = T.dest / "versions.properties"
os.write(
file,
Map(
"CYLang" -> projectVersion(),
"Scala" -> scalaVersion(),
"Scala Native" -> scalaNativeVersion()
)
.map {case (a, b) => s"$a=$b"}
.mkString("\n")
)
T.dest
}
def resources = T.sources { super.resources() :+ versionFile() }
}
object webeditor extends ScalaJSModule {
def scalaVersion = main.scalaVersion
def scalaJSVersion = "1.11.0"
def moduleDeps = Seq(main.js)
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"org.scala-js::scalajs-dom::2.2.0",
ivy"io.indigoengine::tyrian::0.5.1",
ivy"io.indigoengine::tyrian-io::0.5.1",
ivy"co.fs2::fs2-core:3.3.0",
ivy"co.fs2::fs2-io:3.3.0"
)
def moduleKind = T(mill.scalajslib.api.ModuleKind.CommonJSModule)
def buildSite() = T.command {
os.copy.into(fastOpt().path, T.dest)
val resourcesDir = T.dest / "resources"
if(!os.exists(resourcesDir)) os.makeDir(resourcesDir)
(resources() ++ main.js.resources())
.map(_.path)
.filter(os.exists)
.flatMap(os.list)
.foreach(x => os.copy.into(x, resourcesDir))
}
}