Skip to content

Commit 79fdbff

Browse files
committed
chore: add configuration for scala3-tasty-inspector
1 parent 86c1592 commit 79fdbff

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed

.github/workflows/stdlib.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,25 @@ jobs:
200200
- name: Compile `scala3-staging`
201201
run: ./project/scripts/sbt scala3-staging-new/compile
202202

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+
203222
#################################################################################################
204223
########################################### TEST JOBS ###########################################
205224
#################################################################################################

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ val `scala3-sbt-bridge-tests` = Build.`scala3-sbt-bridge-tests`
2121
val `scala3-staging` = Build.`scala3-staging`
2222
val `scala3-staging-new` = Build.`scala3-staging-new`
2323
val `scala3-tasty-inspector` = Build.`scala3-tasty-inspector`
24+
val `scala3-tasty-inspector-new` = Build.`scala3-tasty-inspector-new`
2425
val `scala3-language-server` = Build.`scala3-language-server`
2526
val `scala3-bench` = Build.`scala3-bench`
2627
val `scala3-bench-bootstrapped` = Build.`scala3-bench-bootstrapped`

project/Build.scala

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ object Build {
14511451
lazy val `scala3-bootstrapped-new` = project
14521452
.aggregate(`scala3-interfaces`, `scala3-library-bootstrapped-new` , `scala-library-bootstrapped`,
14531453
`tasty-core-bootstrapped-new`, `scala3-compiler-bootstrapped-new`, `scala3-sbt-bridge-bootstrapped`,
1454-
`scala3-staging-new`)
1454+
`scala3-staging-new`, `scala3-tasty-inspector-new`)
14551455
.settings(
14561456
name := "scala3-bootstrapped",
14571457
moduleName := "scala3-bootstrapped",
@@ -1590,6 +1590,63 @@ object Build {
15901590
},
15911591
)
15921592

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+
15931650
// ==============================================================================================
15941651
// =================================== SCALA STANDARD LIBRARY ===================================
15951652
// ==============================================================================================

0 commit comments

Comments
 (0)