سؤال

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.toList
  }

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)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top