BEP: report configurations for targets

In multi-architecture builds, a target might be built several times,
for the different architectures. Make the target completion events for
those distinguishable by indicating the architecture for which the target
was built. Also add the needed event for the expansion of a target to
target-configuration pairs.

Change-Id: I95ef2c81166077163dd686db4671f672160efe1d
PiperOrigin-RevId: 155491076
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
index 60a6946..382ba82 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
@@ -476,6 +476,16 @@
     List<TargetAndConfiguration> topLevelTargetsWithConfigs =
         nodesForTopLevelTargets(configurations, targets, eventHandler);
 
+    // Report the generated association of targets to configurations
+    Multimap<Label, BuildConfiguration> byLabel =
+        ArrayListMultimap.<Label, BuildConfiguration>create();
+    for (TargetAndConfiguration pair : topLevelTargetsWithConfigs) {
+      byLabel.put(pair.getLabel(), pair.getConfiguration());
+    }
+    for (Label label : byLabel.keySet()) {
+      eventBus.post(new TargetConfiguredEvent(label, byLabel.get(label)));
+    }
+
     List<ConfiguredTargetKey> topLevelCtKeys = Lists.transform(topLevelTargetsWithConfigs,
         new Function<TargetAndConfiguration, ConfiguredTargetKey>() {
           @Override
@@ -484,6 +494,7 @@
           }
         });
 
+
     List<AspectValueKey> aspectKeys = new ArrayList<>();
     for (String aspect : aspects) {
       // Syntax: label%aspect