Skip to content

Commit f2cf246

Browse files
committed
WIP use bootstraped lib in testCompilation
1 parent 7bad9e6 commit f2cf246

File tree

2 files changed

+44
-35
lines changed

2 files changed

+44
-35
lines changed

project/Build.scala

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,17 @@ object Build {
363363
lazy val dottySbtBridgeBootstrappedRef = LocalProject("dotty-sbt-bridge-bootstrapped")
364364

365365
def dottySbtBridgeReference(implicit mode: Mode): LocalProject = mode match {
366-
case NonBootstrapped => dottySbtBridgeRef
367-
case _ => dottySbtBridgeBootstrappedRef
366+
case FullyBootstrapped => dottySbtBridgeBootstrappedRef
367+
case _ => dottySbtBridgeRef
368368
}
369369

370370
// The root project:
371371
// - aggregates other projects so that "compile", "test", etc are run on all projects at once.
372372
// - publishes its own empty artifact "dotty" that depends on "dotty-library" and "dotty-compiler",
373373
// this is only necessary for compatibility with sbt which currently hardcodes the "dotty" artifact name
374-
lazy val dotty = project.in(file(".")).asDottyRoot(NonBootstrapped)
375-
lazy val `dotty-bootstrapped` = project.asDottyRoot(Bootstrapped)
374+
lazy val `dotty-non-bootstrapped-lib` = project.in(file(".")).asDottyRoot(WithNonBootstrappedLib)
375+
lazy val dotty = project.in(file(".")).asDottyRoot(WithBootstrappedLib)
376+
lazy val `dotty-bootstrapped` = project.asDottyRoot(FullyBootstrapped)
376377

377378
lazy val `dotty-interfaces` = project.in(file("interfaces")).
378379
settings(commonScala2Settings). // Java-only project, so this is fine
@@ -462,12 +463,12 @@ object Build {
462463
}
463464
)
464465

465-
lazy val `dotty-doc` = project.in(file("doc-tool")).asDottyDoc(NonBootstrapped)
466-
lazy val `dotty-doc-bootstrapped` = project.in(file("doc-tool")).asDottyDoc(Bootstrapped)
466+
lazy val `dotty-doc` = project.in(file("doc-tool")).asDottyDoc(WithNonBootstrappedLib)
467+
lazy val `dotty-doc-bootstrapped` = project.in(file("doc-tool")).asDottyDoc(FullyBootstrapped)
467468

468469
def dottyDoc(implicit mode: Mode): Project = mode match {
469-
case NonBootstrapped => `dotty-doc`
470-
case Bootstrapped => `dotty-doc-bootstrapped`
470+
case FullyBootstrapped => `dotty-doc-bootstrapped`
471+
case _ => `dotty-doc`
471472
}
472473

473474
def testOnlyFiltered(test: String, options: String) = Def.inputTaskDyn {
@@ -765,14 +766,14 @@ object Build {
765766
)
766767

767768
def dottyCompilerSettings(implicit mode: Mode): sbt.Def.SettingsDefinition =
768-
if (mode == NonBootstrapped) nonBootstrapedDottyCompilerSettings else bootstrapedDottyCompilerSettings
769+
if (mode == WithNonBootstrappedLib) nonBootstrapedDottyCompilerSettings else bootstrapedDottyCompilerSettings
769770

770-
lazy val `dotty-compiler` = project.in(file("compiler")).asDottyCompiler(NonBootstrapped)
771-
lazy val `dotty-compiler-bootstrapped` = project.in(file("compiler")).asDottyCompiler(Bootstrapped)
771+
lazy val `dotty-compiler` = project.in(file("compiler")).asDottyCompiler(WithNonBootstrappedLib)
772+
lazy val `dotty-compiler-bootstrapped` = project.in(file("compiler")).asDottyCompiler(FullyBootstrapped)
772773

773774
def dottyCompiler(implicit mode: Mode): Project = mode match {
774-
case NonBootstrapped => `dotty-compiler`
775-
case Bootstrapped => `dotty-compiler-bootstrapped`
775+
case FullyBootstrapped => `dotty-compiler-bootstrapped`
776+
case _ => `dotty-compiler`
776777
}
777778

778779
// Settings shared between dotty-library and dotty-library-bootstrapped
@@ -790,12 +791,12 @@ object Build {
790791
}
791792
)
792793

793-
lazy val `dotty-library` = project.in(file("library")).asDottyLibrary(NonBootstrapped)
794-
lazy val `dotty-library-bootstrapped`: Project = project.in(file("library")).asDottyLibrary(Bootstrapped)
794+
lazy val `dotty-library` = project.in(file("library")).asDottyLibrary(WithNonBootstrappedLib)
795+
lazy val `dotty-library-bootstrapped`: Project = project.in(file("library")).asDottyLibrary(WithBootstrappedLib)
795796

796797
def dottyLibrary(implicit mode: Mode): Project = mode match {
797-
case NonBootstrapped => `dotty-library`
798-
case Bootstrapped => `dotty-library-bootstrapped`
798+
case WithNonBootstrappedLib => `dotty-library`
799+
case _ => `dotty-library-bootstrapped`
799800
}
800801

801802
// until sbt/sbt#2402 is fixed (https://github.com/sbt/sbt/issues/2402)
@@ -841,8 +842,8 @@ object Build {
841842
parallelExecution in Test := false
842843
)
843844

844-
lazy val `dotty-sbt-bridge` = project.in(file("sbt-bridge")).asDottySbtBridge(NonBootstrapped)
845-
lazy val `dotty-sbt-bridge-bootstrapped` = project.in(file("sbt-bridge")).asDottySbtBridge(Bootstrapped)
845+
lazy val `dotty-sbt-bridge` = project.in(file("sbt-bridge")).asDottySbtBridge(WithNonBootstrappedLib)
846+
lazy val `dotty-sbt-bridge-bootstrapped` = project.in(file("sbt-bridge")).asDottySbtBridge(FullyBootstrapped)
846847
.settings(
847848
// Tweak -Yscala2-unpickler to allow some sbt dependencies used in tests
848849
/*
@@ -862,7 +863,7 @@ object Build {
862863
)
863864

864865
lazy val `dotty-language-server` = project.in(file("language-server")).
865-
dependsOn(dottyCompiler(Bootstrapped)).
866+
dependsOn(dottyCompiler(FullyBootstrapped)).
866867
settings(commonBootstrappedSettings).
867868
settings(
868869
// Sources representing the shared configuration file used to communicate between the sbt-dotty
@@ -955,10 +956,10 @@ object Build {
955956
).
956957
settings(compileWithDottySettings)
957958

958-
lazy val `dotty-bench` = project.in(file("bench")).asDottyBench(NonBootstrapped)
959-
lazy val `dotty-bench-bootstrapped` = project.in(file("bench")).asDottyBench(Bootstrapped)
959+
lazy val `dotty-bench` = project.in(file("bench")).asDottyBench(WithNonBootstrappedLib)
960+
lazy val `dotty-bench-bootstrapped` = project.in(file("bench")).asDottyBench(FullyBootstrapped)
960961

961-
lazy val `dotty-semanticdb` = project.in(file("semanticdb")).asDottySemanticdb(Bootstrapped)
962+
lazy val `dotty-semanticdb` = project.in(file("semanticdb")).asDottySemanticdb(FullyBootstrapped)
962963
lazy val `dotty-semanticdb-input` = project.in(file("semanticdb/input")).settings(
963964
scalaVersion := "2.12.7",
964965
scalacOptions += "-Yrangepos",
@@ -1272,11 +1273,11 @@ object Build {
12721273
packArchiveName := "dotty-" + dottyVersion
12731274
)
12741275

1275-
lazy val dist = project.asDist(NonBootstrapped)
1276+
lazy val dist = project.asDist(WithNonBootstrappedLib)
12761277
.settings(
12771278
packResourceDir += (baseDirectory.value / "bin" -> "bin"),
12781279
)
1279-
lazy val `dist-bootstrapped` = project.asDist(Bootstrapped)
1280+
lazy val `dist-bootstrapped` = project.asDist(FullyBootstrapped)
12801281
.settings(
12811282
packResourceDir += ((baseDirectory in dist).value / "bin" -> "bin"),
12821283
)
@@ -1334,8 +1335,8 @@ object Build {
13341335
)
13351336

13361337
def withCommonSettings(implicit mode: Mode): Project = project.settings(mode match {
1337-
case NonBootstrapped => commonNonBootstrappedSettings
1338-
case Bootstrapped => commonBootstrappedSettings
1338+
case FullyBootstrapped => commonBootstrappedSettings
1339+
case _ => commonNonBootstrappedSettings
13391340
})
13401341
}
13411342
}

project/Modes.scala

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,31 @@ import sbt.{Project, ProjectReference, SettingsDefinition}
33
object Modes {
44

55
sealed trait Mode
6+
sealed trait NonBootstrappedMode extends Mode
67

7-
object NonBootstrapped extends Mode
8-
object Bootstrapped extends Mode
8+
object WithNonBootstrappedLib extends NonBootstrappedMode
9+
object WithBootstrappedLib extends NonBootstrappedMode
10+
object FullyBootstrapped extends Mode
911

1012
implicit class ProjectModesOps(val project: Project) extends AnyVal {
1113

1214
/** Applies the settings if mode is not bootstrapped */
13-
def nonBootstrappedSettings(s: SettingsDefinition*)(implicit mode: Mode): Project =
14-
if (mode == NonBootstrapped) project.settings(s: _*) else project
15+
def nonBootstrappedSettings(s: SettingsDefinition*)(implicit mode: Mode): Project = mode match {
16+
case _: NonBootstrappedMode => project.settings(s: _*)
17+
case _ => project
18+
}
1519

1620
/** Applies the settings if mode is bootstrapped */
17-
def bootstrappedSettings(s: SettingsDefinition*)(implicit mode: Mode): Project =
18-
if (mode == NonBootstrapped) project else project.settings(s: _*)
21+
def bootstrappedSettings(s: SettingsDefinition*)(implicit mode: Mode): Project = mode match {
22+
case _: NonBootstrappedMode => project
23+
case _ => project.settings(s: _*)
24+
}
1925

2026
/** Aggregate only if the mode is bootstrapped */
21-
def bootstrappedAggregate(s: ProjectReference*)(implicit mode: Mode): Project =
22-
if (mode == NonBootstrapped) project else project.aggregate(s: _*)
27+
def bootstrappedAggregate(s: ProjectReference*)(implicit mode: Mode): Project = mode match {
28+
case _: NonBootstrappedMode => project
29+
case _ => project.aggregate(s: _*)
30+
}
2331

2432
}
2533
}

0 commit comments

Comments
 (0)