Skip to content

Commit 242b0ff

Browse files
committed
Small improvements to -Xprint-args
- Don't print `-Xprint-args ...` itself - Render a programattically added single output directory as -d
1 parent 5ed8fd0 commit 242b0ff

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,24 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
14461446

14471447
private def printArgs(sources: List[SourceFile]): Unit = {
14481448
if (settings.printArgs.isSetByUser) {
1449-
val argsFile = (settings.recreateArgs ::: sources.map(_.file.absolute.toString())).mkString("", "\n", "\n")
1449+
val saved = settings.printArgs.value
1450+
val argsFile = try {
1451+
val singleOuputDir: List[String] = if (settings.d.value == settings.d.default) {
1452+
settings.outputDirs.getSingleOutput match {
1453+
case Some(file) =>
1454+
val jfile = file.file
1455+
if (jfile != null && !java.nio.file.Files.isSameFile(jfile.toPath, java.nio.file.Paths.get(settings.d.value))) {
1456+
// A build tool must have used `settings.outDirs.setSingleOutput`, bypassing `-d`.
1457+
// Render that to the equivalent -d arguments.
1458+
"-d" :: jfile.toString :: Nil
1459+
} else Nil
1460+
case _ => Nil
1461+
}
1462+
} else Nil
1463+
(settings.recreateArgs ::: singleOuputDir ::: sources.map(_.file.absolute.toString())).mkString("", "\n", "\n")
1464+
} finally {
1465+
settings.printArgs.value = saved
1466+
}
14501467
settings.printArgs.value match {
14511468
case "-" =>
14521469
reporter.echo(argsFile)

0 commit comments

Comments
 (0)