Allow ImplicitOutputsFunctions to be overriden on Rule creation.

--
MOS_MIGRATED_REVID=129787305
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
index 62f8a24..751e6cf 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
@@ -1136,18 +1136,21 @@
   }
 
   /**
-   * Returns the function which determines the set of implicit outputs
-   * generated by a given rule.
+   * Returns the default function for determining the set of implicit outputs generated by a given
+   * rule. If not otherwise specified, this will be the implementation used by {@link Rule}s
+   * created with this {@link RuleClass}.
    *
-   * <p>An implicit output is an OutputFile that automatically comes into
-   * existence when a rule of this class is declared, and whose name is derived
-   * from the name of the rule.
+   * <p>Do not use this value to calculate implicit outputs for a rule, instead use
+   * {@link Rule#getImplicitOutputsFunction()}.
    *
-   * <p>Implicit outputs are a widely-relied upon.  All ".so",
-   * and "_deploy.jar" targets referenced in BUILD files are examples.
+   * <p>An implicit output is an OutputFile that automatically comes into existence when a rule of
+   * this class is declared, and whose name is derived from the name of the rule.
+   *
+   * <p>Implicit outputs are a widely-relied upon. All ".so", and "_deploy.jar" targets referenced
+   * in BUILD files are examples.
    */
   @VisibleForTesting
-  public ImplicitOutputsFunction getImplicitOutputsFunction() {
+  public ImplicitOutputsFunction getDefaultImplicitOutputsFunction() {
     return implicitOutputsFunction;
   }
 
@@ -1349,9 +1352,15 @@
       Label ruleLabel,
       AttributeValuesMap attributeValues,
       Location location,
-      AttributeContainer attributeContainer)
+      AttributeContainer attributeContainer,
+      ImplicitOutputsFunction implicitOutputsFunction)
       throws LabelSyntaxException, InterruptedException {
-    Rule rule = pkgBuilder.createRule(ruleLabel, this, location, attributeContainer);
+    Rule rule = pkgBuilder.createRule(
+        ruleLabel,
+        this,
+        location,
+        attributeContainer,
+        implicitOutputsFunction);
     populateRuleAttributeValues(rule, pkgBuilder, attributeValues, NullEventHandler.INSTANCE);
     rule.populateOutputFiles(NullEventHandler.INSTANCE, pkgBuilder);
     return rule;