Skip to content

Commit 02af1d8

Browse files
smarterOlivierBlanvillain
authored andcommitted
sjsSandbox: simplify and fix build
We don't need to do anything special to compile code with dotty anymore, but we do need to have the bootstrapped library on the classpath.
1 parent a8ef78c commit 02af1d8

File tree

1 file changed

+2
-98
lines changed

1 file changed

+2
-98
lines changed

project/Build.scala

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,7 @@ object Build {
786786
*/
787787
lazy val sjsSandbox = project.in(file("sandbox/scalajs")).
788788
enablePlugins(ScalaJSPlugin).
789+
dependsOn(dottyLibrary(Bootstrapped)).
789790
settings(commonBootstrappedSettings).
790791
settings(
791792
/* Remove the Scala.js compiler plugin for scalac, and enable the
@@ -808,8 +809,7 @@ object Build {
808809
scalaJSLinkerConfig ~= {
809810
_.withCheckIR(true).withParallel(false)
810811
}
811-
).
812-
settings(compileWithDottySettings)
812+
)
813813

814814
lazy val `dotty-bench` = project.in(file("bench")).asDottyBench(NonBootstrapped)
815815
lazy val `dotty-bench-bootstrapped` = project.in(file("bench")).asDottyBench(Bootstrapped)
@@ -1056,102 +1056,6 @@ object Build {
10561056
)
10571057
)
10581058

1059-
// Compile with dotty
1060-
lazy val compileWithDottySettings = {
1061-
inConfig(Compile)(inTask(compile)(Defaults.runnerTask) ++ Seq(
1062-
// Compile with dotty
1063-
fork in compile := true,
1064-
1065-
compile := {
1066-
val inputs = (compileInputs in compile).value
1067-
val inputOptions = inputs.options()
1068-
import inputOptions._
1069-
1070-
val s = streams.value
1071-
val logger = s.log
1072-
val cacheDir = s.cacheDirectory
1073-
1074-
// Discover classpaths
1075-
1076-
def cpToString(cp: Seq[File]) =
1077-
cp.map(_.getAbsolutePath).mkString(File.pathSeparator)
1078-
1079-
val compilerCp = Attributed.data((fullClasspath in (`dotty-compiler`, Compile)).value)
1080-
val cpStr = cpToString(classpath ++ compilerCp)
1081-
1082-
// List all my dependencies (recompile if any of these changes)
1083-
1084-
val allMyDependencies = classpath filterNot (_ == classesDirectory) flatMap { cpFile =>
1085-
if (cpFile.isDirectory) (cpFile ** "*.class").get
1086-
else Seq(cpFile)
1087-
}
1088-
1089-
// Compile
1090-
1091-
val run = (runner in compile).value
1092-
val cachedCompile = FileFunction.cached(cacheDir / "compile",
1093-
FilesInfo.lastModified, FilesInfo.exists) { dependencies =>
1094-
1095-
logger.info(
1096-
"Compiling %d Scala sources to %s..." format (
1097-
sources.size, classesDirectory))
1098-
1099-
if (classesDirectory.exists)
1100-
IO.delete(classesDirectory)
1101-
IO.createDirectory(classesDirectory)
1102-
1103-
val sourcesArgs = sources.map(_.getAbsolutePath()).toList
1104-
1105-
/* run.run() below in doCompile() will emit a call to its
1106-
* logger.info("Running dotty.tools.dotc.Main [...]")
1107-
* which we do not want to see. We use this patched logger to
1108-
* filter out that particular message.
1109-
*/
1110-
val patchedLogger = new Logger {
1111-
def log(level: Level.Value, message: => String) = {
1112-
val msg = message
1113-
if (level != Level.Info ||
1114-
!msg.startsWith("Running dotty.tools.dotc.Main"))
1115-
logger.log(level, msg)
1116-
}
1117-
def success(message: => String) = logger.success(message)
1118-
def trace(t: => Throwable) = logger.trace(t)
1119-
}
1120-
1121-
def doCompile(sourcesArgs: List[String]): Unit = {
1122-
run.run("dotty.tools.dotc.Main", compilerCp,
1123-
"-classpath" :: cpStr ::
1124-
"-d" :: classesDirectory.getAbsolutePath ::
1125-
scalacOptions ++:
1126-
sourcesArgs,
1127-
patchedLogger)
1128-
}
1129-
1130-
// Work around the Windows limitation on command line length.
1131-
val isWindows =
1132-
System.getProperty("os.name").toLowerCase().indexOf("win") >= 0
1133-
if ((fork in compile).value && isWindows &&
1134-
(sourcesArgs.map(_.length).sum > 1536)) {
1135-
IO.withTemporaryFile("sourcesargs", ".txt") { sourceListFile =>
1136-
IO.writeLines(sourceListFile, sourcesArgs)
1137-
doCompile(List("@"+sourceListFile.getAbsolutePath))
1138-
}
1139-
} else {
1140-
doCompile(sourcesArgs)
1141-
}
1142-
1143-
// Output is all files in classesDirectory
1144-
(classesDirectory ** AllPassFilter).get.toSet
1145-
}
1146-
1147-
cachedCompile((sources ++ allMyDependencies).toSet)
1148-
1149-
// We do not have dependency analysis when compiling externally
1150-
sbt.internal.inc.Analysis.Empty
1151-
}
1152-
))
1153-
}
1154-
11551059
lazy val commonDistSettings = Seq(
11561060
packMain := Map(),
11571061
publishArtifact := false,

0 commit comments

Comments
 (0)