Skip to content

Commit b6e3665

Browse files
committed
Add a setting to bootstrap dotty from published jars
Since the previous commit, we bootstrap dotty from the current build output of the non-bootstrapped compiler, but when hacking on the compiler it might be useful to bootstrap from a stable artefact, this is now possible by setting `bootstrapFromPublishedJars` to true. Usage: \# Publish the non-bootstrapped compiler > dotty/publishLocal \# Enable the option > set bootstrapFromPublishedJars in ThisBuild := true \# Bootstrap the compiler > ;dotty-bootstrapped/clean;dotty-bootstrapped/compile
1 parent 36e27ba commit b6e3665

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ val `scala-library` = Build.`scala-library`
1717
val `scala-compiler` = Build.`scala-compiler`
1818
val `scala-reflect` = Build.`scala-reflect`
1919
val scalap = Build.scalap
20+
21+
inThisBuild(Build.thisBuildSettings)

project/Build.scala

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ import sbt.Package.ManifestAttributes
1313

1414
import com.typesafe.sbteclipse.plugin.EclipsePlugin._
1515

16+
/* In sbt 0.13 the Build trait would expose all vals to the shell, where you
17+
* can use them in "set a := b" like expressions. This re-exposes them.
18+
*/
19+
object ExposedValues extends AutoPlugin {
20+
object autoImport {
21+
val bootstrapFromPublishedJars = Build.bootstrapFromPublishedJars
22+
}
23+
}
24+
1625
object Build {
1726

1827
projectChecks()
@@ -66,6 +75,15 @@ object Build {
6675
// Shorthand for compiling a docs site
6776
lazy val dottydoc = inputKey[Unit]("run dottydoc")
6877

78+
lazy val bootstrapFromPublishedJars = settingKey[Boolean]("If true, bootstrap dotty from published non-bootstrapped dotty")
79+
80+
// Used in build.sbt
81+
lazy val thisBuildSettings = Def.settings(
82+
// Change this to true if you want to bootstrap using a published non-bootstrapped compiler
83+
bootstrapFromPublishedJars := false
84+
)
85+
86+
6987
lazy val commonSettings = publishSettings ++ Seq(
7088
organization := dottyOrganization,
7189
organizationName := "LAMP/EPFL",
@@ -131,11 +149,36 @@ object Build {
131149
// ...but scala-library is
132150
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion,
133151

152+
ivyConfigurations ++= {
153+
if (bootstrapFromPublishedJars.value)
154+
Seq(Configurations.ScalaTool)
155+
else
156+
Seq()
157+
},
158+
libraryDependencies ++= {
159+
if (bootstrapFromPublishedJars.value)
160+
Seq(
161+
dottyOrganization % "dotty-library_2.11" % dottyNonBootstrappedVersion % Configurations.ScalaTool.name,
162+
dottyOrganization % "dotty-compiler_2.11" % dottyNonBootstrappedVersion % Configurations.ScalaTool.name
163+
)
164+
else
165+
Seq()
166+
},
167+
134168
// Compile using the non-bootstrapped and non-published dotty
135169
managedScalaInstance := false,
136170
scalaInstance := {
137-
val libraryJar = (packageBin in (`dotty-library`, Compile)).value
138-
val compilerJar = (packageBin in (`dotty-compiler`, Compile)).value
171+
val (libraryJar, compilerJar) =
172+
if (bootstrapFromPublishedJars.value) {
173+
val jars = update.value.select(
174+
configuration = configurationFilter(Configurations.ScalaTool.name),
175+
artifact = artifactFilter(extension = "jar")
176+
)
177+
(jars.find(_.getName.startsWith("dotty-library_2.11")).get,
178+
jars.find(_.getName.startsWith("dotty-compiler_2.11")).get)
179+
} else
180+
((packageBin in (`dotty-library`, Compile)).value,
181+
(packageBin in (`dotty-compiler`, Compile)).value)
139182

140183
// All compiler dependencies except the library
141184
val otherDependencies = (dependencyClasspath in (`dotty-compiler`, Compile)).value

0 commit comments

Comments
 (0)