Enable working with StarlarkRuleContexts from native rules

StarlarkRuleContext construction made the assumption that only label attributes, not label lists, could be executable. This fails for some native rules, in particular extra_actions. Added a workaround and test, but it's possible there may be other latent requirements that native rules do not satisfy in all cases. These will be discovered as (and if) native rules opt into creating StarlarkRuleContexts.

I also ran into a subtle initialization ambiguity involving the Make-var context inside RuleContext. Added a lazy init workaround and a comment to StarlarkRuleContext#cachedMakeVariables (which has been renamed to avoid being shadowed by a var inside of #resolve_command).

Added a proof-of-concept test case showing how a native rule implementation can dispatch to a Starlark function that registers actions on `ctx`.

Work toward #11437.

PiperOrigin-RevId: 354951875
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
index 4ab1ff4..d132305 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
@@ -1191,7 +1191,10 @@
 
   public void initConfigurationMakeVariableContext(
       Iterable<? extends MakeVariableSupplier> makeVariableSuppliers) {
-    Preconditions.checkState(configurationMakeVariableContext == null);
+    Preconditions.checkState(
+        configurationMakeVariableContext == null,
+        "Attempted to init an already initialized Make var context (did you call"
+            + " initConfigurationMakeVariableContext() after accessing ctx.var?)");
     configurationMakeVariableContext =
         new ConfigurationMakeVariableContext(
             this, getRule().getPackage(), getConfiguration(), makeVariableSuppliers);
@@ -1222,6 +1225,10 @@
   /**
    * Returns a cached context that maps Make variable names (string) to values (string) without any
    * extra {@link MakeVariableSupplier}.
+   *
+   * <p>CAUTION: If there's no context, this will initialize the context with no
+   * MakeVariableSuppliers. Call {@link #initConfigurationMakeVariableContext} first if you want to
+   * register suppliers.
    */
   public ConfigurationMakeVariableContext getConfigurationMakeVariableContext() {
     if (configurationMakeVariableContext == null) {