Skip to content

Commit cbe6846

Browse files
committed
Add sbt-based bootstrap
This adds two new project to the sbt build: dotty-library-bootstrapped and dotty-compiler bootstrapped. These projects use the same source files as dotty-library and dotty-compiler but are compiled using dotty itself. The main usecase for this is that we can now run the JUnit tests (which are _not_ just a subset of the tests run by partest, for example the REPL tests are only run through JUnit) with a bootstrapped compiler: $ sbt > publishLocal # Non-bootstrapped dotty needs to be published first > dotty-compiler-bootstrapped/test But this also allows one to experiment with a bootstrapped dotty much more easily in general. This revealed many issues in the compiler that are fixed in subsequent commits in this PR.
1 parent 6419a06 commit cbe6846

File tree

1 file changed

+96
-50
lines changed

1 file changed

+96
-50
lines changed

project/Build.scala

Lines changed: 96 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@ import sbt.Package.ManifestAttributes
1111

1212
object DottyBuild extends Build {
1313

14-
val baseVersion = "0.1.1"
15-
val isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes")
14+
val scalacVersion = "2.11.5"
15+
16+
val dottyOrganization = "ch.epfl.lamp"
17+
val dottyVersion = {
18+
val baseVersion = "0.1.1"
19+
val isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes")
20+
if (isNightly)
21+
baseVersion + "-" + VersionUtil.commitDate + "-" + VersionUtil.gitHash + "-NIGHTLY"
22+
else
23+
baseVersion + "-SNAPSHOT"
24+
}
1625

1726
val jenkinsMemLimit = List("-Xmx1500m")
1827

@@ -45,14 +54,9 @@ object DottyBuild extends Build {
4554

4655
override def settings: Seq[Setting[_]] = {
4756
super.settings ++ Seq(
48-
scalaVersion in Global := "2.11.5",
49-
version in Global := {
50-
if (isNightly)
51-
baseVersion + "-" + VersionUtil.commitDate + "-" + VersionUtil.gitHash + "-NIGHTLY"
52-
else
53-
baseVersion + "-SNAPSHOT"
54-
},
55-
organization in Global := "ch.epfl.lamp",
57+
scalaVersion in Global := scalacVersion,
58+
version in Global := dottyVersion,
59+
organization in Global := dottyOrganization,
5660
organizationName in Global := "LAMP/EPFL",
5761
organizationHomepage in Global := Some(url("http://lamp.epfl.ch")),
5862
homepage in Global := Some(url("https://github.com/lampepfl/dotty")),
@@ -82,6 +86,17 @@ object DottyBuild extends Build {
8286
resourceDirectory in Compile := baseDirectory.value / "resources"
8387
)
8488

89+
// Settings used by all dotty-compiled projects
90+
lazy val commonBootstrappedSettings = Seq(
91+
scalaOrganization := dottyOrganization,
92+
scalaVersion := dottyVersion,
93+
scalaBinaryVersion := "2.11",
94+
scalaCompilerBridgeSource :=
95+
(dottyOrganization % "dotty-sbt-bridge" % scalaVersion.value % "component").sources(),
96+
97+
// sbt gets very unhappy if two projects use the same target
98+
target := baseDirectory.value / ".." / "out" / name.value
99+
)
85100

86101
/** Projects -------------------------------------------------------------- */
87102

@@ -141,25 +156,8 @@ object DottyBuild extends Build {
141156
).
142157
settings(publishing)
143158

144-
lazy val `dotty-compiler` = project.in(file("compiler")).
145-
dependsOn(`dotty-interfaces`).
146-
dependsOn(`dotty-library`).
147-
settings(sourceStructure).
148-
settings(
149-
overrideScalaVersionSetting,
150-
151-
// Disable scaladoc generation, it's way too slow and we'll replace it
152-
// by dottydoc anyway. We still publish an empty -javadoc.jar to make
153-
// sonatype happy.
154-
sources in (Compile, doc) := Seq(),
155-
156-
// necessary evil: dottydoc currently needs to be included in the dotty
157-
// project, for sbt integration
158-
unmanagedSourceDirectories in Compile := Seq((scalaSource in Compile).value),
159-
unmanagedSourceDirectories in Compile += baseDirectory.value / ".." / "doc-tool" / "src",
160-
unmanagedSourceDirectories in Test := Seq((scalaSource in Test).value),
161-
unmanagedSourceDirectories in Test += baseDirectory.value / ".." / "doc-tool" / "test",
162-
159+
// Settings shared between dotty-compiler and dotty-compiler-bootstrapped
160+
lazy val dottyCompilerSettings = Seq(
163161
// set system in/out for repl
164162
connectInput in run := true,
165163
outputStrategy := Some(StdoutOutput),
@@ -178,28 +176,18 @@ object DottyBuild extends Build {
178176

179177
// get libraries onboard
180178
partestDeps := Seq(scalaCompiler,
181-
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
182-
"org.scala-lang" % "scala-library" % scalaVersion.value % "test"),
179+
"org.scala-lang" % "scala-reflect" % scalacVersion,
180+
"org.scala-lang" % "scala-library" % scalacVersion % "test"),
183181
libraryDependencies ++= partestDeps.value,
184182
libraryDependencies ++= Seq("org.scala-lang.modules" %% "scala-xml" % "1.0.1",
185183
"org.scala-lang.modules" %% "scala-partest" % "1.0.11" % "test",
186-
"ch.epfl.lamp" % "dottydoc-client" % "0.1.0",
184+
dottyOrganization % "dottydoc-client" % "0.1.0",
187185
"com.novocode" % "junit-interface" % "0.11" % "test",
188186
"com.github.spullara.mustache.java" % "compiler" % "0.9.3",
189187
"com.typesafe.sbt" % "sbt-interface" % sbtVersion.value),
190188
// enable improved incremental compilation algorithm
191189
incOptions := incOptions.value.withNameHashing(true),
192190

193-
// packageAll packages all and then returns a map with the abs location
194-
packageAll := {
195-
Map(
196-
"dotty-interfaces" -> (packageBin in (`dotty-interfaces`, Compile)).value,
197-
"dotty-compiler" -> (packageBin in Compile).value,
198-
"dotty-library" -> (packageBin in (`dotty-library`, Compile)).value,
199-
"dotty-compiler-test" -> (packageBin in Test).value
200-
) map { case (k, v) => (k, v.getAbsolutePath) }
201-
},
202-
203191
// For convenience, change the baseDirectory when running the compiler
204192
baseDirectory in (Compile, run) := baseDirectory.value / "..",
205193
// .. but not when running partest
@@ -274,8 +262,8 @@ object DottyBuild extends Build {
274262
val args = Def.spaceDelimited("<arg>").parsed
275263
val jars = List(
276264
(packageBin in Compile).value.getAbsolutePath,
277-
(packageBin in (`dotty-library`, Compile)).value.getAbsolutePath,
278-
(packageBin in (`dotty-interfaces`, Compile)).value.getAbsolutePath
265+
packageAll.value("dotty-library"),
266+
packageAll.value("dotty-interfaces")
279267
) ++ getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
280268
val dottyJars =
281269
s"""-dottyJars ${jars.length + 2} dotty.jar dotty-lib.jar ${jars.mkString(" ")}"""
@@ -364,9 +352,59 @@ object DottyBuild extends Build {
364352

365353
("-DpartestParentID=" + pid) :: jars ::: tuning ::: agentOptions ::: ci_build ::: path.toList
366354
}
355+
)
356+
357+
lazy val `dotty-compiler` = project.in(file("compiler")).
358+
dependsOn(`dotty-interfaces`).
359+
dependsOn(`dotty-library`).
360+
settings(sourceStructure).
361+
settings(dottyCompilerSettings).
362+
settings(
363+
overrideScalaVersionSetting,
364+
365+
// necessary evil: dottydoc currently needs to be included in the dotty
366+
// project, for sbt integration
367+
// FIXME: note part of dottyCompilerSettings because the doc-tool does not
368+
// compile with dotty
369+
unmanagedSourceDirectories in Compile := Seq((scalaSource in Compile).value),
370+
unmanagedSourceDirectories in Compile += baseDirectory.value / ".." / "doc-tool" / "src",
371+
unmanagedSourceDirectories in Test := Seq((scalaSource in Test).value),
372+
unmanagedSourceDirectories in Test += baseDirectory.value / ".." / "doc-tool" / "test",
373+
374+
// Disable scaladoc generation, it's way too slow and we'll replace it
375+
// by dottydoc anyway. We still publish an empty -javadoc.jar to make
376+
// sonatype happy.
377+
sources in (Compile, doc) := Seq(),
378+
379+
// packageAll packages all and then returns a map with the abs location
380+
packageAll := {
381+
Map(
382+
"dotty-interfaces" -> (packageBin in (`dotty-interfaces`, Compile)).value,
383+
"dotty-compiler" -> (packageBin in Compile).value,
384+
"dotty-library" -> (packageBin in (`dotty-library`, Compile)).value,
385+
"dotty-compiler-test" -> (packageBin in Test).value
386+
) map { case (k, v) => (k, v.getAbsolutePath) }
387+
}
367388
).
368389
settings(publishing)
369390

391+
lazy val `dotty-compiler-bootstrapped` = project.in(file("compiler")).
392+
dependsOn(`dotty-library-bootstrapped`).
393+
settings(sourceStructure).
394+
settings(commonBootstrappedSettings).
395+
settings(dottyCompilerSettings).
396+
settings(
397+
// Used instead of "dependsOn(`dotty-interfaces`)" because the latter breaks sbt somehow
398+
libraryDependencies += scalaOrganization.value % "dotty-interfaces" % version.value,
399+
400+
packageAll := {
401+
(packageAll in `dotty-compiler`).value ++ Seq(
402+
("dotty-compiler" -> (packageBin in Compile).value.getAbsolutePath),
403+
("dotty-library" -> (packageBin in (`dotty-library-bootstrapped`, Compile)).value.getAbsolutePath)
404+
)
405+
}
406+
)
407+
370408
/* Contains unit tests for the scripts */
371409
lazy val `dotty-bin-tests` = project.in(file("bin")).
372410
settings(sourceStructure).
@@ -377,17 +415,25 @@ object DottyBuild extends Build {
377415
"com.novocode" % "junit-interface" % "0.11" % "test"
378416
)
379417

380-
lazy val `dotty-library` = project.in(file("library")).
381-
settings(sourceStructure).
382-
settings(
418+
// Settings shared between dotty-library and dotty-library-bootstrapped
419+
lazy val dottyLibrarySettings = Seq(
383420
libraryDependencies ++= Seq(
384-
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
385-
"org.scala-lang" % "scala-library" % scalaVersion.value,
421+
"org.scala-lang" % "scala-reflect" % scalacVersion,
422+
"org.scala-lang" % "scala-library" % scalacVersion,
386423
"com.novocode" % "junit-interface" % "0.11" % "test"
387424
)
388-
).
425+
)
426+
427+
lazy val `dotty-library` = project.in(file("library")).
428+
settings(sourceStructure).
429+
settings(dottyLibrarySettings).
389430
settings(publishing)
390431

432+
lazy val `dotty-library-bootstrapped` = project.in(file("library")).
433+
settings(sourceStructure).
434+
settings(commonBootstrappedSettings).
435+
settings(dottyLibrarySettings)
436+
391437
// until sbt/sbt#2402 is fixed (https://github.com/sbt/sbt/issues/2402)
392438
lazy val cleanSbtBridge = TaskKey[Unit]("cleanSbtBridge", "delete dotty-sbt-bridge cache")
393439

0 commit comments

Comments
 (0)