Support debug output for macros

It's sometimes useful to get the output of the macro-generated code.
This adds a mechanism to allow plugins.sbt to pass in scalacOptions,
which we can later check from the macro.

1. -Xmacro-settings:sbt:Vprint prints out the code.
2. Adding -Xmacro-settings:sbt:print-tree-structure prints out the tree structure.
This commit is contained in:
Eugene Yokota
2025-05-27 00:58:41 -04:00
parent 5fabfdff32
commit 4521f43995
4 changed files with 47 additions and 1 deletions
@@ -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;
}
}