Skip to content

Generate only TASTy in stdlib-bootstrapped #17909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:

- name: Cmd Tests
run: |
./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"
./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"
./project/scripts/cmdTests
./project/scripts/bootstrappedOnlyCmdTests

Expand Down Expand Up @@ -488,7 +488,7 @@ jobs:

- name: Test
run: |
./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"
./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"
./project/scripts/cmdTests
./project/scripts/bootstrappedOnlyCmdTests

Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ val `scala3-bench` = Build.`scala3-bench`
val `scala3-bench-bootstrapped` = Build.`scala3-bench-bootstrapped`
val `scala3-bench-micro` = Build.`scala3-bench-micro`
val `stdlib-bootstrapped` = Build.`stdlib-bootstrapped`
val `stdlib-bootstrapped-tasty` = Build.`stdlib-bootstrapped-tasty`
val `stdlib-bootstrapped-tasty-tests` = Build.`stdlib-bootstrapped-tasty-tests`
val `tasty-core` = Build.`tasty-core`
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`
Expand Down
38 changes: 32 additions & 6 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ object Build {
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
settings(commonBootstrappedSettings).
settings(
moduleName := "scala-library",
moduleName := "scala2-library",
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
Compile / scalacOptions ++= {
Seq("-sourcepath", ((Compile/sourceManaged).value / "scala-library-src").toString)
Expand Down Expand Up @@ -1025,10 +1025,10 @@ object Build {
|""".stripMargin)

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

/** Packages the TASTy files of `stdlib-bootstrapped` in a jar */
lazy val `stdlib-bootstrapped-tasty` = project.in(file("stdlib-bootstrapped-tasty")).
withCommonSettings(Bootstrapped).
settings(
exportJars := true,
Compile / packageBin / mappings := {
(`stdlib-bootstrapped` / Compile / packageBin / mappings).value
.filter(_._2.endsWith(".tasty"))
},
Comment on lines +1084 to +1088
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those settings couldn't go directly in stdlib-boostrapped? Why is this additional project necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the solution you proposed to be able to test MiMa (classfiles) on stdlib-bootstrapped and also have a jar with TASTy only.

An alternative would be to stop testing MiMa and only rely on TASTy MiMa.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, right. That makes sense.

)

/** Test the tasty generated by `stdlib-bootstrapped`
*
* The sources in src are compiled using TASTy from stdlib-bootstrapped-tasty but then run
* with the scala-library compiled be Scala 2.
*
* The tests are run with the bootstrapped compiler and the tasty inpector on the classpath.
* The classpath has the default `scala-library` and not `stdlib-bootstrapped`.
Expand All @@ -1088,11 +1102,23 @@ object Build {
*/
lazy val `stdlib-bootstrapped-tasty-tests` = project.in(file("stdlib-bootstrapped-tasty-tests")).
withCommonSettings(Bootstrapped).
dependsOn(dottyCompiler(Bootstrapped) % "compile->compile").
dependsOn(`scala3-tasty-inspector` % "test->test").
dependsOn(`stdlib-bootstrapped-tasty`).
settings(commonBootstrappedSettings).
settings(
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
javaOptions += "-Ddotty.scala.library=" + (`stdlib-bootstrapped` / Compile / packageBin).value.getAbsolutePath
Test / javaOptions += "-Ddotty.scala.library=" + (`stdlib-bootstrapped` / Compile / packageBin).value.getAbsolutePath,
Compile / compile / fullClasspath ~= {
_.filterNot(file => file.data.getName == s"scala-library-${stdlibVersion(Bootstrapped)}.jar")
},
Compile / compile / dependencyClasspath := {
// make sure that the scala2-library (tasty of `stdlib-bootstrapped-tasty`) is listed before the scala-library (classfiles)
val (bootstrappedLib, otherLibs) =
(Compile / compile / dependencyClasspath).value
.partition(_.data.getName == s"scala2-library-${dottyVersion}.jar")
bootstrappedLib ++ otherLibs
},
)

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