mirror of https://github.com/sbt/sbt.git
Merge pull request #8140 from eed3si9n/wip/eval-debug
[2.x] Support debug output for macros
This commit is contained in:
commit
8431c38e93
|
|
@ -436,8 +436,12 @@ trait Cont:
|
|||
val exprWithConfig =
|
||||
cacheConfigExprOpt.map(config => '{ $config; $expr }).getOrElse(expr)
|
||||
val body = transformWrappers(exprWithConfig.asTerm, record, Symbol.spliceOwner)
|
||||
inputBuf.toList match
|
||||
val r = inputBuf.toList match
|
||||
case Nil => pure(body)
|
||||
case x :: Nil => genMap(body, x)
|
||||
case xs => genMapN(body, xs)
|
||||
if hasVprintMacroSetting then
|
||||
if hasPrintTreeMacroSetting then Console.err.println(Printer.TreeStructure.show(r.asTerm))
|
||||
else Console.err.println(r.show)
|
||||
r
|
||||
end Cont
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@
|
|||
package sbt.internal.util
|
||||
package appmacro
|
||||
|
||||
import scala.jdk.CollectionConverters.*
|
||||
import scala.quoted.*
|
||||
import scala.collection.mutable
|
||||
import sbt.util.cacheLevel
|
||||
import sbt.util.CacheLevelTag
|
||||
import xsbti.Attic
|
||||
|
||||
trait ContextUtil[C <: Quotes & scala.Singleton](val valStart: Int):
|
||||
val qctx: C
|
||||
|
|
@ -166,4 +168,15 @@ trait ContextUtil[C <: Quotes & scala.Singleton](val valStart: Int):
|
|||
end traverser
|
||||
traverser.traverseTree(tree)(Symbol.spliceOwner)
|
||||
defs.toSet
|
||||
|
||||
private lazy val atticValues = Attic.getItems().asScala.toSet
|
||||
def hasVprintMacroSetting: Boolean =
|
||||
atticValues.contains("-Xmacro-settings:sbt:Vprint")
|
||||
def hasPrintTreeMacroSetting: Boolean =
|
||||
atticValues.contains("-Xmacro-settings:sbt:print-tree-structure")
|
||||
end ContextUtil
|
||||
|
||||
object ContextUtil:
|
||||
def appendScalacOptions(options: Seq[String]): Unit =
|
||||
Attic.appendItems(options.asJava);
|
||||
end ContextUtil
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package xsbti;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/** A global in-memory storage to pass information. */
|
||||
public class Attic {
|
||||
private static List<String> _items = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* This is used to collect scalacOptions of metabuild. This works around the fact that
|
||||
* CompilationInfo.XmacroSettings is experimental.
|
||||
*/
|
||||
public static void appendItems(Collection<String> values) {
|
||||
_items.addAll(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used to return scalacOptions of metabuild. This works around the fact that
|
||||
* CompilationInfo.XmacroSettings is experimental.
|
||||
*/
|
||||
public static Collection<String> getItems() {
|
||||
return _items;
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ import sbt.internal.inc.{ MappedFileConverter, ScalaInstance, ZincLmUtil, ZincUt
|
|||
import sbt.internal.util.Attributed.data
|
||||
import sbt.internal.util.Types.const
|
||||
import sbt.internal.util.Attributed
|
||||
import sbt.internal.util.appmacro.ContextUtil
|
||||
import sbt.internal.server.BuildServerEvalReporter
|
||||
import sbt.io.{ GlobFilter, IO }
|
||||
import sbt.librarymanagement.ivy.{ InlineIvyConfiguration, IvyDependencyResolution, IvyPaths }
|
||||
|
|
@ -776,6 +777,8 @@ private[sbt] object Load {
|
|||
}
|
||||
val converter = config.converter
|
||||
|
||||
ContextUtil.appendScalacOptions(plugs.pluginData.scalacOptions)
|
||||
|
||||
// NOTE - because we create an eval here, we need a clean-eval later for this URI.
|
||||
lazy val eval = timed("Load.loadUnit: mkEval", log) {
|
||||
def mkReporter(): EvalReporter = plugs.pluginData.buildTarget match {
|
||||
|
|
|
|||
Loading…
Reference in New Issue