@@ -931,11 +931,11 @@ object Build {
931
931
settings(
932
932
moduleName := " scala-library" ,
933
933
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
934
- Compile / scalacOptions += " -Yerased-terms" ,
935
934
Compile / scalacOptions ++= {
936
935
Seq (
937
936
" -sourcepath" ,
938
937
Seq (
938
+ baseDirectory.value / " stdlib-bootstrapped" / " src" ,
939
939
(Compile / sourceManaged).value / " scala-library-src" ,
940
940
(Compile / sourceManaged).value / " dotty-library-src" ,
941
941
).mkString(File .pathSeparator),
@@ -1009,9 +1009,59 @@ object Build {
1009
1009
file.getPath.endsWith(" scala-library-src/scala/Nothing.scala" ) ||
1010
1010
file.getPath.endsWith(" scala-library-src/scala/Null.scala" ) ||
1011
1011
file.getPath.endsWith(" scala-library-src/scala/Singleton.scala" ))),
1012
+ (Compile / sources) ~= (files =>
1013
+ {
1014
+ val overwritenSources = files.collect {
1015
+ case file if file.getPath.contains(" stdlib-bootstrapped/src" ) => file.getPath.split(" stdlib-bootstrapped/src/" )(1 )
1016
+ }.toSet
1017
+ files.filterNot(file =>
1018
+ file.getPath.contains(" scala-library-src/" ) && overwritenSources(file.getPath.split(" scala-library-src/" )(1 )))
1019
+ }
1020
+ ),
1012
1021
(Test / managedClasspath) ~= {
1013
1022
_.filterNot(file => file.data.getName == s " scala-library- ${stdlibVersion(Bootstrapped )}.jar " )
1014
1023
},
1024
+ run := {
1025
+ val args : Seq [String ] = spaceDelimited(" <arg>" ).parsed
1026
+ val reference = (Compile / sourceManaged).value / " scala-library-src"
1027
+ args match {
1028
+ case Seq (" list" ) =>
1029
+ println(s " List of non-overriden files in $reference" )
1030
+ reference.allPaths.get()
1031
+ .flatMap(_.relativeTo(reference))
1032
+ .filter(_.ext == " scala" )
1033
+ .sorted
1034
+ .foreach(println)
1035
+ case Seq (cmd @ (" clone" | " overwrite" ), files* ) =>
1036
+ println(" Cloning scala-library sources: " + files.mkString(" , " ))
1037
+ for (file <- files) {
1038
+ val referenceStdlibPaths = reference / file
1039
+ val destination = baseDirectory.value / " src" / file
1040
+ if (! referenceStdlibPaths.exists) {
1041
+ println(" Not found " + referenceStdlibPaths)
1042
+ } else if (destination.exists && cmd == " clone" ) {
1043
+ println(s " Already exists $file. (use `overwrite` command to overwrite) " )
1044
+ } else {
1045
+ val action = if (cmd == " clone" ) " Cloning" else " Overwriting"
1046
+ println(s " $action $file" )
1047
+ IO .copyFile(referenceStdlibPaths, destination)
1048
+ }
1049
+ }
1050
+ case _ =>
1051
+ println(
1052
+ """ Usage:
1053
+ |> stdlib-bootstrapped/run list
1054
+ | -- lists all files that are not overriden in stdlib-bootstrapped/src
1055
+ |
1056
+ |> stdlib-bootstrapped/run clone <sources>*
1057
+ | -- clones the specified sources from the stdlib-bootstrapped/src
1058
+ | -- example: stdlib-bootstrapped/run clone scala/Option.scala
1059
+ |
1060
+ |> stdlib-bootstrapped/run overwrite <sources>*
1061
+ | -- (danger) overwrites the specified sources from the stdlib-bootstrapped/src
1062
+ |""" .stripMargin)
1063
+ }
1064
+ }
1015
1065
)
1016
1066
1017
1067
/** Test the tasty generated by `stdlib-bootstrapped`
0 commit comments