Skip to content

Commit

Permalink
Merge pull request #47 from danicheg/fix-#45
Browse files Browse the repository at this point in the history
Emit the warning if the `-Vstatistics` option isn't set
  • Loading branch information
SethTisue authored Nov 23, 2023
2 parents 529f77d + 5413ff9 commit af02e05
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions plugin/src/main/scala/ch/epfl/scala/ProfilingPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ import ch.epfl.scala.profiledb.utils.{AbsolutePath, RelativePath}
import ch.epfl.scala.profilers.ProfilingImpl
import ch.epfl.scala.profilers.tools.{Logger, ScalaSettingsOps, SettingsOps}

import scala.reflect.internal.util.{SourceFile, Statistics}
import scala.reflect.internal.util.{NoPosition, SourceFile, Statistics}
import scala.reflect.io.Path
import scala.tools.nsc.Reporting.WarningCategory
import scala.tools.nsc.io.AbstractFile
import scala.tools.nsc.{Global, Phase}
import scala.tools.nsc.plugins.{Plugin, PluginComponent}
import scala.util.Try
import scala.util.matching.Regex

class ProfilingPlugin(val global: Global) extends Plugin {
class ProfilingPlugin(val global: Global) extends Plugin { self =>
// Every definition used at init needs to be lazy otherwise it slays the compiler
val name = "scalac-profiling"
val description = "Adds instrumentation to keep an eye on Scalac performance."
Expand Down Expand Up @@ -321,6 +322,16 @@ class ProfilingPlugin(val global: Global) extends Plugin {
override def run(): Unit = {
super.run()

if (!SettingsOps.areStatisticsEnabled(global)) {
val flagName = global.settings.Ystatistics.name
global.runReporting.warning(
NoPosition,
s"`${self.name}` compiler plugin requires the option `$flagName` to be enabled",
WarningCategory.OtherDebug,
""
)
}

val graphsRelativePath = ProfileDbPath.GraphsProfileDbRelativePath
val graphsDir = globalOutputDir.resolve(graphsRelativePath)
reportStatistics(graphsDir)
Expand Down

0 comments on commit af02e05

Please sign in to comment.