开发者

stopping Scala compilation after a particular phase

开发者 https://www.devze.com 2023-02-28 22:58 出处:网络
I\'m testing my plugin by running it in-process like this: type PluginMessage = StoreReporter#Info def runPlugin(fileName: String): List[PluginMessage] = {

I'm testing my plugin by running it in-process like this:

  type PluginMessage = StoreReporter#Info
  def runPlugin(fileName: String): List[PluginMessage] = {
    val settings = new Settings 
    settings.outputDirs setSingleOutput (curDir + "/target")
    settings.classpath.tryToSet(List(
      "project/boot/scala-" + scalaVersion + "/lib/scala-compiler.jar" +
      ":project/boot/scala-" + scalaVersion + "/lib/scala-library.jar"))
    val reporter = new StoreReporter
    val compiler = new Global(settings, reporter) {
      override protected def computeInternalPhases() {
        super.computeInternalPhases
        for (phase <- new AlacsPlugin(this).components)
          phasesSet += phase
      }
    }
    (new compiler.Run).compile(List(testPrefix + fileName))
    reporter.infos.to开发者_C百科List
  }

However, given the slow speed of scalac I'd really like for compilation to end after a certain phase (specifically, after my plugin runs). Unfortunately Global.cancel doesn't have the intended effect. How might I do this?


scalac has an argument explicitly for this purpose. As of 2.9.0.RC2 you can specify at the command line:

-Ystop-after:<phasename>

And in earlier versions:

-Ystop:<phasename>

To do the equivalent directly from a Settings instance, this is defined as stopAfter (or stop in earlier versions)

0

精彩评论

暂无评论...
验证码 换一张
取 消