Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve printing of what is being compiled in benchmarks #503

Merged
merged 2 commits into from
Mar 5, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions internal/zinc-benchmarks/src/main/scala/xsbt/BenchmarkBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] = _

Expand All @@ -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)
Expand All @@ -70,7 +74,6 @@ class BenchmarkBase {
}

protected def compile(): Unit = {
println(_message.head)
_setup.compile()
}
}