RuleContext.Builder: expose Starlark semantics
For various verification tasks in build(), the RuleContext.Builder passes
itself as context. Verifications can, however, depend on the Skylark semantics
to know which incompatible changes (e.g., to visibility) have to be taken into account.
@@ -96,6 +96,7 @@ import com.google.devtools.build.lib.packages.Type;
import com.google.devtools.build.lib.packages.Type.LabelClass;
import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData;
import com.google.devtools.build.lib.syntax.EvalException;
+import com.google.devtools.build.lib.syntax.StarlarkSemantics;
import com.google.devtools.build.lib.util.FileTypeSet;
import com.google.devtools.build.lib.util.OS;
import com.google.devtools.build.lib.util.OrderedSetMultimap;
@@ -1954,6 +1955,14 @@ public final class RuleContext extends TargetContext
return target.getAssociatedRule();
}
+ /**
+ * Expose the Starlark semantics that governs the building of this rule (and the rest of the
+ * build)
+ */
+ public StarlarkSemantics getStarlarkSemantics() throws InterruptedException {
+ return env.getSkylarkSemantics();
+ }
+
/**
* Returns a rule class name suitable for log messages, including an aspect name if applicable.
*/
