Skip to content

Commit 12a784c

Browse files
committed
chore: add scala-library-bootstrapped
1 parent f9921f5 commit 12a784c

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ val `scala3-interfaces` = Build.`scala3-interfaces`
44
val `scala3-compiler` = Build.`scala3-compiler`
55
val `scala3-compiler-bootstrapped` = Build.`scala3-compiler-bootstrapped`
66
val `scala-library-nonbootstrapped` = Build.`scala-library-nonbootstrapped`
7+
val `scala-library-bootstrapped` = Build.`scala-library-bootstrapped`
78
val `scala3-library` = Build.`scala3-library`
89
val `scala3-library-bootstrapped` = Build.`scala3-library-bootstrapped`
910
val `scala3-library-bootstrappedJS` = Build.`scala3-library-bootstrappedJS`

project/Build.scala

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,11 +1424,16 @@ object Build {
14241424
versionScheme := Some("semver-spec"),
14251425
scalaVersion := referenceVersion, // nonbootstrapped artifacts are compiled with the reference compiler (already officially published)
14261426
crossPaths := false, // org.scala-lang:scala-library doesn't have a crosspath
1427-
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
1428-
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
1427+
autoScalaLibrary := false, // do not add a dependency to stdlib
14291428
// Add the source directories for the stdlib (non-boostrapped)
14301429
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
14311430
Compile / unmanagedSourceDirectories += baseDirectory.value / "src-non-bootstrapped",
1431+
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
1432+
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
1433+
(Compile / scalacOptions) ++= Seq(
1434+
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
1435+
"-sourcepath", (Compile / sourceDirectories).value.map(_.getCanonicalPath).distinct.mkString(File.pathSeparator),
1436+
),
14321437
// Only publish compilation artifacts, no test artifacts
14331438
Compile / publishArtifact := true,
14341439
Test / publishArtifact := false,
@@ -1438,6 +1443,63 @@ object Build {
14381443
target := target.value / "scala-library-nonbootstrapped",
14391444
)
14401445

1446+
/* Configuration of the org.scala-lang:scala-library:*.**.**-boostrapped project */
1447+
lazy val `scala-library-bootstrapped` = project.in(file("library"))
1448+
.settings(
1449+
name := "scala-library-bootstrapped",
1450+
moduleName := "scala-library",
1451+
version := dottyVersion,
1452+
versionScheme := Some("semver-spec"),
1453+
crossPaths := false, // org.scala-lang:scala-library doesn't have a crosspath
1454+
// Add the source directories for the stdlib (non-boostrapped)
1455+
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
1456+
Compile / unmanagedSourceDirectories += baseDirectory.value / "src-bootstrapped",
1457+
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
1458+
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
1459+
Compile / scalacOptions ++= Seq(
1460+
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
1461+
"-sourcepath", (Compile / sourceDirectories).value.map(_.getCanonicalPath).distinct.mkString(File.pathSeparator),
1462+
),
1463+
// Only publish compilation artifacts, no test artifacts
1464+
Compile / publishArtifact := true,
1465+
Test / publishArtifact := false,
1466+
// Do not allow to publish this project for now
1467+
publish / skip := true,
1468+
// Project specific target folder. sbt doesn't like having two projects using the same target folder
1469+
target := target.value / "scala-library-bootstrapped",
1470+
// Configure the nonbootstrapped compiler
1471+
managedScalaInstance := false,
1472+
scalaInstance := {
1473+
val externalLibraryDeps = (`scala3-library` / Compile / externalDependencyClasspath).value.map(_.data).toSet
1474+
val externalCompilerDeps = (`scala3-compiler` / Compile / externalDependencyClasspath).value.map(_.data).toSet
1475+
1476+
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
1477+
// just directories containing classfiles because sbt maintains a cache of
1478+
// compiler instances. This cache is invalidated based on timestamps
1479+
// however this is only implemented on jars, directories are never
1480+
// invalidated.
1481+
val tastyCore = (`tasty-core` / Compile / packageBin).value
1482+
val scala3Library = (`scala3-library` / Compile / packageBin).value
1483+
val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
1484+
val scala3Compiler = (`scala3-compiler` / Compile / packageBin).value
1485+
1486+
val libraryJars = Array(scala3Library) ++ externalLibraryDeps
1487+
val compilerJars = Seq(tastyCore, scala3Interfaces, scala3Compiler) ++ (externalCompilerDeps -- externalLibraryDeps)
1488+
1489+
Defaults.makeScalaInstance(
1490+
scalaVersion.value,
1491+
libraryJars = libraryJars,
1492+
allCompilerJars = compilerJars,
1493+
allDocJars = Seq.empty,
1494+
state.value,
1495+
scalaInstanceTopLoader.value
1496+
)
1497+
},
1498+
scalaCompilerBridgeBinaryJar := {
1499+
Some((`scala3-sbt-bridge` / Compile / packageBin).value)
1500+
},
1501+
)
1502+
14411503
def dottyLibrary(implicit mode: Mode): Project = mode match {
14421504
case NonBootstrapped => `scala3-library`
14431505
case Bootstrapped => `scala3-library-bootstrapped`

0 commit comments

Comments
 (0)