Skip to content

Commit cf81680

Browse files
committed
build libraries from source
1 parent e143442 commit cf81680

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

compiler/src/dotty/tools/repl/Rendering.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
9595

9696
/** Return a String representation of a value we got from `classLoader()`. */
9797
private[repl] def replStringOf(sym: Symbol, value: Object)(using Context): String =
98-
pprint.PPrinter.BlackWhite.apply(value).toString
98+
dotty.shaded.pprint.PPrinter.BlackWhite.apply(value).toString
9999

100100
/** Load the value of the symbol using reflection.
101101
*

project/Build.scala

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,31 @@ object Build {
719719
"org.jline" % "jline-terminal" % "3.29.0",
720720
"org.jline" % "jline-terminal-jni" % "3.29.0", // needed for Windows
721721
("io.get-coursier" %% "coursier" % "2.0.16" % Test).cross(CrossVersion.for3Use2_13),
722-
("com.lihaoyi" %% "pprint" % "0.9.3").exclude("org.scala-lang", "*"),
723722
),
724723

724+
(Compile / sourceGenerators) += Def.task {
725+
val downloads = Seq(
726+
"https://repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.3/pprint_3-0.9.3-sources.jar",
727+
"https://repo1.maven.org/maven2/com/lihaoyi/fansi_3/0.5.1/fansi_3-0.5.1-sources.jar",
728+
"https://repo1.maven.org/maven2/com/lihaoyi/sourcecode_3/0.4.3-M5/sourcecode_3-0.4.3-M5-sources.jar",
729+
)
730+
val sourceManagedPath = os.Path((Compile / sourceManaged).value)
731+
for(download <- downloads) os.unzip.stream(requests.get.stream(download), dest = sourceManagedPath)
732+
for(file <- os.walk(sourceManagedPath) if file.ext == "scala") yield{
733+
val text = os.read(file)
734+
if (!text.contains("package scala")){
735+
os.write.over(
736+
file,
737+
"package dotty.shaded\n" +
738+
text
739+
.replace("_root_.pprint", "_root_.dotty.shaded.pprint")
740+
.replace("_root_.fansi", "_root_.dotty.shaded.fansi")
741+
)
742+
}
743+
file.toIO
744+
}
745+
}.taskValue,
746+
725747
// For convenience, change the baseDirectory when running the compiler
726748
Compile / forkOptions := (Compile / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
727749
Compile / run / forkOptions := (Compile / run / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),

project/build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Used by VersionUtil to get gitHash and commitDate
22
libraryDependencies += "org.eclipse.jgit" % "org.eclipse.jgit" % "4.11.0.201803080745-r"
3+
libraryDependencies += "com.lihaoyi" %% "requests" % "0.9.0"
4+
libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.11.5"
35

46
libraryDependencies += Dependencies.`jackson-databind`

0 commit comments

Comments
 (0)