Skip to content

Commit c841e2f

Browse files
committed
Build.scala: add bootstrapped projects
1 parent 53b29ac commit c841e2f

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,7 @@ 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+
lazy val dottyCompilerSettings = Seq(
163160
// set system in/out for repl
164161
connectInput in run := true,
165162
outputStrategy := Some(StdoutOutput),
@@ -178,28 +175,18 @@ object DottyBuild extends Build {
178175

179176
// get libraries onboard
180177
partestDeps := Seq(scalaCompiler,
181-
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
182-
"org.scala-lang" % "scala-library" % scalaVersion.value % "test"),
178+
"org.scala-lang" % "scala-reflect" % scalacVersion,
179+
"org.scala-lang" % "scala-library" % scalacVersion % "test"),
183180
libraryDependencies ++= partestDeps.value,
184181
libraryDependencies ++= Seq("org.scala-lang.modules" %% "scala-xml" % "1.0.1",
185182
"org.scala-lang.modules" %% "scala-partest" % "1.0.11" % "test",
186-
"ch.epfl.lamp" % "dottydoc-client" % "0.1.0",
183+
dottyOrganization % "dottydoc-client" % "0.1.0",
187184
"com.novocode" % "junit-interface" % "0.11" % "test",
188185
"com.github.spullara.mustache.java" % "compiler" % "0.9.3",
189186
"com.typesafe.sbt" % "sbt-interface" % sbtVersion.value),
190187
// enable improved incremental compilation algorithm
191188
incOptions := incOptions.value.withNameHashing(true),
192189

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-
203190
// For convenience, change the baseDirectory when running the compiler
204191
baseDirectory in (Compile, run) := baseDirectory.value / "..",
205192
// .. but not when running partest
@@ -274,8 +261,8 @@ object DottyBuild extends Build {
274261
val args = Def.spaceDelimited("<arg>").parsed
275262
val jars = List(
276263
(packageBin in Compile).value.getAbsolutePath,
277-
(packageBin in (`dotty-library`, Compile)).value.getAbsolutePath,
278-
(packageBin in (`dotty-interfaces`, Compile)).value.getAbsolutePath
264+
packageAll.value("dotty-library"),
265+
packageAll.value("dotty-interfaces")
279266
) ++ getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
280267
val dottyJars =
281268
s"""-dottyJars ${jars.length + 2} dotty.jar dotty-lib.jar ${jars.mkString(" ")}"""
@@ -364,9 +351,60 @@ object DottyBuild extends Build {
364351

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

390+
lazy val `dotty-compiler-bootstrapped` = project.in(file("compiler")).
391+
dependsOn(`dotty-library-bootstrapped`).
392+
settings(sourceStructure).
393+
settings(commonBootstrappedSettings).
394+
settings(dottyCompilerSettings).
395+
settings(
396+
// Used instead of "dependsOn(`dotty-interfaces`)" because the latter breaks sbt somehow
397+
libraryDependencies += scalaOrganization.value % "dotty-interfaces" % version.value
398+
).
399+
settings(
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)