Introduces a registry of native providers to the BuildConfiguration, which can be added to by fragments.  Uses the registry to enable native access to TranstiveProviderInstances from Skylark.  In particular, makes ObjcProvider accessible to skylark rule implementations.

--
MOS_MIGRATED_REVID=121390911
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 9c85ce9..faa4f2c 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
@@ -18,6 +18,7 @@
 import com.google.common.base.Joiner;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableBiMap;
 import com.google.common.collect.ImmutableCollection;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableListMultimap;
@@ -151,7 +152,9 @@
   private final ConfigurationFragmentPolicy configurationFragmentPolicy;
   private final Class<? extends BuildConfiguration.Fragment> universalFragment;
   private final ErrorReporter reporter;
-
+  private final ImmutableBiMap<String, Class<? extends TransitiveInfoProvider>>
+      skylarkProviderRegistry;
+  
   private ActionOwner actionOwner;
 
   /* lazily computed cache for Make variables, computed from the above. See get... method */
@@ -178,6 +181,7 @@
     this.features = getEnabledFeatures();
     this.ruleClassNameForLogging = ruleClassNameForLogging;
     this.aspectAttributes = aspectAttributes;
+    this.skylarkProviderRegistry = builder.skylarkProviderRegistry;
     this.hostConfiguration = builder.hostConfiguration;
     reporter = builder.reporter;
   }
@@ -269,6 +273,15 @@
   }
 
   /**
+   * Returns a map that indicates which providers should be exported to skylark under the key
+   * (map key).  These provider types will also be exportable by skylark rules under (map key).
+   */
+  public ImmutableBiMap<String, Class<? extends TransitiveInfoProvider>>
+      getSkylarkProviderRegistry() {
+    return skylarkProviderRegistry;
+  }
+  
+  /**
    * Returns whether this instance is known to have errors at this point during analysis. Do not
    * call this method after the initializationHook has returned.
    */
@@ -1307,6 +1320,7 @@
     private Set<ConfigMatchingProvider> configConditions;
     private NestedSet<PackageSpecification> visibility;
     private ImmutableMap<String, Attribute> aspectAttributes;
+    private ImmutableBiMap<String, Class<? extends TransitiveInfoProvider>> skylarkProviderRegistry;
 
     Builder(
         AnalysisEnvironment env,
@@ -1393,6 +1407,16 @@
       return this;
     }
 
+    /**
+     * Sets a map that indicates which providers should be exported to skylark under the key
+     * (map key).  These provider types will also be exportable by skylark rules under (map key).
+     */
+    Builder setSkylarkProvidersRegistry(
+        ImmutableBiMap<String, Class<? extends TransitiveInfoProvider>> skylarkProviderRegistry) {
+      this.skylarkProviderRegistry = skylarkProviderRegistry;
+      return this;
+    }
+
     private boolean validateFilesetEntry(FilesetEntry filesetEntry, ConfiguredTarget src) {
       if (src.getProvider(FilesetProvider.class) != null) {
         return true;