Skip to content

Commit adbc33b

Browse files
committed
chore: add scala3-sbt-bridge-bootstrapped to the new build
1 parent 94fe8ea commit adbc33b

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

.github/workflows/stdlib.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,20 @@ jobs:
165165
- uses: sbt/setup-sbt@v1
166166
- name: Compile `scala3-compiler-bootstrapped`
167167
run: ./project/scripts/sbt scala3-compiler-bootstrapped-new/compile
168+
169+
scala3-sbt-bridge-bootstrapped:
170+
runs-on: ubuntu-latest
171+
##needs: [scala3-compiler-bootstrapped] Add when we add support for caching here
172+
steps:
173+
- name: Git Checkout
174+
uses: actions/checkout@v4
175+
176+
- name: Set up JDK 17
177+
uses: actions/setup-java@v4
178+
with:
179+
distribution: 'temurin'
180+
java-version: 17
181+
cache: 'sbt'
182+
- uses: sbt/setup-sbt@v1
183+
- name: Compile `scala3-sbt-bridge-bootstrapped`
184+
run: ./project/scripts/sbt scala3-sbt-bridge-bootstrapped/compile

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ val `scala3-library` = Build.`scala3-library`
1414
val `scala3-library-bootstrapped` = Build.`scala3-library-bootstrapped`
1515
val `scala3-library-bootstrappedJS` = Build.`scala3-library-bootstrappedJS`
1616
val `scala3-sbt-bridge` = Build.`scala3-sbt-bridge`
17+
val `scala3-sbt-bridge-bootstrapped` = Build.`scala3-sbt-bridge-bootstrapped`
1718
val `scala3-sbt-bridge-nonbootstrapped` = Build.`scala3-sbt-bridge-nonbootstrapped`
1819
val `scala3-sbt-bridge-tests` = Build.`scala3-sbt-bridge-tests`
1920
val `scala3-staging` = Build.`scala3-staging`

project/Build.scala

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,67 @@ object Build {
14311431
)},
14321432
)
14331433

1434+
// ==============================================================================================
1435+
// =================================== BOOTSTRAPPED PROJECTS ====================================
1436+
// ==============================================================================================
1437+
1438+
/* Configuration of the org.scala-lang:scala3-sbt-bridge:*.**.**-bootstrapped project */
1439+
lazy val `scala3-sbt-bridge-bootstrapped` = project.in(file("sbt-bridge"))
1440+
.dependsOn(`scala3-compiler-bootstrapped`) // TODO: Would this actually evict the reference compiler in scala-tool?
1441+
.settings(
1442+
name := "scala3-sbt-bridge-bootstrapped",
1443+
moduleName := "scala3-sbt-bridge",
1444+
version := dottyVersion,
1445+
versionScheme := Some("semver-spec"),
1446+
scalaVersion := dottyNonBootstrappedVersion, // nonbootstrapped artifacts are compiled with the reference compiler (already officially published)
1447+
crossPaths := false, // org.scala-lang:scala3-sbt-bridge doesn't have a crosspath
1448+
autoScalaLibrary := false, // do not add a dependency to stdlib, we depend transitively on the stdlib from `scala3-compiler-nonbootstrapped`
1449+
// Add the source directories for the stdlib (non-boostrapped)
1450+
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
1451+
Compile / resourceDirectory := baseDirectory.value / "resources",
1452+
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
1453+
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
1454+
// Make sure that the produced artifacts have the minimum JVM version in the bytecode
1455+
Compile / javacOptions ++= Seq("--target", Versions.minimumJVMVersion),
1456+
Compile / scalacOptions ++= Seq("--java-output-version", Versions.minimumJVMVersion),
1457+
// Packaging configuration of the stdlib
1458+
Compile / packageBin / publishArtifact := true,
1459+
Compile / packageDoc / publishArtifact := false,
1460+
Compile / packageSrc / publishArtifact := true,
1461+
// Only publish compilation artifacts, no test artifacts
1462+
Test / publishArtifact := false,
1463+
// non-bootstrapped stdlib is publishable (only locally)
1464+
publish / skip := false,
1465+
// Project specific target folder. sbt doesn't like having two projects using the same target folder
1466+
target := target.value / "scala3-sbt-bridge-bootstrapped",
1467+
// Configure to use the non-bootstrapped compiler
1468+
scalaInstance := {
1469+
val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
1470+
1471+
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
1472+
// just directories containing classfiles because sbt maintains a cache of
1473+
// compiler instances. This cache is invalidated based on timestamps
1474+
// however this is only implemented on jars, directories are never
1475+
// invalidated.
1476+
val tastyCore = (`tasty-core-nonbootstrapped` / Compile / packageBin).value
1477+
val scalaLibrary = (`scala-library-nonbootstrapped` / Compile / packageBin).value
1478+
val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
1479+
val scala3Compiler = (`scala3-compiler-nonbootstrapped` / Compile / packageBin).value
1480+
1481+
Defaults.makeScalaInstance(
1482+
dottyNonBootstrappedVersion,
1483+
libraryJars = Array(scalaLibrary),
1484+
allCompilerJars = Seq(tastyCore, scala3Interfaces, scala3Compiler) ++ externalCompilerDeps,
1485+
allDocJars = Seq.empty,
1486+
state.value,
1487+
scalaInstanceTopLoader.value
1488+
)
1489+
},
1490+
scalaCompilerBridgeBinaryJar := {
1491+
Some((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
1492+
},
1493+
)
1494+
14341495
// ==============================================================================================
14351496
// =================================== SCALA STANDARD LIBRARY ===================================
14361497
// ==============================================================================================

0 commit comments

Comments
 (0)