@@ -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 (
@@ -758,14 +776,24 @@ object Build {
758
776
else if (debugFromTasty) " dotty.tools.dotc.fromtasty.Debug"
759
777
else " dotty.tools.dotc.Main"
760
778
761
- var extraClasspath =
762
- scalaLibTastyOpt match {
763
- case Some (scalaLibTasty) if useScala2LibraryTasty.value =>
764
- Seq (scalaLibTasty, scalaLib, dottyLib)
765
- case _ =>
766
- if (useScala2LibraryTasty.value) log.warn(" useScala2LibraryTasty is ignored on non-bootstrapped compiler" )
767
- Seq (scalaLib, dottyLib)
768
- }
779
+ val scala2LibraryTasty = scala2Library.value match {
780
+ case Scala2LibraryJar => Seq .empty
781
+ case Scala2LibraryTasty =>
782
+ jars.get(" scala2-library-tasty" ) match {
783
+ case Some (jar) => Seq (jar)
784
+ case None =>
785
+ log.warn(" Scala2LibraryTasty is ignored on non-bootstrapped compiler" )
786
+ Seq .empty
787
+ }
788
+ case Scala2LibraryCCTasty =>
789
+ jars.get(" scala2-library-cc-tasty" ) match {
790
+ case Some (jar) => Seq (jar)
791
+ case None =>
792
+ log.warn(" Scala2LibraryCCTasty is ignored on non-bootstrapped compiler" )
793
+ Seq .empty
794
+ }
795
+ }
796
+ var extraClasspath = scala2LibraryTasty ++ Seq (scalaLib, dottyLib)
769
797
770
798
if (decompile && ! args.contains(" -classpath" ))
771
799
extraClasspath ++= Seq (" ." )
@@ -876,6 +904,7 @@ object Build {
876
904
" scala3-tasty-inspector" -> (LocalProject (" scala3-tasty-inspector" ) / Compile / packageBin).value.getAbsolutePath,
877
905
" tasty-core" -> (LocalProject (" tasty-core-bootstrapped" ) / Compile / packageBin).value.getAbsolutePath,
878
906
" scala2-library-tasty" -> (LocalProject (" scala2-library-tasty" ) / Compile / packageBin).value.getAbsolutePath,
907
+ " scala2-library-cc-tasty" -> (LocalProject (" scala2-library-cc-tasty" ) / Compile / packageBin).value.getAbsolutePath,
879
908
)
880
909
},
881
910
@@ -1004,8 +1033,24 @@ object Build {
1004
1033
withCommonSettings(Bootstrapped ).
1005
1034
dependsOn(dottyCompiler(Bootstrapped ) % " provided; compile->runtime; test->test" ).
1006
1035
settings(commonBootstrappedSettings).
1036
+ settings(scala2LibraryBootstrappedSettings).
1037
+ settings(moduleName := " scala2-library" )
1038
+
1039
+ /** Scala 2 library compiled by dotty using the latest published sources of the library.
1040
+ *
1041
+ * This version of the library is not (yet) TASTy/binary compatible with the Scala 2 compiled library.
1042
+ */
1043
+ lazy val `scala2-library-cc` = project.in(file(" scala2-library-cc" )).
1044
+ withCommonSettings(Bootstrapped ).
1045
+ dependsOn(dottyCompiler(Bootstrapped ) % " provided; compile->runtime; test->test" ).
1046
+ settings(commonBootstrappedSettings).
1047
+ settings(scala2LibraryBootstrappedSettings).
1007
1048
settings(
1008
- moduleName := " scala2-library" ,
1049
+ moduleName := " scala2-library-cc" ,
1050
+ scalacOptions += " -Ycheck:all" ,
1051
+ )
1052
+
1053
+ lazy val scala2LibraryBootstrappedSettings = Seq (
1009
1054
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
1010
1055
Compile / scalacOptions ++= {
1011
1056
Seq (" -sourcepath" , ((Compile / sourceManaged).value / " scala-library-src" ).toString)
@@ -1089,13 +1134,13 @@ object Build {
1089
1134
| - final val MinorVersion = $minorVersion
1090
1135
| - final val ExperimentalVersion = 0
1091
1136
| * Clean everything to generate a compiler with those new TASTy versions
1092
- | * Run scala2-library-bootstrapped /tastyMiMaReportIssues
1137
+ | * Run ${name.value} /tastyMiMaReportIssues
1093
1138
| """ .stripMargin)
1094
1139
1095
1140
}).value,
1096
1141
Compile / exportJars := true ,
1097
1142
artifactName := { (sv : ScalaVersion , module : ModuleID , artifact : Artifact ) =>
1098
- " scala2-library -" + dottyVersion + " ." + artifact.extension
1143
+ moduleName.value + " -" + dottyVersion + " ." + artifact.extension
1099
1144
},
1100
1145
run := {
1101
1146
val log = streams.value.log
@@ -1133,18 +1178,18 @@ object Build {
1133
1178
println(
1134
1179
s """ Usage:
1135
1180
|> $projectName/run list
1136
- | -- lists all files that are not overriden in scala2-library-bootstrapped /src
1181
+ | -- lists all files that are not overriden in ${name.value} /src
1137
1182
|
1138
1183
|> $projectName/run clone <sources>*
1139
- | -- clones the specified sources from the scala2-library-bootstrapped /src
1184
+ | -- clones the specified sources from the ${name.value} /src
1140
1185
| -- example: $projectName/run clone scala/Option.scala
1141
1186
|
1142
1187
|> $projectName/run overwrite <sources>*
1143
- | -- (danger) overwrites the specified sources from the scala2-library-bootstrapped /src
1188
+ | -- (danger) overwrites the specified sources from the ${name.value} /src
1144
1189
| """ .stripMargin)
1145
1190
}
1146
1191
}
1147
- )
1192
+ )
1148
1193
1149
1194
/** Packages the TASTy files of `scala2-library-bootstrapped` in a jar */
1150
1195
lazy val `scala2-library-tasty` = project.in(file(" scala2-library-tasty" )).
@@ -1157,6 +1202,17 @@ object Build {
1157
1202
},
1158
1203
)
1159
1204
1205
+ /** Packages the TASTy files of `scala2-library-cc` in a jar */
1206
+ lazy val `scala2-library-cc-tasty` = project.in(file(" scala2-library-cc-tasty" )).
1207
+ withCommonSettings(Bootstrapped ).
1208
+ settings(
1209
+ exportJars := true ,
1210
+ Compile / packageBin / mappings := {
1211
+ (`scala2-library-cc` / Compile / packageBin / mappings).value
1212
+ .filter(_._2.endsWith(" .tasty" ))
1213
+ },
1214
+ )
1215
+
1160
1216
/** Test the tasty generated by `scala2-library-bootstrapped`
1161
1217
*
1162
1218
* The sources in src are compiled using TASTy from scala2-library-tasty but then run
0 commit comments