Example #1
0
 /**
  * Returns ids for dependent nodes of a given node, sorted by attribute. Note that some
  * dependencies do not have a corresponding attribute here, and we use the null attribute to
  * represent those edges. Visibility attributes are only visited if {@code visitVisibility} is
  * {@code true}.
  *
  * <p>If {@code aspect} is null, returns the dependent nodes of the configured target node
  * representing the given target and configuration, otherwise that of the aspect node accompanying
  * the aforementioned configured target node for the specified aspect.
  *
  * <p>The values are not simply labels because this also implements the first step of applying
  * configuration transitions, namely, split transitions. This needs to be done before the labels
  * are resolved because late bound attributes depend on the configuration. A good example for this
  * is @{code :cc_toolchain}.
  *
  * <p>The long-term goal is that most configuration transitions be applied here. However, in order
  * to do that, we first have to eliminate transitions that depend on the rule class of the
  * dependency.
  */
 public final ListMultimap<Attribute, Dependency> dependentNodeMap(
     TargetAndConfiguration node,
     BuildConfiguration hostConfig,
     AspectDefinition aspect,
     AspectParameters aspectParameters,
     Set<ConfigMatchingProvider> configConditions)
     throws EvalException, InterruptedException {
   Target target = node.getTarget();
   BuildConfiguration config = node.getConfiguration();
   ListMultimap<Attribute, Dependency> outgoingEdges = ArrayListMultimap.create();
   if (target instanceof OutputFile) {
     Preconditions.checkNotNull(config);
     visitTargetVisibility(node, outgoingEdges.get(null));
     Rule rule = ((OutputFile) target).getGeneratingRule();
     outgoingEdges.put(null, new Dependency(rule.getLabel(), config));
   } else if (target instanceof InputFile) {
     visitTargetVisibility(node, outgoingEdges.get(null));
   } else if (target instanceof EnvironmentGroup) {
     visitTargetVisibility(node, outgoingEdges.get(null));
   } else if (target instanceof Rule) {
     Preconditions.checkNotNull(config);
     visitTargetVisibility(node, outgoingEdges.get(null));
     Rule rule = (Rule) target;
     ListMultimap<Attribute, LabelAndConfiguration> labelMap =
         resolveAttributes(rule, aspect, config, hostConfig, configConditions);
     visitRule(rule, aspect, aspectParameters, labelMap, outgoingEdges);
   } else if (target instanceof PackageGroup) {
     visitPackageGroup(node, (PackageGroup) target, outgoingEdges.get(null));
   } else {
     throw new IllegalStateException(target.getLabel().toString());
   }
   return outgoingEdges;
 }