Skip to content

Commit

Permalink
Rename stdlib-bootstrapped-tasty to scala2-library-tasty (#18615)
Browse files Browse the repository at this point in the history
Align with the `scala-library` and `dotty-library` nomenclature. Note
that the name of the project/jar is already `scala2-library`.

* `stdlib-bootstrapped` -> `scala2-library-bootstrapped`
* `stdlib-bootstrapped-tasty` -> `scala2-library-tasty`
* `stdlib-bootstrapped-tasty-tests` -> `scala2-library-tasty-tests`

Based on #18613
  • Loading branch information
odersky committed Oct 3, 2023
2 parents ebb3a11 + f104cb9 commit 48bb59c
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 39 deletions.
8 changes: 4 additions & 4 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-tasty-tests/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/* ;scala2-library-tasty-tests/run ;scala2-library-tasty-tests/test; scala3-compiler-bootstrapped/scala3CompilerCoursierTest:test"
./project/scripts/cmdTests
./project/scripts/bootstrappedOnlyCmdTests
Expand Down Expand Up @@ -253,12 +253,12 @@ jobs:

- name: MiMa
run: |
./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues; tasty-core-bootstrapped/mimaReportBinaryIssues; stdlib-bootstrapped/mimaReportBinaryIssues"
./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues; tasty-core-bootstrapped/mimaReportBinaryIssues; scala2-library-bootstrapped/mimaReportBinaryIssues"
- name: TASTy MiMa
run: |
# This script cleans the compiler and recompiles it from scratch (keep as last run)
./project/scripts/stdlib-bootstrapped-tasty-mima.sh
./project/scripts/scala2-library-tasty-mima.sh
community_build_a:
runs-on: [self-hosted, Linux]
Expand Down Expand Up @@ -493,7 +493,7 @@ jobs:

- name: Test
run: |
./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/sbt ";dist/pack ;scala3-bootstrapped/compile ;scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;scala2-library-tasty-tests/run ;scala2-library-tasty-tests/test"
./project/scripts/cmdTests
./project/scripts/bootstrappedOnlyCmdTests
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ val `scala3-language-server` = Build.`scala3-language-server`
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 `scala2-library-bootstrapped` = Build.`scala2-library-bootstrapped`
val `scala2-library-tasty` = Build.`scala2-library-tasty`
val `scala2-library-tasty-tests` = Build.`scala2-library-tasty-tests`
val `tasty-core` = Build.`tasty-core`
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`
val `tasty-core-scala2` = Build.`tasty-core-scala2`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ class DependencyRecorder {
* we should have called `cb.generatedNonLocalClass` with the same class file name.
*
* FIXME: we still need a way to resolve the correct classfile when we split tasty and classes between
* different outputs (e.g. stdlib-bootstrapped).
* different outputs (e.g. scala2-library-bootstrapped).
*/
def cachedSiblingClass(pf: PlainFile): Path =
siblingClassfiles.getOrElseUpdate(pf, {
Expand Down
60 changes: 35 additions & 25 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ object Build {
Keys.scalaSource, Keys.javaSource
),

// This is used to download nightly builds of the Scala 2 library in `stdlib-bootstrapped`
// This is used to download nightly builds of the Scala 2 library in `scala2-library-bootstrapped`
resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/",
)

Expand Down Expand Up @@ -723,22 +723,31 @@ object Build {
val externalDeps = externalCompilerClasspathTask.value
val jars = packageAll.value
val scalaLib = findArtifactPath(externalDeps, "scala-library")
val scalaLibTastyOpt = jars.get("scala2-library-tasty")
val dottyLib = jars("scala3-library")
val dottyCompiler = jars("scala3-compiler")
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
val decompile = args0.contains("-decompile")
val printTasty = args0.contains("-print-tasty")
val useScala2LibraryTasty = args0.contains("-Yscala2-library-tasty")
val debugFromTasty = args0.contains("-Ythrough-tasty")
val args = args0.filter(arg => arg != "-repl" && arg != "-decompile" &&
arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty")

arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty"
&& arg != "-Yscala2-library-tasty")
val main =
if (decompile) "dotty.tools.dotc.decompiler.Main"
else if (printTasty) "dotty.tools.dotc.core.tasty.TastyPrinter"
else if (debugFromTasty) "dotty.tools.dotc.fromtasty.Debug"
else "dotty.tools.dotc.Main"

var extraClasspath = Seq(scalaLib, dottyLib)
var extraClasspath =
scalaLibTastyOpt match {
case Some(scalaLibTasty) if useScala2LibraryTasty =>
Seq(scalaLibTasty, scalaLib, dottyLib)
case _ =>
if (useScala2LibraryTasty) log.error("-Yscala2-library-tasty can only be used with a bootstrapped compiler")
Seq(scalaLib, dottyLib)
}

if (decompile && !args.contains("-classpath"))
extraClasspath ++= Seq(".")
Expand Down Expand Up @@ -848,6 +857,7 @@ object Build {
"scala3-staging" -> (LocalProject("scala3-staging") / Compile / packageBin).value.getAbsolutePath,
"scala3-tasty-inspector" -> (LocalProject("scala3-tasty-inspector") / Compile / packageBin).value.getAbsolutePath,
"tasty-core" -> (LocalProject("tasty-core-bootstrapped") / Compile / packageBin).value.getAbsolutePath,
"scala2-library-tasty" -> (LocalProject("scala2-library-tasty") / Compile / packageBin).value.getAbsolutePath,
)
},

Expand Down Expand Up @@ -972,7 +982,7 @@ object Build {
*
* This version of the library is not (yet) TASTy/binary compatible with the Scala 2 compiled library.
*/
lazy val `stdlib-bootstrapped` = project.in(file("stdlib-bootstrapped")).
lazy val `scala2-library-bootstrapped` = project.in(file("scala2-library-bootstrapped")).
withCommonSettings(Bootstrapped).
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
settings(commonBootstrappedSettings).
Expand Down Expand Up @@ -1061,7 +1071,7 @@ object Build {
| - final val MinorVersion = $minorVersion
| - final val ExperimentalVersion = 0
| * Clean everiting to generate a compiler with those new TASTy vesrions
| * Run stdlib-bootstrapped/tastyMiMaReportIssues
| * Run scala2-library-bootstrapped/tastyMiMaReportIssues
|""".stripMargin)

}).value,
Expand Down Expand Up @@ -1105,56 +1115,56 @@ object Build {
println(
s"""Usage:
|> $projectName/run list
| -- lists all files that are not overriden in stdlib-bootstrapped/src
| -- lists all files that are not overriden in scala2-library-bootstrapped/src
|
|> $projectName/run clone <sources>*
| -- clones the specified sources from the stdlib-bootstrapped/src
| -- clones the specified sources from the scala2-library-bootstrapped/src
| -- example: $projectName/run clone scala/Option.scala
|
|> $projectName/run overwrite <sources>*
| -- (danger) overwrites the specified sources from the stdlib-bootstrapped/src
| -- (danger) overwrites the specified sources from the scala2-library-bootstrapped/src
|""".stripMargin)
}
}
)

/** Packages the TASTy files of `stdlib-bootstrapped` in a jar */
lazy val `stdlib-bootstrapped-tasty` = project.in(file("stdlib-bootstrapped-tasty")).
/** Packages the TASTy files of `scala2-library-bootstrapped` in a jar */
lazy val `scala2-library-tasty` = project.in(file("scala2-library-tasty")).
withCommonSettings(Bootstrapped).
settings(
exportJars := true,
Compile / packageBin / mappings := {
(`stdlib-bootstrapped` / Compile / packageBin / mappings).value
(`scala2-library-bootstrapped` / Compile / packageBin / mappings).value
.filter(_._2.endsWith(".tasty"))
},
)

/** Test the tasty generated by `stdlib-bootstrapped`
/** Test the tasty generated by `scala2-library-bootstrapped`
*
* The sources in src are compiled using TASTy from stdlib-bootstrapped-tasty but then run
* The sources in src are compiled using TASTy from scala2-library-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`.
* The classpath has the default `scala-library` and not `scala2-library-bootstrapped`.
*
* The jar of `stdlib-bootstrapped` is provided for to the tests.
* The jar of `scala2-library-bootstrapped` is provided for to the tests.
* - inspector: test that we can load the contents of the jar using the tasty inspector
* - from-tasty: test that we can recompile the contents of the jar using `dotc -from-tasty`
*/
lazy val `stdlib-bootstrapped-tasty-tests` = project.in(file("stdlib-bootstrapped-tasty-tests")).
lazy val `scala2-library-tasty-tests` = project.in(file("scala2-library-tasty-tests")).
withCommonSettings(Bootstrapped).
dependsOn(dottyCompiler(Bootstrapped) % "compile->compile").
dependsOn(`scala3-tasty-inspector` % "test->test").
dependsOn(`stdlib-bootstrapped-tasty`).
dependsOn(`scala2-library-tasty`).
settings(commonBootstrappedSettings).
settings(
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
Test / javaOptions += "-Ddotty.scala.library=" + (`stdlib-bootstrapped` / Compile / packageBin).value.getAbsolutePath,
Test / javaOptions += "-Ddotty.scala.library=" + (`scala2-library-bootstrapped` / Compile / packageBin).value.getAbsolutePath,
Compile / compile / fullClasspath ~= {
_.filterNot(file => file.data.getName == s"scala-library-$stdlibBootstrappedVersion.jar")
},
Compile / compile / dependencyClasspath := {
// make sure that the scala2-library (tasty of `stdlib-bootstrapped-tasty`) is listed before the scala-library (classfiles)
// make sure that the scala2-library (tasty of `scala2-library-tasty`) is listed before the scala-library (classfiles)
val (bootstrappedLib, otherLibs) =
(Compile / compile / dependencyClasspath).value
.partition(_.data.getName == s"scala2-library-${dottyVersion}.jar")
Expand Down Expand Up @@ -2106,7 +2116,7 @@ object ScaladocConfigs {

def defaultSourceLinks(version: String = dottyNonBootstrappedVersion, refVersion: String = dottyVersion) = Def.task {
def stdLibVersion = stdlibVersion(NonBootstrapped)
def srcManaged(v: String, s: String) = s"out/bootstrap/stdlib-bootstrapped/scala-$v/src_managed/main/$s-library-src"
def srcManaged(v: String, s: String) = s"out/bootstrap/scala2-library-bootstrapped/scala-$v/src_managed/main/$s-library-src"
SourceLinks(
List(
scalaSrcLink(stdLibVersion, srcManaged(version, "scala") + "="),
Expand Down Expand Up @@ -2194,7 +2204,7 @@ object ScaladocConfigs {

lazy val Scala3 = Def.task {
val dottyJars: Seq[java.io.File] = Seq(
(`stdlib-bootstrapped`/Compile/products).value,
(`scala2-library-bootstrapped`/Compile/products).value,
(`scala3-library-bootstrapped`/Compile/products).value,
(`scala3-interfaces`/Compile/products).value,
(`tasty-core-bootstrapped`/Compile/products).value,
Expand All @@ -2203,7 +2213,7 @@ object ScaladocConfigs {
val roots = dottyJars.map(_.getAbsolutePath)

val managedSources =
(`stdlib-bootstrapped`/Compile/sourceManaged).value / "scala-library-src"
(`scala2-library-bootstrapped`/Compile/sourceManaged).value / "scala-library-src"
val projectRoot = (ThisBuild/baseDirectory).value.toPath
val stdLibRoot = projectRoot.relativize(managedSources.toPath.normalize())
val docRootFile = stdLibRoot.resolve("rootdoc.txt")
Expand Down Expand Up @@ -2236,7 +2246,7 @@ object ScaladocConfigs {
}

def stableScala3(version: String) = Def.task {
val scalaLibrarySrc = s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed"
val scalaLibrarySrc = s"out/bootstrap/scala2-library-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/src_managed"
val dottyLibrarySrc = "library/src"
Scala3.value
.add(defaultSourceLinks(version + "-bin-SNAPSHOT-nonbootstrapped", version).value)
Expand All @@ -2255,7 +2265,7 @@ object ScaladocConfigs {
.add(DocRootContent(s"$scalaLibrarySrc/rootdoc.txt"))
.withTargets(
Seq(
s"out/bootstrap/stdlib-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/classes",
s"out/bootstrap/scala2-library-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/classes",
s"out/bootstrap/scala3-library-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/classes",
s"tmp/interfaces/target/classes",
s"out/bootstrap/tasty-core-bootstrapped/scala-$version-bin-SNAPSHOT-nonbootstrapped/classes"
Expand Down
4 changes: 2 additions & 2 deletions project/TastyMiMaFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ object TastyMiMaFilters {

// Probably OK: ConstantType for `null` versus `scala.Null`
// Calls to the default getter seem to link correctly.
// Tested in stdlib-bootstrapped/test/scala/collection/UnrolledBufferTest.scala
// Tested in scala2-library-bootstrapped/test/scala/collection/UnrolledBufferTest.scala
ProblemMatcher.make(ProblemKind.IncompatibleTypeChange, "scala.collection.mutable.UnrolledBuffer.Unrolled.<init>$default$4"),

// Probably OK: Overriding java method (`public abstract Object underlying();` with `def underlying: Object`)
// Calls to the underlying seem to link correctly.
// Tested in stdlib-bootstrapped/test/Main.scala
// Tested in scala2-library-bootstrapped/test/Main.scala
ProblemMatcher.make(ProblemKind.MissingTermMember, "scala.math.Big*.underlying"),
ProblemMatcher.make(ProblemKind.NewAbstractMember, "scala.math.ScalaNumericConversions.underlying"),

Expand Down
4 changes: 2 additions & 2 deletions project/scripts/cmdScaladocTests
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ SOURCE_LINKS_VERSION="${GITHUB_SHA:-$DOTTY_BOOTSTRAPPED_VERSION}"
dist/target/pack/bin/scaladoc \
-d "$OUT1" \
-project "scaladoc testcases" \
-source-links:out/bootstrap/stdlib-bootstrapped/scala-"${DOTTY_NONBOOTSTRAPPED_VERSION}"/src_managed/main/scala-library-src=github://scala/scala/v"${STDLIB_VERSION}"#src/library \
-source-links:out/bootstrap/stdlib-bootstrapped/scala-"${DOTTY_NONBOOTSTRAPPED_VERSION}"/src_managed/main/dotty-library-src=github://"${SOURCE_LINKS_REPOSITORY}"/"${SOURCE_LINKS_VERSION}"\#library/src \
-source-links:out/bootstrap/scala2-library-bootstrapped/scala-"${DOTTY_NONBOOTSTRAPPED_VERSION}"/src_managed/main/scala-library-src=github://scala/scala/v"${STDLIB_VERSION}"#src/library \
-source-links:out/bootstrap/scala2-library-bootstrapped/scala-"${DOTTY_NONBOOTSTRAPPED_VERSION}"/src_managed/main/dotty-library-src=github://"${SOURCE_LINKS_REPOSITORY}"/"${SOURCE_LINKS_VERSION}"\#library/src \
-source-links:github://"${SOURCE_LINKS_REPOSITORY}"/"${SOURCE_LINKS_VERSION}" \
"-external-mappings:.*scala/.*::scaladoc3::https://dotty.epfl.ch/api/,.*java/.*::javadoc::https://docs.oracle.com/javase/8/docs/api/" \
"-skip-by-regex:.+\.internal($|\..+)" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ setTastyVersion() {

setTastyVersion $MINOR_TASTY_VERSION_SUPPORTED_BY_TASTY_MIMA 0

# Run stdlib-bootstrapped/tastyMiMaReportIssues using a custom TASTy version.
# Run scala2-library-bootstrapped/tastyMiMaReportIssues using a custom TASTy version.
# We clean before to make sure all sources are recompiled using the new TASTY version.
# We clean after to make sure no other test will use the TASTy generated with this version.
"$SBT" "clean; stdlib-bootstrapped/clean; reload; stdlib-bootstrapped/tastyMiMaReportIssues; clean; stdlib-bootstrapped/clean"
"$SBT" "clean; scala2-library-bootstrapped/clean; reload; scala2-library-bootstrapped/tastyMiMaReportIssues; clean; scala2-library-bootstrapped/clean"

setTastyVersion $MINOR_TASTY_VERSION $EXPERIMENTAL_TASTY_VERSION
File renamed without changes.

0 comments on commit 48bb59c

Please sign in to comment.