Skip to content

Commit 5e5f2a7

Browse files
committed
[WIP] Full bootstrap: Use Dotty as the reference compiler
Before merging this I'd like to: - Wait for 0.13.0-RC1 to be released. - Change the nomenclature used in the build ("non-bootstrapped dotty" and "bootstrapped dotty" are not descriptive enough when the reference compiler is also dotty). - Cross-compile the build with 2.12 on the CI so that we don't accidentally start using Dotty features in case we need to revert this PR (we'll start usin Dotty features eventually, but let's wait until we're confident that this setup works well enough).
1 parent ea95606 commit 5e5f2a7

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

project/Build.scala

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import scala.util.Properties.isJavaAtLeast
3030

3131
object Build {
3232
val scalacVersion = "2.12.8"
33+
val referenceVersion = "0.14.0-bin-20190321-bb0a1ed-NIGHTLY"
3334

3435
val baseVersion = "0.14.0"
3536
val baseSbtDottyVersion = "0.3.2"
@@ -182,21 +183,27 @@ object Build {
182183
// Settings used for projects compiled only with Java
183184
lazy val commonJavaSettings = commonSettings ++ Seq(
184185
version := dottyVersion,
185-
scalaVersion := scalacVersion,
186+
scalaVersion := referenceVersion,
186187
// Do not append Scala versions to the generated artifacts
187188
crossPaths := false,
188189
// Do not depend on the Scala library
189190
autoScalaLibrary := false
190191
)
191192

192-
// Settings used when compiling dotty using Scala 2
193-
lazy val commonNonBootstrappedSettings = commonSettings ++ Seq(
193+
// Settings used when compiling dotty (both non-boostrapped and bootstrapped)
194+
lazy val commonDottySettings = commonSettings ++ Seq(
195+
// Manually set the standard library to use
196+
autoScalaLibrary := false
197+
)
198+
199+
// Settings used when compiling dotty with the reference compiler
200+
lazy val commonNonBootstrappedSettings = commonDottySettings ++ Seq(
194201
version := dottyNonBootstrappedVersion,
195-
scalaVersion := scalacVersion
202+
scalaVersion := referenceVersion
196203
)
197204

198205
// Settings used when compiling dotty with a non-bootstrapped dotty
199-
lazy val commonBootstrappedSettings = commonSettings ++ Seq(
206+
lazy val commonBootstrappedSettings = commonDottySettings ++ Seq(
200207
version := dottyVersion,
201208
scalaVersion := dottyNonBootstrappedVersion,
202209

@@ -219,11 +226,6 @@ object Build {
219226
// sbt gets very unhappy if two projects use the same target
220227
target := baseDirectory.value / ".." / "out" / "bootstrap" / name.value,
221228

222-
// The non-bootstrapped dotty-library is not necessary when bootstrapping dotty
223-
autoScalaLibrary := false,
224-
// ...but scala-library is
225-
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion,
226-
227229
// Compile using the non-bootstrapped and non-published dotty
228230
managedScalaInstance := false,
229231
scalaInstance := {
@@ -466,7 +468,7 @@ object Build {
466468
"-Ddotty.tests.classes.dottyLibrary=" + jars("dotty-library"),
467469
"-Ddotty.tests.classes.dottyCompiler=" + jars("dotty-compiler"),
468470
"-Ddotty.tests.classes.compilerInterface=" + findLib(attList, "compiler-interface"),
469-
"-Ddotty.tests.classes.scalaLibrary=" + findLib(attList, "scala-library"),
471+
"-Ddotty.tests.classes.scalaLibrary=" + findLib(attList, "scala-library-"),
470472
"-Ddotty.tests.classes.scalaAsm=" + findLib(attList, "scala-asm"),
471473
"-Ddotty.tests.classes.scalaXml=" + findLib(attList, "scala-xml"),
472474
"-Ddotty.tests.classes.jlineTerminal=" + findLib(attList, "jline-terminal"),
@@ -506,9 +508,6 @@ object Build {
506508
} else if (scalaLib == "") {
507509
println("Couldn't find scala-library on classpath, please run using script in bin dir instead")
508510
} else if (args.contains("-with-compiler")) {
509-
if (!isDotty.value) {
510-
throw new MessageOnlyException("-with-compiler can only be used with a bootstrapped compiler")
511-
}
512511
val args1 = args.filter(_ != "-with-compiler")
513512
val asm = findLib(attList, "scala-asm")
514513
val dottyCompiler = jars("dotty-compiler")
@@ -558,7 +557,7 @@ object Build {
558557
def runCompilerMain(repl: Boolean = false) = Def.inputTaskDyn {
559558
val attList = (dependencyClasspath in Runtime).value
560559
val jars = packageAll.value
561-
val scalaLib = findLib(attList, "scala-library")
560+
val scalaLib = findLib(attList, "scala-library-")
562561
val dottyLib = jars("dotty-library")
563562
val dottyCompiler = jars("dotty-compiler")
564563
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
@@ -576,12 +575,8 @@ object Build {
576575

577576
var extraClasspath = s"$scalaLib${File.pathSeparator}$dottyLib"
578577
if ((decompile || printTasty) && !args.contains("-classpath")) extraClasspath += s"${File.pathSeparator}."
579-
if (args0.contains("-with-compiler")) {
580-
if (!isDotty.value) {
581-
throw new MessageOnlyException("-with-compiler can only be used with a bootstrapped compiler")
582-
}
578+
if (args0.contains("-with-compiler"))
583579
extraClasspath += s"${File.pathSeparator}$dottyCompiler"
584-
}
585580

586581
val fullArgs = main :: insertClasspathInArgs(args, extraClasspath)
587582

@@ -642,8 +637,12 @@ object Build {
642637
// Settings shared between dotty-library and dotty-library-bootstrapped
643638
lazy val dottyLibrarySettings = Seq(
644639
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion,
640+
641+
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
642+
scalacOptions in Compile ++= Seq("-sourcepath", (scalaSource in Compile).value.getAbsolutePath),
643+
645644
// Add version-specific source directories:
646-
// - files in src-non-bootstrapped will only be compiled by the reference compiler (scalac)
645+
// - files in src-non-bootstrapped will only be compiled by the reference compiler
647646
// - files in src-bootstrapped will only be compiled by the current dotty compiler (non-bootstrapped and bootstrapped)
648647
unmanagedSourceDirectories in Compile += {
649648
val baseDir = baseDirectory.value
@@ -1149,11 +1148,7 @@ object Build {
11491148
settings(dottyCompilerSettings)
11501149

11511150
def asDottyLibrary(implicit mode: Mode): Project = project.withCommonSettings.
1152-
settings(dottyLibrarySettings).
1153-
bootstrappedSettings(
1154-
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called.
1155-
scalacOptions in Compile ++= Seq("-sourcepath", (scalaSource in Compile).value.getAbsolutePath)
1156-
)
1151+
settings(dottyLibrarySettings)
11571152

11581153
def asDottyDoc(implicit mode: Mode): Project = project.withCommonSettings.
11591154
dependsOn(dottyCompiler, dottyCompiler % "test->test").

0 commit comments

Comments
 (0)