@@ -1044,6 +1044,66 @@ object Build {
1044
1044
},
1045
1045
)
1046
1046
1047
+ /** Creates a copy of the Scala 2.13 library JAR with TASTy from `stdlib-2_13-bootstrapped` */
1048
+ lazy val `stdlib-2_13-tasty-bundle` = project.in(file(" stdlib-2_13-tasty-bundle" )).
1049
+ withCommonSettings(Bootstrapped ).
1050
+ dependsOn(`stdlib-2_13-bootstrapped`).
1051
+ settings(commonBootstrappedSettings).
1052
+ settings(
1053
+ moduleName := " scala-library" ,
1054
+ exportJars := true ,
1055
+ Compile / compile := {
1056
+ val classDir = (Compile / classDirectory).value
1057
+
1058
+ // Copy contents of Scala 2.13 JAR into classDir
1059
+ val s = streams.value
1060
+ val report = updateClassifiers.value
1061
+ val scalaLibraryJar =
1062
+ // FIXME could not find it with report.select. Other options?
1063
+ report.select(
1064
+ configuration = configurationFilter(" compile" ),
1065
+ module = (_ : ModuleID ).name == " scala-library" ,
1066
+ artifact = artifactFilter(`type` = " src" ))
1067
+ .headOption.getOrElse {
1068
+ sys.error(s " Could not fetch scala-library sources " )
1069
+ }.getParentFile / s " scala-library- ${stdlibVersion(Bootstrapped )}.jar "
1070
+ val cacheDir = s.cacheDirectory
1071
+ FileFunction .cached(cacheDir / " fetchScalaLibraryBin" ,
1072
+ FilesInfo .lastModified, FilesInfo .exists) { dependencies =>
1073
+ s.log.info(s " Unpacking scala-library classfiles to $classDir" )
1074
+ if (classDir.exists)
1075
+ IO .delete(classDir)
1076
+ IO .createDirectory(classDir)
1077
+ IO .unzip(scalaLibraryJar, classDir)
1078
+ (classDir ** " *" ).get.toSet
1079
+ } (Set (scalaLibraryJar)).toSeq
1080
+ IO .delete(classDir / " META-INF" )
1081
+ // TODO What to do with library.properties, LICENSE, NOTICE, rootdoc.txt? Keep? Modify?
1082
+
1083
+ // Copy .tasty files from stdlib-2_13-bootstrapped into classDir
1084
+ val tastySrcDir = (`stdlib-2_13-bootstrapped` / Compile / classDirectory).value
1085
+ s.log.info(s " Copying .tasty files from $tastySrcDir to $classDir" )
1086
+ for (tastyFile <- tastySrcDir.allPaths.get()) {
1087
+ if (tastyFile.getName.endsWith(" .tasty" )) {
1088
+ val tastyFileDest = tastyFile.relativeTo(tastySrcDir).get
1089
+ val destFile = classDir / tastyFileDest.toString()
1090
+ IO .copyFile(tastyFile, destFile)
1091
+ }
1092
+ }
1093
+
1094
+ (Compile / compile).value
1095
+ },
1096
+ Compile / packageBin / artifactName := { (sv : ScalaVersion , module : ModuleID , artifact : Artifact ) =>
1097
+ artifact.name + " -" + stdlibVersion(Bootstrapped ) + " -" + module.revision + " ." + artifact.extension
1098
+ },
1099
+ Compile / packageBin := {
1100
+ val version = stdlibVersion(Bootstrapped )
1101
+ val path = (Compile / packageBin / artifactPath).value
1102
+ streams.value.log.info(s " Repackaging Scala $version library with .tasty files into $path" )
1103
+ (Compile / packageBin).value
1104
+ }
1105
+ )
1106
+
1047
1107
/** Test the tasty generated by `stdlib-bootstrapped`
1048
1108
*
1049
1109
* The tests are run with the bootstrapped compiler and the tasty inpector on the classpath.
0 commit comments