From e566126eec7f9cdeb42e7cc3f079b00f57457bcf Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 22 Feb 2018 09:26:53 +1000 Subject: [PATCH] Improve printing of what is being compiled in benchmarks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` info] # Warmup Iteration 1: [info] Compiling {scala/scala@827d69d}/library using: @/tmp/zinc-bench-baseline/compiler.args ``` ``` ⚡ head /tmp/zinc-bench-baseline/compiler.args -cp -sourcepath /private/tmp/zinc-bench-baseline/827d69d48e96d9add75ce19e06b374610784c936/src/library -usejavacp /private/tmp/zinc-bench-baseline/827d69d48e96d9add75ce19e06b374610784c936/src/library/scala/AnyVal.scala /private/tmp/zinc-bench-baseline/827d69d48e96d9add75ce19e06b374610784c936/src/library/scala/AnyValCompanion.scala /private/tmp/zinc-bench-baseline/827d69d48e96d9add75ce19e06b374610784c936/src/library/scala/App.scala /private/tmp/zinc-bench-baseline/827d69d48e96d9add75ce19e06b374610784c936/src/library/scala/Array.scala /private/tmp/zinc-bench-baseline/827d69d48e96d9add75ce19e06b374610784c936/src/library/scala/Boolean.scala ``` --- .../src/main/scala/xsbt/BenchmarkBase.scala | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/internal/zinc-benchmarks/src/main/scala/xsbt/BenchmarkBase.scala b/internal/zinc-benchmarks/src/main/scala/xsbt/BenchmarkBase.scala index 9db292f22b..a202ccd233 100644 --- a/internal/zinc-benchmarks/src/main/scala/xsbt/BenchmarkBase.scala +++ b/internal/zinc-benchmarks/src/main/scala/xsbt/BenchmarkBase.scala @@ -24,7 +24,6 @@ class BenchmarkBase { /* Data filled in by the benchmark setup. */ var _dir: File = _ - var _message: String = _ var _setup: ProjectSetup = _ var _subprojectsSetup: List[ProjectSetup] = _ @@ -49,17 +48,22 @@ class BenchmarkBase { _setup = _subprojectsSetup .find(p => p.subproject == id) .getOrElse(sys.error(s"No subproject ${_subprojectToRun} found.")) - _message = { - val info = _setup.compilationInfo - s"""Compiling with: - | - |> Classpath: ${info.classpath} - | - |> Scalac options: ${info.scalacOptions.mkString(" ")} - | - |> Scala sources: ${info.sources.mkString(" ")} - """.stripMargin + printCompilationDetails() + } + + private def printCompilationDetails() = { + val info = _setup.compilationInfo + + val argsFile = new File(_tempDir, "compiler.args") + val argsFileContents: String = { + val cpArgs = if (info.classpath.isEmpty) Nil else List("-cp", info.classpath) + val allArgs: List[String] = cpArgs ::: info.scalacOptions.toList ::: info.sources + allArgs.mkString("\n") } + sbt.io.IO.write(argsFile, argsFileContents) + val shortSha = _project.hash.take(7) + println( + s"\nCompiling {${_project.repo}@${shortSha}}/${_subprojectToRun} using: @${argsFile.getAbsolutePath}") } @TearDown(Level.Trial) @@ -70,7 +74,6 @@ class BenchmarkBase { } protected def compile(): Unit = { - println(_message.head) _setup.compile() } }