Skip to content

Commit c8a0f4d

Browse files
committed
chore: add scala-library-cc project
1 parent b872039 commit c8a0f4d

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

.github/workflows/stdlib.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,24 @@ jobs:
219219
- name: Compile `scala3-tasty-inspector`
220220
run: ./project/scripts/sbt scala3-tasty-inspector-new/compile
221221

222+
scala-library-cc:
223+
runs-on: ubuntu-latest
224+
needs : [scala3-compiler-nonbootstrapped, scala3-sbt-bridge-nonbootstrapped, scala-library-nonbootstrapped, scala3-library-nonbootstrapped]
225+
steps:
226+
- name: Git Checkout
227+
uses: actions/checkout@v4
228+
229+
- name: Set up JDK 17
230+
uses: actions/setup-java@v4
231+
with:
232+
distribution: 'temurin'
233+
java-version: 17
234+
cache: 'sbt'
235+
236+
- uses: sbt/setup-sbt@v1
237+
- name: Compile `scala-library-cc`
238+
run: ./project/scripts/sbt scala-library-cc/compile
239+
222240
#################################################################################################
223241
########################################### TEST JOBS ###########################################
224242
#################################################################################################

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ val `scala-library-bootstrapped` = Build.`scala-library-bootstrapped`
1313
val `scala3-library-bootstrapped-new` = Build.`scala3-library-bootstrapped-new`
1414
val `scala3-library` = Build.`scala3-library`
1515
val `scala3-library-bootstrapped` = Build.`scala3-library-bootstrapped`
16+
val `scala-library-cc` = Build.`scala-library-cc`
1617
val `scala3-library-bootstrappedJS` = Build.`scala3-library-bootstrappedJS`
1718
val `scala3-sbt-bridge` = Build.`scala3-sbt-bridge`
1819
val `scala3-sbt-bridge-bootstrapped` = Build.`scala3-sbt-bridge-bootstrapped`

project/Build.scala

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,73 @@ object Build {
16471647
},
16481648
)
16491649

1650+
/* Configuration of the org.scala-lang:scala-library-cc:*.**.**-bootstrapped */
1651+
lazy val `scala-library-cc` = project.in(file("library"))
1652+
.enablePlugins(ScalaLibraryPlugin)
1653+
.settings(
1654+
name := "scala-library-cc",
1655+
moduleName := "scala-library-cc",
1656+
version := dottyVersion,
1657+
versionScheme := Some("semver-spec"),
1658+
// sbt defaults to scala 2.12.x and metals will report issues as it doesn't consider the project a scala 3 project
1659+
// (not the actual version we use to compile the project)
1660+
scalaVersion := referenceVersion,
1661+
crossPaths := true,
1662+
// Add the source directories for the stdlib (non-boostrapped)
1663+
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
1664+
Compile / unmanagedSourceDirectories += baseDirectory.value / "src-bootstrapped",
1665+
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
1666+
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
1667+
Compile / scalacOptions += "-Yno-stdlib-patches",
1668+
Compile / scalacOptions ++= Seq(
1669+
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
1670+
"-sourcepath", (Compile / sourceDirectories).value.map(_.getCanonicalPath).distinct.mkString(File.pathSeparator),
1671+
),
1672+
// Make sure that the produced artifacts have the minimum JVM version in the bytecode
1673+
Compile / javacOptions ++= Seq("--target", Versions.minimumJVMVersion),
1674+
Compile / scalacOptions ++= Seq("--java-output-version", Versions.minimumJVMVersion),
1675+
// Packaging configuration of the stdlib
1676+
Compile / packageBin / publishArtifact := true,
1677+
Compile / packageDoc / publishArtifact := false,
1678+
Compile / packageSrc / publishArtifact := true,
1679+
// Only publish compilation artifacts, no test artifacts
1680+
Test / publishArtifact := false,
1681+
// Do not allow to publish this project for now
1682+
publish / skip := false,
1683+
// Project specific target folder. sbt doesn't like having two projects using the same target folder
1684+
target := target.value / "scala-library-cc",
1685+
// we need to have the `scala-library` artifact in the classpath for `ScalaLibraryPlugin` to work
1686+
// this was the only way to not get the artifact evicted by sbt. Even a custom configuration didn't work
1687+
// NOTE: true is the default value, just making things clearer here
1688+
managedScalaInstance := true,
1689+
// Configure the nonbootstrapped compiler
1690+
scalaInstance := {
1691+
val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
1692+
1693+
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
1694+
// just directories containing classfiles because sbt maintains a cache of
1695+
// compiler instances. This cache is invalidated based on timestamps
1696+
// however this is only implemented on jars, directories are never
1697+
// invalidated.
1698+
val tastyCore = (`tasty-core-nonbootstrapped` / Compile / packageBin).value
1699+
val scalaLibrary = (`scala-library-nonbootstrapped` / Compile / packageBin).value
1700+
val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
1701+
val scala3Compiler = (`scala3-compiler-nonbootstrapped` / Compile / packageBin).value
1702+
1703+
Defaults.makeScalaInstance(
1704+
dottyNonBootstrappedVersion,
1705+
libraryJars = Array(scalaLibrary),
1706+
allCompilerJars = Seq(tastyCore, scala3Interfaces, scala3Compiler) ++ externalCompilerDeps,
1707+
allDocJars = Seq.empty,
1708+
state.value,
1709+
scalaInstanceTopLoader.value
1710+
)
1711+
},
1712+
scalaCompilerBridgeBinaryJar := {
1713+
Some((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
1714+
},
1715+
)
1716+
16501717
// ==============================================================================================
16511718
// =================================== SCALA STANDARD LIBRARY ===================================
16521719
// ==============================================================================================

0 commit comments

Comments
 (0)