This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
build.sc
117 lines (89 loc) · 3.35 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
// SPDX-License-Identifier: Apache-2.0
// Build script for mill 0.6.0
import mill._
import mill.scalalib._
import mill.scalalib.publish._
import coursier.maven.MavenRepository
import $ivy.`com.lihaoyi::mill-contrib-buildinfo:$MILL_VERSION`
import mill.contrib.buildinfo.BuildInfo
object treadle extends mill.Cross[treadleCrossModule]("2.12.13", "2.13.5")
// The following stanza is searched for and used when preparing releases.
// Please retain it.
// Provide a managed dependency on X if -DXVersion="" is supplied on the command line.
val defaultVersions = Map(
"firrtl" -> "1.6-SNAPSHOT"
)
def getVersion(dep: String, org: String = "edu.berkeley.cs") = {
val version = sys.env.getOrElse(dep + "Version", defaultVersions(dep))
ivy"$org::$dep:$version"
}
trait CommonModule extends ScalaModule with SbtModule with PublishModule {
def firrtlModule: Option[PublishModule] = None
def firrtlIvyDeps = if (firrtlModule.isEmpty)
Agg(
getVersion("firrtl")
)
else Agg.empty[Dep]
def moduleDeps = Seq() ++ firrtlModule
def ivyDeps = super.ivyDeps() ++ firrtlIvyDeps
def publishVersion = "1.6-SNAPSHOT"
protected def majorVersion = crossVersion.split('.')(1).toInt
def crossVersion: String
def scalaVersion = crossVersion
def repositories() = super.repositories ++ Seq(
MavenRepository("https://oss.sonatype.org/content/repositories/snapshots"),
MavenRepository("https://oss.sonatype.org/content/repositories/releases")
)
private def javacCrossOptions = majorVersion match {
case i if i < 12 => Seq("-source", "1.7", "-target", "1.7")
case _ => Seq("-source", "1.8", "-target", "1.8")
}
override def scalacOptions = super.scalacOptions() ++ Agg(
"-deprecation",
"-feature"
)
override def javacOptions = super.javacOptions() ++ javacCrossOptions
def pomSettings = PomSettings(
description = artifactName(),
organization = "edu.berkeley.cs",
url = "https://www.chisel-lang.org",
licenses = Seq(License.`Apache-2.0`),
versionControl = VersionControl.github("freechipsproject", "treadle"),
developers = Seq(
Developer("jackbackrack", "Jonathan Bachrach", "https://eecs.berkeley.edu/~jrb/")
)
)
}
class treadleCrossModule(crossVersionValue: String) extends CommonModule with PublishModule with BuildInfo { m =>
// different scala version shares same sources
// mill use foo/2.12.13 by default
override def millSourcePath = super.millSourcePath / os.up / os.up
def crossVersion = crossVersionValue
def mainClass = Some("treadle.repl.TreadleReplMain")
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"org.scala-lang.modules:scala-jline:2.12.1",
)
object test extends Tests {
private def ivyCrossDeps = majorVersion match {
case i if i < 12 => Agg(ivy"junit:junit:4.13")
case _ => Agg()
}
def ivyDeps = Agg(
ivy"org.scalatest::scalatest:3.2.9",
) ++ ivyCrossDeps
def testFrameworks = Seq("org.scalatest.tools.Framework")
}
override def buildInfoPackageName = Some("treadle")
override def buildInfoMembers: T[Map[String, String]] = T {
Map(
"buildInfoPackage" -> artifactName(),
"version" -> publishVersion(),
"scalaVersion" -> scalaVersion()
)
}
override def generatedSources = T {
Seq(generatedBuildInfo()._2)
}
// make mill publish sbt compatible package
def artifactName = "treadle"
}