Skip to content

Commit f0967f9

Browse files
committed
chore: add scala-library-bootstrapped
1 parent 161a336 commit f0967f9

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,59 @@ object Build {
14441444
},
14451445
)
14461446

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

0 commit comments

Comments
 (0)