Skip to content

Commit 5899730

Browse files
authored
chore: add the scala-library projects (non-bootstrapped and bootstrapped) (#23510)
Add the configuration for the `scala-library` project in sbt. For now, this configuration is disabled and doesn't publish anything until we enable it in 3.8.0
2 parents 73b935c + a19c2b0 commit 5899730

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed

.github/workflows/stdlib.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Compile Full Standard Library
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
compile-nonbootstrapped:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Git Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'temurin'
23+
java-version: 17
24+
cache: 'sbt'
25+
26+
- uses: sbt/setup-sbt@v1
27+
- name: Compile `scala-library-nonbootstrapped`
28+
run: ./project/scripts/sbt scala-library-nonbootstrapped/compile
29+
30+
compile-bootstrapped:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Git Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Set up JDK 17
37+
uses: actions/setup-java@v4
38+
with:
39+
distribution: 'temurin'
40+
java-version: 17
41+
cache: 'sbt'
42+
43+
- uses: sbt/setup-sbt@v1
44+
- name: Compile `scala-library-bootstrapped`
45+
run: ./project/scripts/sbt scala-library-bootstrapped/compile
46+

build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ val `scala3-bootstrapped` = Build.`scala3-bootstrapped`
33
val `scala3-interfaces` = Build.`scala3-interfaces`
44
val `scala3-compiler` = Build.`scala3-compiler`
55
val `scala3-compiler-bootstrapped` = Build.`scala3-compiler-bootstrapped`
6+
val `scala-library-nonbootstrapped` = Build.`scala-library-nonbootstrapped`
7+
val `scala-library-bootstrapped` = Build.`scala-library-bootstrapped`
68
val `scala3-library` = Build.`scala3-library`
79
val `scala3-library-bootstrapped` = Build.`scala3-library-bootstrapped`
810
val `scala3-library-bootstrappedJS` = Build.`scala3-library-bootstrappedJS`

project/Build.scala

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,95 @@ object Build {
14111411
)
14121412
)
14131413

1414+
// ==============================================================================================
1415+
// =================================== SCALA STANDARD LIBRARY ===================================
1416+
// ==============================================================================================
1417+
1418+
/* Configuration of the org.scala-lang:scala-library:*.**.**-nonboostrapped project */
1419+
lazy val `scala-library-nonbootstrapped` = project.in(file("library"))
1420+
.settings(
1421+
name := "scala-library-nonbootstrapped",
1422+
moduleName := "scala-library",
1423+
version := dottyNonBootstrappedVersion,
1424+
versionScheme := Some("semver-spec"),
1425+
scalaVersion := referenceVersion, // nonbootstrapped artifacts are compiled with the reference compiler (already officially published)
1426+
crossPaths := false, // org.scala-lang:scala-library doesn't have a crosspath
1427+
autoScalaLibrary := false, // do not add a dependency to stdlib
1428+
// Add the source directories for the stdlib (non-boostrapped)
1429+
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
1430+
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+
),
1437+
// Only publish compilation artifacts, no test artifacts
1438+
Compile / publishArtifact := true,
1439+
Test / publishArtifact := false,
1440+
// Do not allow to publish this project for now
1441+
publish / skip := true,
1442+
// Project specific target folder. sbt doesn't like having two projects using the same target folder
1443+
target := target.value / "scala-library-nonbootstrapped",
1444+
)
1445+
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+
14141503
def dottyLibrary(implicit mode: Mode): Project = mode match {
14151504
case NonBootstrapped => `scala3-library`
14161505
case Bootstrapped => `scala3-library-bootstrapped`

0 commit comments

Comments
 (0)