mirror of
https://github.com/enso-org/enso.git
synced 2024-09-17 16:17:25 +03:00
Debugging flags for benchOnly (#179)
This commit is contained in:
parent
7c1d9cf908
commit
47f5adfff3
10
build.sbt
10
build.sbt
@ -1,4 +1,6 @@
|
||||
import scala.sys.process._
|
||||
import org.enso.build.BenchTasks._
|
||||
import org.enso.build.WithDebugCommand
|
||||
|
||||
// Global Configuration
|
||||
organization := "org.enso"
|
||||
@ -15,9 +17,9 @@ scalacOptions ++= Seq(
|
||||
javacOptions ++= Seq("-source", "12", "-target", "1.8")
|
||||
|
||||
// Benchmark Configuration
|
||||
lazy val Benchmark = config("bench") extend Test
|
||||
lazy val bench = taskKey[Unit]("Run Benchmarks")
|
||||
lazy val benchOnly = inputKey[Unit]("Run benchmarks by name substring")
|
||||
lazy val Benchmark = config("bench") extend sbt.Test
|
||||
|
||||
// Native Image Generation
|
||||
lazy val buildNativeImage =
|
||||
taskKey[Unit]("Build native image for the Enso executable")
|
||||
|
||||
@ -93,7 +95,7 @@ lazy val interpreter = (project in file("Interpreter"))
|
||||
mainClass in (Compile, run) := Some("org.enso.interpreter.Main"),
|
||||
version := "0.1"
|
||||
)
|
||||
.settings(commands += RunDebugCommand.runDebug)
|
||||
.settings(commands += WithDebugCommand.withDebug)
|
||||
.settings(
|
||||
libraryDependencies ++= Seq(
|
||||
"com.chuusai" %% "shapeless" % "2.3.3",
|
||||
|
12
project/BenchTasks.scala
Normal file
12
project/BenchTasks.scala
Normal file
@ -0,0 +1,12 @@
|
||||
package org.enso.build
|
||||
|
||||
import sbt.inputKey
|
||||
import sbt.taskKey
|
||||
|
||||
/**
|
||||
* Defines benchmarking related task keys.
|
||||
*/
|
||||
object BenchTasks {
|
||||
lazy val bench = taskKey[Unit]("Run Benchmarks")
|
||||
lazy val benchOnly = inputKey[Unit]("Run benchmarks by name substring")
|
||||
}
|
@ -1,17 +1,20 @@
|
||||
import sbt.Keys.javaOptions
|
||||
package org.enso.build
|
||||
|
||||
import sbt._
|
||||
|
||||
/** Command allowing to run the CLI program with additional JVM-level flags.
|
||||
* The supported flags are:
|
||||
/** Command allowing to run a task with additional JVM-level flags.
|
||||
* Supported tasks are run and benchOnly.
|
||||
* Supported flags are:
|
||||
* * `--dumpGraphs`: dumps IGV output of the program
|
||||
* * `--showCompilations`: prints Truffle compilation traces
|
||||
* * `--printAssembly`: prints the disassembler output
|
||||
* Any CLI arguments should be passed following `--` like so:
|
||||
* Any task arguments should be passed following `--` like so:
|
||||
* {{{
|
||||
* runDebug --dumpGraphs --printAssembly -- --run myFile.enso
|
||||
* withDebug run --dumpGraphs --printAssembly -- --run myFile.enso
|
||||
* withDebug benchOnly --showCompilations -- myBenchmark
|
||||
* }}}
|
||||
*/
|
||||
object RunDebugCommand {
|
||||
object WithDebugCommand {
|
||||
|
||||
val truffleNoBackgroundCompilationOptions = Seq(
|
||||
"-Dgraal.TruffleBackgroundCompilation=false"
|
||||
@ -42,13 +45,22 @@ object RunDebugCommand {
|
||||
|
||||
val argSeparator = "--"
|
||||
|
||||
val commandName = "runDebug"
|
||||
val commandName = "withDebug"
|
||||
|
||||
val benchOnlyCommandName = "benchOnly"
|
||||
val runCommandName = "run"
|
||||
|
||||
/** The main logic for parsing and transforming the debug flags into JVM level flags */
|
||||
def runDebug: Command = Command.args(commandName, "<arguments>") {
|
||||
def withDebug: Command = Command.args(commandName, "<arguments>") {
|
||||
(state, args) =>
|
||||
val (debugFlags, prefixedRunArgs) = args.span(_ != argSeparator)
|
||||
val runArgs = " " + prefixedRunArgs.drop(1).mkString(" ")
|
||||
|
||||
val taskKey =
|
||||
if (debugFlags.contains(benchOnlyCommandName)) BenchTasks.benchOnly
|
||||
else if (debugFlags.contains(runCommandName)) Compile / Keys.run
|
||||
else throw new IllegalArgumentException("Invalid command name.")
|
||||
|
||||
val dumpGraphsOpts =
|
||||
if (debugFlags.contains(dumpGraphsOption)) truffleDumpGraphsOptions
|
||||
else Seq()
|
||||
@ -69,12 +81,12 @@ object RunDebugCommand {
|
||||
|
||||
val extracted = Project.extract(state)
|
||||
val withJavaOpts = extracted.appendWithoutSession(
|
||||
Seq(Compile / Keys.run / Keys.javaOptions ++= javaOpts),
|
||||
Seq(Compile / Keys.javaOptions ++= javaOpts),
|
||||
state
|
||||
)
|
||||
Project
|
||||
.extract(withJavaOpts)
|
||||
.runInputTask(Compile / Keys.run, runArgs, withJavaOpts)
|
||||
.runInputTask(taskKey, runArgs, withJavaOpts)
|
||||
state
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user