Skip to content

Commit 6f6b3dc

Browse files
committed
WIP Package stdlib compiled with Scala 2 + TASTy
1 parent 2489d73 commit 6f6b3dc

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

project/Build.scala

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,46 @@ object Build {
939939
},
940940
mimaCheckDirection := "both",
941941
mimaBinaryIssueFilters ++= MiMaFilters.LibraryBootstrappedForward,
942+
libraryDependencies += // For jar packaging
943+
("org.scala-lang" % "scala-library" % stdlibVersion(Bootstrapped)),
944+
exportJars := true,
945+
Compile / packageBin / artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
946+
artifact.name + "-" + stdlibVersion(Bootstrapped) + "-" + module.revision + "." + artifact.extension
947+
},
948+
Compile / packageBin / mappings := {
949+
val s = streams.value
950+
val report = updateClassifiers.value
951+
val scalaLibraryJar =
952+
// FIXME
953+
report.select(
954+
configuration = configurationFilter("sourcedeps"),
955+
module = (_: ModuleID).name == "scala-library",
956+
artifact = artifactFilter(`type` = "src")).headOption.getOrElse {
957+
sys.error(s"Could not fetch scala-library sources")
958+
}.getParentFile / "scala-library-2.13.10.jar"
959+
val cacheDir = s.cacheDirectory
960+
val trgDir = (Compile / sourceManaged).value / "scala-library-bin"
961+
FileFunction.cached(cacheDir / "fetchScalaLibraryBin",
962+
FilesInfo.lastModified, FilesInfo.exists) { dependencies =>
963+
s.log.info(s"Unpacking scala-library classfiles to $trgDir...")
964+
if (trgDir.exists)
965+
IO.delete(trgDir)
966+
IO.createDirectory(trgDir)
967+
IO.unzip(scalaLibraryJar, trgDir)
968+
969+
(trgDir ** "*.class").get.toSet
970+
} (Set(scalaLibraryJar)).toSeq
971+
val allScalaLibraryJarFiles =
972+
trgDir.allPaths.get().filterNot(_.getName.endsWith(".MF")) // TODO use parts of the old manifest?
973+
val allScalaLibraryJarMappings: Seq[(java.io.File, String)] =
974+
allScalaLibraryJarFiles.zip(allScalaLibraryJarFiles.map(_.relativeTo(trgDir).get.getPath))
975+
976+
val tastyFileMappings: Seq[(java.io.File, String)] =
977+
(Compile / packageBin / mappings).value.filter(_._1.getName.endsWith(".tasty"))
978+
979+
allScalaLibraryJarMappings ++ tastyFileMappings
980+
}
981+
942982
)
943983

944984
/** Scala library compiled by dotty using the latest published sources of the library

0 commit comments

Comments
 (0)