Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
build libraries from source
  • Loading branch information
lihaoyi committed Sep 1, 2025
commit 1be063a836f652ec7f87eb15f82b49d0ef98bacc
45 changes: 33 additions & 12 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -727,19 +727,40 @@ object Build {
"https://repo1.maven.org/maven2/com/lihaoyi/fansi_3/0.5.1/fansi_3-0.5.1-sources.jar",
"https://repo1.maven.org/maven2/com/lihaoyi/sourcecode_3/0.4.3-M5/sourcecode_3-0.4.3-M5-sources.jar",
)
val sourceManagedPath = os.Path((Compile / sourceManaged).value)
for(download <- downloads) os.unzip.stream(requests.get.stream(download), dest = sourceManagedPath)
for(file <- os.walk(sourceManagedPath) if file.ext == "scala") yield{
val sourceManagedPath = os.Path((Compile / sourceManaged).value / "downloaded")
os.remove.all(sourceManagedPath)
os.makeDir.all(sourceManagedPath)
for(download <- downloads) {
os.unzip.stream(requests.get.stream(download), dest = sourceManagedPath)
}
for {
file <- os.walk(sourceManagedPath)
if file.ext == "scala"
if file.last != "CollectionName.scala"
} yield {
val text = os.read(file)
if (!text.contains("package scala")){
os.write.over(
file,
"package dotty.shaded\n" +
text
.replace("_root_.pprint", "_root_.dotty.shaded.pprint")
.replace("_root_.fansi", "_root_.dotty.shaded.fansi")
)
}
os.write.over(
file,
"package dotty.shaded\n" +
text
.replace("import scala", "import _root_.scala")
.replace(" scala.collection.", " _root_.scala.collection.")
.replace("_root_.pprint", "_root_.dotty.shaded.pprint")
.replace("_root_.fansi", "_root_.dotty.shaded.fansi")
.replace("def apply(c: Char): Trie[T]", "def apply(c: Char): Trie[T] | Null")
.replace("var head: Iterator[T] = null", "var head: Iterator[T] | Null = null")
.replace("if (head != null && head.hasNext) true", "if (head != null && head.nn.hasNext) true")
.replace("head.next()", "head.nn.next()")
.replace(
"_root_.scala.collection.internal.pprint.CollectionName.get(i)",
"import scala.reflect.Selectable.reflectiveSelectable\n" +
" i.asInstanceOf[{def collectionClassName: String}].collectionClassName"
)
.replace("abstract class Walker", "@scala.annotation.nowarn abstract class Walker")
.replace("object TPrintLowPri", "@scala.annotation.nowarn object TPrintLowPri")
// .replace("_root_.scala.collection.internal.pprint.CollectionName.get(i)", "head.nn.next()")
// .replace("_root_.scala.collection.internal.pprint.CollectionName.get(i)", "head.nn.next()")
)
file.toIO
}
}.taskValue,
Expand Down
Loading