@@ -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,59 @@ 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+ // NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
1455+ Compile / scalacOptions := Seq (" -deprecation" , " -feature" , " -unchecked" , " -encoding" , " UTF8" , " -language:implicitConversions" ),
1456+ // Add the source directories for the stdlib (non-boostrapped)
1457+ Compile / unmanagedSourceDirectories := Seq (baseDirectory.value / " src" ),
1458+ Compile / unmanagedSourceDirectories += baseDirectory.value / " src-bootstrapped" ,
1459+ // Only publish compilation artifacts, no test artifacts
1460+ Compile / publishArtifact := true ,
1461+ Test / publishArtifact := false ,
1462+ // Do not allow to publish this project for now
1463+ publish / skip := true ,
1464+ // Project specific target folder. sbt doesn't like having two projects using the same target folder
1465+ target := target.value / " scala-library-bootstrapped" ,
1466+ // Configure the nonbootstrapped compiler
1467+ managedScalaInstance := false ,
1468+ scalaInstance := {
1469+ val externalLibraryDeps = (`scala3-library` / Compile / externalDependencyClasspath).value.map(_.data).toSet
1470+ val externalCompilerDeps = (`scala3-compiler` / Compile / externalDependencyClasspath).value.map(_.data).toSet
1471+
1472+ // IMPORTANT: We need to use actual jars to form the ScalaInstance and not
1473+ // just directories containing classfiles because sbt maintains a cache of
1474+ // compiler instances. This cache is invalidated based on timestamps
1475+ // however this is only implemented on jars, directories are never
1476+ // invalidated.
1477+ val tastyCore = (`tasty-core` / Compile / packageBin).value
1478+ val scala3Library = (`scala3-library` / Compile / packageBin).value
1479+ val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
1480+ val scala3Compiler = (`scala3-compiler` / Compile / packageBin).value
1481+
1482+ val libraryJars = Array (scala3Library) ++ externalLibraryDeps
1483+ val compilerJars = Seq (tastyCore, scala3Interfaces, scala3Compiler) ++ (externalCompilerDeps -- externalLibraryDeps)
1484+
1485+ Defaults .makeScalaInstance(
1486+ scalaVersion.value,
1487+ libraryJars = libraryJars,
1488+ allCompilerJars = compilerJars,
1489+ allDocJars = Seq .empty,
1490+ state.value,
1491+ scalaInstanceTopLoader.value
1492+ )
1493+ },
1494+ scalaCompilerBridgeBinaryJar := {
1495+ Some ((`scala3-sbt-bridge` / Compile / packageBin).value)
1496+ },
1497+ )
1498+
14411499 def dottyLibrary (implicit mode : Mode ): Project = mode match {
14421500 case NonBootstrapped => `scala3-library`
14431501 case Bootstrapped => `scala3-library-bootstrapped`
0 commit comments