Skip to content

Commit ceeac54

Browse files
authored
chore: add scala3-staging and scala3-tasty-inspector to the new build (#23624)
Note that the tests haven't been configured yet as they depend on the test configuration of the compiler.
2 parents e936805 + 79fdbff commit ceeac54

File tree

3 files changed

+154
-2
lines changed

3 files changed

+154
-2
lines changed

.github/workflows/stdlib.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,42 @@ 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+
203+
scala3-tasty-inspector:
204+
runs-on: ubuntu-latest
205+
##needs: [scala3-compiler-bootstrapped] Add when we add support for caching here
206+
steps:
207+
- name: Git Checkout
208+
uses: actions/checkout@v4
209+
210+
- name: Set up JDK 17
211+
uses: actions/setup-java@v4
212+
with:
213+
distribution: 'temurin'
214+
java-version: 17
215+
cache: 'sbt'
216+
- uses: sbt/setup-sbt@v1
217+
- name: Compile `scala3-staging`
218+
run: ./project/scripts/sbt scala3-staging-new/compile
219+
- name: Compile `scala3-tasty-inspector`
220+
run: ./project/scripts/sbt scala3-tasty-inspector-new/compile
221+
186222
#################################################################################################
187223
########################################### TEST JOBS ###########################################
188224
#################################################################################################

build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ 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`
24+
val `scala3-tasty-inspector-new` = Build.`scala3-tasty-inspector-new`
2325
val `scala3-language-server` = Build.`scala3-language-server`
2426
val `scala3-bench` = Build.`scala3-bench`
2527
val `scala3-bench-bootstrapped` = Build.`scala3-bench-bootstrapped`

project/Build.scala

Lines changed: 116 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`, `scala3-tasty-inspector-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,120 @@ 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+
1593+
/* Configuration of the org.scala-lang:scala3-tasty-inspector:*.**.**-bootstrapped project */
1594+
lazy val `scala3-tasty-inspector-new` = project.in(file("tasty-inspector"))
1595+
// We want the compiler to be present in the compiler classpath when compiling this project but not
1596+
// when compiling a project that depends on scala3-tasty-inspector (see sbt-test/sbt-dotty/tasty-inspector-example-project),
1597+
// but we always need it to be present on the JVM classpath at runtime.
1598+
.dependsOn(`scala3-compiler-bootstrapped-new` % "provided; compile->runtime; test->test")
1599+
.settings(
1600+
name := "scala3-tasty-inspector",
1601+
moduleName := "scala3-tasty-inspector",
1602+
version := dottyVersion,
1603+
versionScheme := Some("semver-spec"),
1604+
scalaVersion := referenceVersion,
1605+
crossPaths := true, // org.scala-lang:scala3-tasty-inspector has a crosspath
1606+
autoScalaLibrary := false, // do not add a dependency to stdlib, we depend transitively on the stdlib from `scala3-compiler-bootstrapped`
1607+
// Add the source directories for the sbt-bridge (boostrapped)
1608+
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
1609+
Test / unmanagedSourceDirectories := Seq(baseDirectory.value / "test"),
1610+
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
1611+
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
1612+
// Make sure that the produced artifacts have the minimum JVM version in the bytecode
1613+
Compile / javacOptions ++= Seq("--target", Versions.minimumJVMVersion),
1614+
Compile / scalacOptions ++= Seq("--java-output-version", Versions.minimumJVMVersion),
1615+
// Packaging configuration of `scala3-staging`
1616+
Compile / packageBin / publishArtifact := true,
1617+
Compile / packageDoc / publishArtifact := false,
1618+
Compile / packageSrc / publishArtifact := true,
1619+
// Only publish compilation artifacts, no test artifacts
1620+
Test / publishArtifact := false,
1621+
publish / skip := false,
1622+
// Configure to use the non-bootstrapped compiler
1623+
scalaInstance := {
1624+
val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
1625+
1626+
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
1627+
// just directories containing classfiles because sbt maintains a cache of
1628+
// compiler instances. This cache is invalidated based on timestamps
1629+
// however this is only implemented on jars, directories are never
1630+
// invalidated.
1631+
val tastyCore = (`tasty-core-nonbootstrapped` / Compile / packageBin).value
1632+
val scalaLibrary = (`scala-library-nonbootstrapped` / Compile / packageBin).value
1633+
val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
1634+
val scala3Compiler = (`scala3-compiler-nonbootstrapped` / Compile / packageBin).value
1635+
1636+
Defaults.makeScalaInstance(
1637+
dottyNonBootstrappedVersion,
1638+
libraryJars = Array(scalaLibrary),
1639+
allCompilerJars = Seq(tastyCore, scala3Interfaces, scala3Compiler) ++ externalCompilerDeps,
1640+
allDocJars = Seq.empty,
1641+
state.value,
1642+
scalaInstanceTopLoader.value
1643+
)
1644+
},
1645+
scalaCompilerBridgeBinaryJar := {
1646+
Some((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
1647+
},
1648+
)
1649+
15361650
// ==============================================================================================
15371651
// =================================== SCALA STANDARD LIBRARY ===================================
15381652
// ==============================================================================================

0 commit comments

Comments
 (0)