Skip to content

Commit b34cd61

Browse files
committed
Add stdlib-2_13-bootstrapped to bootstrap the 2.13 library
1 parent 51d69e8 commit b34cd61

File tree

4 files changed

+73
-38
lines changed

4 files changed

+73
-38
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134

135135
- name: Cmd Tests
136136
run: |
137-
./project/scripts/sbt ";dist/pack; scala3-bootstrapped/compile; scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped/test:run ;stdlib-bootstrapped-tasty-tests/test; scala3-compiler-bootstrapped/scala3CompilerCoursierTest:test"
137+
./project/scripts/sbt ";dist/pack; scala3-bootstrapped/compile; scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped/test:run ;stdlib-2_13-bootstrapped/test:run ;stdlib-bootstrapped-tasty-tests/test; scala3-compiler-bootstrapped/scala3CompilerCoursierTest:test"
138138
./project/scripts/cmdTests
139139
./project/scripts/bootstrappedOnlyCmdTests
140140
@@ -488,7 +488,7 @@ jobs:
488488

489489
- name: Test
490490
run: |
491-
./project/scripts/sbt ";dist/pack ;scala3-bootstrapped/compile ;scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped/test:run ;stdlib-bootstrapped-tasty-tests/test"
491+
./project/scripts/sbt ";dist/pack ;scala3-bootstrapped/compile ;scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped/test:run ;stdlib-2_13-bootstrapped/test:run ;stdlib-bootstrapped-tasty-tests/test"
492492
./project/scripts/cmdTests
493493
./project/scripts/bootstrappedOnlyCmdTests
494494

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ val `scala3-bench` = Build.`scala3-bench`
1515
val `scala3-bench-bootstrapped` = Build.`scala3-bench-bootstrapped`
1616
val `scala3-bench-micro` = Build.`scala3-bench-micro`
1717
val `stdlib-bootstrapped` = Build.`stdlib-bootstrapped`
18+
val `stdlib-2_13-bootstrapped` = Build.`stdlib-2_13-bootstrapped`
1819
val `stdlib-bootstrapped-tasty-tests` = Build.`stdlib-bootstrapped-tasty-tests`
1920
val `tasty-core` = Build.`tasty-core`
2021
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`

project/Build.scala

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -922,15 +922,17 @@ object Build {
922922
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value
923923
)
924924

925-
/** Scala library compiled by dotty using the latest published sources of the library */
925+
/** Scala library compiled by dotty using the latest published sources of the 2.13 library
926+
* and the current Scala 3 library sources.
927+
*
928+
* This version of the library is not binary compatible with the Scala 2 compiled library.
929+
* It compiles every file as Scala 3 sources.
930+
*/
926931
lazy val `stdlib-bootstrapped` = project.in(file("stdlib-bootstrapped")).
927932
withCommonSettings(Bootstrapped).
928933
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
929-
settings(commonBootstrappedSettings).
934+
settings(commonStdlibBootstrappedSettings).
930935
settings(
931-
moduleName := "scala-library",
932-
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
933-
Compile/scalacOptions += "-Yerased-terms",
934936
Compile/scalacOptions ++= {
935937
Seq(
936938
"-sourcepath",
@@ -940,36 +942,6 @@ object Build {
940942
).mkString(File.pathSeparator),
941943
)
942944
},
943-
Compile / doc / scalacOptions += "-Ydocument-synthetic-types",
944-
scalacOptions -= "-Xfatal-warnings",
945-
ivyConfigurations += SourceDeps.hide,
946-
transitiveClassifiers := Seq("sources"),
947-
libraryDependencies +=
948-
("org.scala-lang" % "scala-library" % stdlibVersion(Bootstrapped) % "sourcedeps"),
949-
(Compile / sourceGenerators) += Def.task {
950-
val s = streams.value
951-
val cacheDir = s.cacheDirectory
952-
val trgDir = (Compile / sourceManaged).value / "scala-library-src"
953-
954-
val report = updateClassifiers.value
955-
val scalaLibrarySourcesJar = report.select(
956-
configuration = configurationFilter("sourcedeps"),
957-
module = (_: ModuleID).name == "scala-library",
958-
artifact = artifactFilter(`type` = "src")).headOption.getOrElse {
959-
sys.error(s"Could not fetch scala-library sources")
960-
}
961-
962-
FileFunction.cached(cacheDir / s"fetchScalaLibrarySrc",
963-
FilesInfo.lastModified, FilesInfo.exists) { dependencies =>
964-
s.log.info(s"Unpacking scala-library sources to $trgDir...")
965-
if (trgDir.exists)
966-
IO.delete(trgDir)
967-
IO.createDirectory(trgDir)
968-
IO.unzip(scalaLibrarySourcesJar, trgDir)
969-
970-
((trgDir ** "*.scala") +++ (trgDir ** "*.java")).get.toSet
971-
} (Set(scalaLibrarySourcesJar)).toSeq
972-
}.taskValue,
973945
(Compile / sourceGenerators) += Def.task {
974946
val s = streams.value
975947
val cacheDir = s.cacheDirectory
@@ -1000,6 +972,56 @@ object Build {
1000972

1001973
cachedFun(dottyLibSources.get.toSet).toSeq
1002974
}.taskValue,
975+
)
976+
977+
/** Scala 2 library compiled by dotty using the latest published sources of the library.
978+
*
979+
* This version of the library is not (yet) binary compatible with the Scala 2 compiled library.
980+
*/
981+
lazy val `stdlib-2_13-bootstrapped` = project.in(file("stdlib-2_13-bootstrapped")).
982+
withCommonSettings(Bootstrapped).
983+
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
984+
settings(commonStdlibBootstrappedSettings).
985+
settings(
986+
Compile/scalacOptions ++= {
987+
Seq("-sourcepath", ((Compile/sourceManaged).value / "scala-library-src").toString)
988+
},
989+
)
990+
991+
lazy val commonStdlibBootstrappedSettings =
992+
commonBootstrappedSettings ++ Seq(
993+
moduleName := "scala-library",
994+
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
995+
Compile / doc / scalacOptions += "-Ydocument-synthetic-types",
996+
scalacOptions -= "-Xfatal-warnings",
997+
ivyConfigurations += SourceDeps.hide,
998+
transitiveClassifiers := Seq("sources"),
999+
libraryDependencies +=
1000+
("org.scala-lang" % "scala-library" % stdlibVersion(Bootstrapped) % "sourcedeps"),
1001+
(Compile / sourceGenerators) += Def.task {
1002+
val s = streams.value
1003+
val cacheDir = s.cacheDirectory
1004+
val trgDir = (Compile / sourceManaged).value / "scala-library-src"
1005+
1006+
val report = updateClassifiers.value
1007+
val scalaLibrarySourcesJar = report.select(
1008+
configuration = configurationFilter("sourcedeps"),
1009+
module = (_: ModuleID).name == "scala-library",
1010+
artifact = artifactFilter(`type` = "src")).headOption.getOrElse {
1011+
sys.error(s"Could not fetch scala-library sources")
1012+
}
1013+
1014+
FileFunction.cached(cacheDir / s"fetchScalaLibrarySrc",
1015+
FilesInfo.lastModified, FilesInfo.exists) { dependencies =>
1016+
s.log.info(s"Unpacking scala-library sources to $trgDir...")
1017+
if (trgDir.exists)
1018+
IO.delete(trgDir)
1019+
IO.createDirectory(trgDir)
1020+
IO.unzip(scalaLibrarySourcesJar, trgDir)
1021+
1022+
((trgDir ** "*.scala") +++ (trgDir ** "*.java")).get.toSet
1023+
} (Set(scalaLibrarySourcesJar)).toSeq
1024+
}.taskValue,
10031025
(Compile / sources) ~= (_.filterNot(file =>
10041026
// sources from https://github.com/scala/scala/tree/2.13.x/src/library-aux
10051027
file.getPath.endsWith("scala-library-src/scala/Any.scala") ||
@@ -1011,7 +1033,7 @@ object Build {
10111033
(Test / managedClasspath) ~= {
10121034
_.filterNot(file => file.data.getName == s"scala-library-${stdlibVersion(Bootstrapped)}.jar")
10131035
},
1014-
)
1036+
)
10151037

10161038
/** Test the tasty generated by `stdlib-bootstrapped`
10171039
*
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package hello
2+
3+
enum Color:
4+
case Red, Green, Blue
5+
6+
object HelloWorld:
7+
def main(args: Array[String]): Unit = {
8+
println("hello 2.13 library bootstrapped")
9+
println(Color.Red)
10+
println(Color.Green)
11+
println(Color.Blue)
12+
}

0 commit comments

Comments
 (0)