Skip to content

Commit 5c66d7b

Browse files
Generate only TASTy in stdlib-bootstrapped (#17909)
2 parents 8aae57e + 6b7889b commit 5c66d7b

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
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-tasty-tests/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-tasty-tests/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-bootstrapped-tasty` = Build.`stdlib-bootstrapped-tasty`
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: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ object Build {
936936
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
937937
settings(commonBootstrappedSettings).
938938
settings(
939-
moduleName := "scala-library",
939+
moduleName := "scala2-library",
940940
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
941941
Compile / scalacOptions ++= {
942942
Seq("-sourcepath", ((Compile/sourceManaged).value / "scala-library-src").toString)
@@ -1025,10 +1025,10 @@ object Build {
10251025
|""".stripMargin)
10261026

10271027
}).value,
1028-
// TODO package only TASTy files.
1029-
// We first need to check that a project can depend on a JAR that only contains TASTy files.
1030-
// Compile / exportJars := true,
1031-
// Compile / packageBin / mappings ~= { _.filter(_._2.endsWith(".tasty")) },
1028+
Compile / exportJars := true,
1029+
artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
1030+
"scala2-library-" + dottyVersion + "." + artifact.extension
1031+
},
10321032
run := {
10331033
val log = streams.value.log
10341034
val args: Seq[String] = spaceDelimited("<arg>").parsed
@@ -1077,7 +1077,21 @@ object Build {
10771077
}
10781078
)
10791079

1080+
/** Packages the TASTy files of `stdlib-bootstrapped` in a jar */
1081+
lazy val `stdlib-bootstrapped-tasty` = project.in(file("stdlib-bootstrapped-tasty")).
1082+
withCommonSettings(Bootstrapped).
1083+
settings(
1084+
exportJars := true,
1085+
Compile / packageBin / mappings := {
1086+
(`stdlib-bootstrapped` / Compile / packageBin / mappings).value
1087+
.filter(_._2.endsWith(".tasty"))
1088+
},
1089+
)
1090+
10801091
/** Test the tasty generated by `stdlib-bootstrapped`
1092+
*
1093+
* The sources in src are compiled using TASTy from stdlib-bootstrapped-tasty but then run
1094+
* with the scala-library compiled be Scala 2.
10811095
*
10821096
* The tests are run with the bootstrapped compiler and the tasty inpector on the classpath.
10831097
* The classpath has the default `scala-library` and not `stdlib-bootstrapped`.
@@ -1088,11 +1102,23 @@ object Build {
10881102
*/
10891103
lazy val `stdlib-bootstrapped-tasty-tests` = project.in(file("stdlib-bootstrapped-tasty-tests")).
10901104
withCommonSettings(Bootstrapped).
1105+
dependsOn(dottyCompiler(Bootstrapped) % "compile->compile").
10911106
dependsOn(`scala3-tasty-inspector` % "test->test").
1107+
dependsOn(`stdlib-bootstrapped-tasty`).
10921108
settings(commonBootstrappedSettings).
10931109
settings(
10941110
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
1095-
javaOptions += "-Ddotty.scala.library=" + (`stdlib-bootstrapped` / Compile / packageBin).value.getAbsolutePath
1111+
Test / javaOptions += "-Ddotty.scala.library=" + (`stdlib-bootstrapped` / Compile / packageBin).value.getAbsolutePath,
1112+
Compile / compile / fullClasspath ~= {
1113+
_.filterNot(file => file.data.getName == s"scala-library-${stdlibVersion(Bootstrapped)}.jar")
1114+
},
1115+
Compile / compile / dependencyClasspath := {
1116+
// make sure that the scala2-library (tasty of `stdlib-bootstrapped-tasty`) is listed before the scala-library (classfiles)
1117+
val (bootstrappedLib, otherLibs) =
1118+
(Compile / compile / dependencyClasspath).value
1119+
.partition(_.data.getName == s"scala2-library-${dottyVersion}.jar")
1120+
bootstrappedLib ++ otherLibs
1121+
},
10961122
)
10971123

10981124
lazy val `scala3-sbt-bridge` = project.in(file("sbt-bridge/src")).

0 commit comments

Comments
 (0)