Skip to content

Commit a9696f4

Browse files
committed
Add default output directory scalac in dotty project
The previous default output directory when executing `scalac`, `run`, `scala3-bootstrapped/scalac` and `scala3-bootstrapped/run` was the root directory of the project. This could easily pollute the project with `.class`/`.tasty` files. In some situations, these could be mistakenly loaded by some of the projects or scripts. Now when we execute `scalac` with no `-d` option set, we output a jar in the `./out` directory.
1 parent 16f1680 commit a9696f4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

project/Build.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,8 @@ object Build {
749749
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
750750
val decompile = args0.contains("-decompile")
751751
val printTasty = args0.contains("-print-tasty")
752+
val defaultOutputDirectory =
753+
if (args0.contains("-d")) Nil else List("-d", baseDirectory.value / ".." / "out" / "default-last-scalac-out.jar")
752754
val debugFromTasty = args0.contains("-Ythrough-tasty")
753755
val args = args0.filter(arg => arg != "-repl" && arg != "-decompile" &&
754756
arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty")
@@ -783,7 +785,7 @@ object Build {
783785
extraClasspath ++= Seq(dottyCompiler, dottyInterfaces, asm, dottyStaging, dottyTastyInspector, tastyCore, compilerInterface)
784786
}
785787

786-
val fullArgs = main :: (if (printTasty) args else insertClasspathInArgs(args, extraClasspath.mkString(File.pathSeparator)))
788+
val fullArgs = main :: defaultOutputDirectory ::: (if (printTasty) args else insertClasspathInArgs(args, extraClasspath.mkString(File.pathSeparator)))
787789

788790
(Compile / runMain).toTask(fullArgs.mkString(" ", " ", ""))
789791
}.evaluated,

0 commit comments

Comments
 (0)