Skip to content

Commit 86c1592

Browse files
committed
chore: add configuration for scala3-staging
1 parent 287f746 commit 86c1592

File tree

3 files changed

+77
-2
lines changed

3 files changed

+77
-2
lines changed

.github/workflows/stdlib.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,23 @@ jobs:
183183
- name: Compile `scala3-sbt-bridge-bootstrapped`
184184
run: ./project/scripts/sbt scala3-sbt-bridge-bootstrapped/compile
185185

186+
scala3-staging:
187+
runs-on: ubuntu-latest
188+
##needs: [scala3-compiler-bootstrapped] Add when we add support for caching here
189+
steps:
190+
- name: Git Checkout
191+
uses: actions/checkout@v4
192+
193+
- name: Set up JDK 17
194+
uses: actions/setup-java@v4
195+
with:
196+
distribution: 'temurin'
197+
java-version: 17
198+
cache: 'sbt'
199+
- uses: sbt/setup-sbt@v1
200+
- name: Compile `scala3-staging`
201+
run: ./project/scripts/sbt scala3-staging-new/compile
202+
186203
#################################################################################################
187204
########################################### TEST JOBS ###########################################
188205
#################################################################################################

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ val `scala3-sbt-bridge-bootstrapped` = Build.`scala3-sbt-bridge-bootstrapped`
1919
val `scala3-sbt-bridge-nonbootstrapped` = Build.`scala3-sbt-bridge-nonbootstrapped`
2020
val `scala3-sbt-bridge-tests` = Build.`scala3-sbt-bridge-tests`
2121
val `scala3-staging` = Build.`scala3-staging`
22+
val `scala3-staging-new` = Build.`scala3-staging-new`
2223
val `scala3-tasty-inspector` = Build.`scala3-tasty-inspector`
2324
val `scala3-language-server` = Build.`scala3-language-server`
2425
val `scala3-bench` = Build.`scala3-bench`

project/Build.scala

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,8 @@ object Build {
14501450

14511451
lazy val `scala3-bootstrapped-new` = project
14521452
.aggregate(`scala3-interfaces`, `scala3-library-bootstrapped-new` , `scala-library-bootstrapped`,
1453-
`tasty-core-bootstrapped-new`, `scala3-compiler-bootstrapped-new`, `scala3-sbt-bridge-bootstrapped`)
1453+
`tasty-core-bootstrapped-new`, `scala3-compiler-bootstrapped-new`, `scala3-sbt-bridge-bootstrapped`,
1454+
`scala3-staging-new`)
14541455
.settings(
14551456
name := "scala3-bootstrapped",
14561457
moduleName := "scala3-bootstrapped",
@@ -1494,7 +1495,6 @@ object Build {
14941495
"org.scala-lang" % "scala-reflect",
14951496
"org.scala-lang" % "scala-compiler",
14961497
),
1497-
//
14981498
// Packaging configuration of `scala3-sbt-bridge`
14991499
Compile / packageBin / publishArtifact := true,
15001500
Compile / packageDoc / publishArtifact := false,
@@ -1533,6 +1533,63 @@ object Build {
15331533
},
15341534
)
15351535

1536+
/* Configuration of the org.scala-lang:scala3-staging:*.**.**-bootstrapped project */
1537+
lazy val `scala3-staging-new` = project.in(file("staging"))
1538+
// We want the compiler to be present in the compiler classpath when compiling this project but not
1539+
// when compiling a project that depends on scala3-staging (see sbt-test/sbt-dotty/quoted-example-project),
1540+
// but we always need it to be present on the JVM classpath at runtime.
1541+
.dependsOn(`scala3-compiler-bootstrapped-new` % "provided; compile->runtime; test->test")
1542+
.settings(
1543+
name := "scala3-staging",
1544+
moduleName := "scala3-staging",
1545+
version := dottyVersion,
1546+
versionScheme := Some("semver-spec"),
1547+
scalaVersion := referenceVersion,
1548+
crossPaths := true, // org.scala-lang:scala3-staging has a crosspath
1549+
autoScalaLibrary := false, // do not add a dependency to stdlib, we depend transitively on the stdlib from `scala3-compiler-bootstrapped`
1550+
// Add the source directories for the sbt-bridge (boostrapped)
1551+
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
1552+
Test / unmanagedSourceDirectories := Seq(baseDirectory.value / "test"),
1553+
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
1554+
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
1555+
// Make sure that the produced artifacts have the minimum JVM version in the bytecode
1556+
Compile / javacOptions ++= Seq("--target", Versions.minimumJVMVersion),
1557+
Compile / scalacOptions ++= Seq("--java-output-version", Versions.minimumJVMVersion),
1558+
// Packaging configuration of `scala3-staging`
1559+
Compile / packageBin / publishArtifact := true,
1560+
Compile / packageDoc / publishArtifact := false,
1561+
Compile / packageSrc / publishArtifact := true,
1562+
// Only publish compilation artifacts, no test artifacts
1563+
Test / publishArtifact := false,
1564+
publish / skip := false,
1565+
// Configure to use the non-bootstrapped compiler
1566+
scalaInstance := {
1567+
val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
1568+
1569+
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
1570+
// just directories containing classfiles because sbt maintains a cache of
1571+
// compiler instances. This cache is invalidated based on timestamps
1572+
// however this is only implemented on jars, directories are never
1573+
// invalidated.
1574+
val tastyCore = (`tasty-core-nonbootstrapped` / Compile / packageBin).value
1575+
val scalaLibrary = (`scala-library-nonbootstrapped` / Compile / packageBin).value
1576+
val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
1577+
val scala3Compiler = (`scala3-compiler-nonbootstrapped` / Compile / packageBin).value
1578+
1579+
Defaults.makeScalaInstance(
1580+
dottyNonBootstrappedVersion,
1581+
libraryJars = Array(scalaLibrary),
1582+
allCompilerJars = Seq(tastyCore, scala3Interfaces, scala3Compiler) ++ externalCompilerDeps,
1583+
allDocJars = Seq.empty,
1584+
state.value,
1585+
scalaInstanceTopLoader.value
1586+
)
1587+
},
1588+
scalaCompilerBridgeBinaryJar := {
1589+
Some((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
1590+
},
1591+
)
1592+
15361593
// ==============================================================================================
15371594
// =================================== SCALA STANDARD LIBRARY ===================================
15381595
// ==============================================================================================

0 commit comments

Comments
 (0)