@@ -173,11 +173,23 @@ object Build {
173
173
// Run tests with filter through vulpix test suite
174
174
val testCompilation = inputKey[Unit ](" runs integration test with the supplied filter" )
175
175
176
+ sealed trait Scala2Library
177
+ // Use Scala 2 compiled library JAR
178
+ object Scala2LibraryJar extends Scala2Library
176
179
// Use the TASTy jar from `scala2-library-tasty` in the classpath
177
180
// This only works with `scala3-bootstrapped/scalac` and tests in `scala3-bootstrapped`
178
181
//
179
- // Enable in SBT with: `set ThisBuild/Build.useScala2LibraryTasty := true`
180
- val useScala2LibraryTasty = settingKey[Boolean ](" Use the TASTy jar from `scala2-library-tasty` in the classpath" )
182
+ object Scala2LibraryTasty extends Scala2Library
183
+ // Use the TASTy jar from `scala2-library-cc-tasty` in the classpath
184
+ // This only works with `scala3-bootstrapped/scalac` and tests in `scala3-bootstrapped`
185
+ //
186
+ object Scala2LibraryCCTasty extends Scala2Library
187
+
188
+ // Set in SBT with:
189
+ // - `set ThisBuild/Build.scala2Library := Build.Scala2LibraryJar` (default)
190
+ // - `set ThisBuild/Build.scala2Library := Build.Scala2LibraryTasty`
191
+ // - `set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty`
192
+ val scala2Library = settingKey[Scala2Library ](" Choose which version of the Scala 2 library should be used" )
181
193
182
194
// Used to compile files similar to ./bin/scalac script
183
195
val scalac = inputKey[Unit ](" run the compiler using the correct classpath, or the user supplied classpath" )
@@ -225,7 +237,7 @@ object Build {
225
237
226
238
outputStrategy := Some (StdoutOutput ),
227
239
228
- useScala2LibraryTasty := false ,
240
+ scala2Library := Scala2LibraryJar ,
229
241
230
242
// enable verbose exception messages for JUnit
231
243
(Test / testOptions) += Tests .Argument (TestFrameworks .JUnit , " -a" , " -v" , " -s" ),
@@ -645,12 +657,18 @@ object Build {
645
657
val externalDeps = externalCompilerClasspathTask.value
646
658
val jars = packageAll.value
647
659
648
- val scala2LibraryTasty = jars.get(" scala2-library-tasty" ) match {
649
- case Some (scala2LibraryTastyJar) if useScala2LibraryTasty.value =>
650
- Seq (" -Ddotty.tests.tasties.scalaLibrary=" + scala2LibraryTastyJar)
651
- case _ =>
652
- if (useScala2LibraryTasty.value) log.warn(" useScala2LibraryTasty is ignored on non-bootstrapped compiler" )
653
- Seq .empty
660
+ def libraryPathProperty (jarName : String ): Seq [String ] =
661
+ jars.get(jarName) match {
662
+ case Some (jar) =>
663
+ Seq (s " -Ddotty.tests.tasties.scalaLibrary= $jar" )
664
+ case None =>
665
+ log.warn(" Scala 2 library TASTy is ignored on non-bootstrapped compiler" )
666
+ Seq .empty
667
+ }
668
+ val scala2LibraryTasty = scala2Library.value match {
669
+ case Scala2LibraryJar => Seq .empty
670
+ case Scala2LibraryTasty => libraryPathProperty(" scala2-library-tasty" )
671
+ case Scala2LibraryCCTasty => libraryPathProperty(" scala2-library-cc-tasty" )
654
672
}
655
673
656
674
scala2LibraryTasty ++ Seq (
@@ -764,14 +782,24 @@ object Build {
764
782
else if (debugFromTasty) " dotty.tools.dotc.fromtasty.Debug"
765
783
else " dotty.tools.dotc.Main"
766
784
767
- var extraClasspath =
768
- scalaLibTastyOpt match {
769
- case Some (scalaLibTasty) if useScala2LibraryTasty.value =>
770
- Seq (scalaLibTasty, scalaLib, dottyLib)
771
- case _ =>
772
- if (useScala2LibraryTasty.value) log.warn(" useScala2LibraryTasty is ignored on non-bootstrapped compiler" )
773
- Seq (scalaLib, dottyLib)
774
- }
785
+ val scala2LibraryTasty = scala2Library.value match {
786
+ case Scala2LibraryJar => Seq .empty
787
+ case Scala2LibraryTasty =>
788
+ jars.get(" scala2-library-tasty" ) match {
789
+ case Some (jar) => Seq (jar)
790
+ case None =>
791
+ log.warn(" Scala2LibraryTasty is ignored on non-bootstrapped compiler" )
792
+ Seq .empty
793
+ }
794
+ case Scala2LibraryCCTasty =>
795
+ jars.get(" scala2-library-cc-tasty" ) match {
796
+ case Some (jar) => Seq (jar)
797
+ case None =>
798
+ log.warn(" Scala2LibraryCCTasty is ignored on non-bootstrapped compiler" )
799
+ Seq .empty
800
+ }
801
+ }
802
+ var extraClasspath = scala2LibraryTasty ++ Seq (scalaLib, dottyLib)
775
803
776
804
if (decompile && ! args.contains(" -classpath" ))
777
805
extraClasspath ++= Seq (" ." )
@@ -882,6 +910,7 @@ object Build {
882
910
" scala3-tasty-inspector" -> (LocalProject (" scala3-tasty-inspector" ) / Compile / packageBin).value.getAbsolutePath,
883
911
" tasty-core" -> (LocalProject (" tasty-core-bootstrapped" ) / Compile / packageBin).value.getAbsolutePath,
884
912
" scala2-library-tasty" -> (LocalProject (" scala2-library-tasty" ) / Compile / packageBin).value.getAbsolutePath,
913
+ " scala2-library-cc-tasty" -> (LocalProject (" scala2-library-cc-tasty" ) / Compile / packageBin).value.getAbsolutePath,
885
914
)
886
915
},
887
916
@@ -1010,8 +1039,24 @@ object Build {
1010
1039
withCommonSettings(Bootstrapped ).
1011
1040
dependsOn(dottyCompiler(Bootstrapped ) % " provided; compile->runtime; test->test" ).
1012
1041
settings(commonBootstrappedSettings).
1042
+ settings(scala2LibraryBootstrappedSettings).
1043
+ settings(moduleName := " scala2-library" )
1044
+
1045
+ /** Scala 2 library compiled by dotty using the latest published sources of the library.
1046
+ *
1047
+ * This version of the library is not (yet) TASTy/binary compatible with the Scala 2 compiled library.
1048
+ */
1049
+ lazy val `scala2-library-cc` = project.in(file(" scala2-library-cc" )).
1050
+ withCommonSettings(Bootstrapped ).
1051
+ dependsOn(dottyCompiler(Bootstrapped ) % " provided; compile->runtime; test->test" ).
1052
+ settings(commonBootstrappedSettings).
1053
+ settings(scala2LibraryBootstrappedSettings).
1013
1054
settings(
1014
- moduleName := " scala2-library" ,
1055
+ moduleName := " scala2-library-cc" ,
1056
+ scalacOptions += " -Ycheck:all" ,
1057
+ )
1058
+
1059
+ lazy val scala2LibraryBootstrappedSettings = Seq (
1015
1060
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
1016
1061
Compile / scalacOptions ++= {
1017
1062
Seq (" -sourcepath" , ((Compile / sourceManaged).value / " scala-library-src" ).toString)
@@ -1096,13 +1141,13 @@ object Build {
1096
1141
| - final val MinorVersion = $minorVersion
1097
1142
| - final val ExperimentalVersion = 0
1098
1143
| * Clean everything to generate a compiler with those new TASTy versions
1099
- | * Run scala2-library-bootstrapped /tastyMiMaReportIssues
1144
+ | * Run ${name.value} /tastyMiMaReportIssues
1100
1145
| """ .stripMargin)
1101
1146
1102
1147
}).value,
1103
1148
Compile / exportJars := true ,
1104
1149
artifactName := { (sv : ScalaVersion , module : ModuleID , artifact : Artifact ) =>
1105
- " scala2-library -" + dottyVersion + " ." + artifact.extension
1150
+ moduleName.value + " -" + dottyVersion + " ." + artifact.extension
1106
1151
},
1107
1152
run := {
1108
1153
val log = streams.value.log
@@ -1174,7 +1219,7 @@ object Build {
1174
1219
| """ .stripMargin)
1175
1220
}
1176
1221
}
1177
- )
1222
+ )
1178
1223
1179
1224
/** Packages the TASTy files of `scala2-library-bootstrapped` in a jar */
1180
1225
lazy val `scala2-library-tasty` = project.in(file(" scala2-library-tasty" )).
@@ -1187,6 +1232,17 @@ object Build {
1187
1232
},
1188
1233
)
1189
1234
1235
+ /** Packages the TASTy files of `scala2-library-cc` in a jar */
1236
+ lazy val `scala2-library-cc-tasty` = project.in(file(" scala2-library-cc-tasty" )).
1237
+ withCommonSettings(Bootstrapped ).
1238
+ settings(
1239
+ exportJars := true ,
1240
+ Compile / packageBin / mappings := {
1241
+ (`scala2-library-cc` / Compile / packageBin / mappings).value
1242
+ .filter(_._2.endsWith(" .tasty" ))
1243
+ },
1244
+ )
1245
+
1190
1246
/** Test the tasty generated by `scala2-library-bootstrapped`
1191
1247
*
1192
1248
* The sources in src are compiled using TASTy from scala2-library-tasty but then run
0 commit comments