Skip to content

Commit

Permalink
[aquery] Handle the case of aspect-on-aspect.
Browse files Browse the repository at this point in the history
Problems:
Current aquery output:
- In the case of aspect-on-aspect: does include the full aspect path, but in reversed order.
- Lists the Target label as the "Owner" of an action that was generated from an Aspect applied on that Target. Technically the Owner of the action should be the Aspect.

Changes:
- AspectDescriptors now represent the aspect path (sorted by topological order of the dependency graph).
- Replace "Owner" by "Target" in aquery text output (there's no "Owner" field in proto output).

RELNOTES: [aquery] Handle the case of aspect-on-aspect.
PiperOrigin-RevId: 230528732
  • Loading branch information
joeleba authored and Copybara-Service committed Jan 23, 2019
1 parent 22cdcc5 commit ed99017
Show file tree
Hide file tree
Showing 5 changed files with 537 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,20 @@ private void writeAction(ActionAnalysisMetadata action, PrintStream printStream)
BuildEvent configuration = actionOwner.getConfiguration();
BuildEventStreamProtos.Configuration configProto =
configuration.asStreamProto(/*context=*/ null).getConfiguration();

stringBuilder
.append(" Owner: ")
.append(actionOwner.getLabel().toString())
.append(" Target: ")
.append(actionOwner.getLabel())
.append('\n')
.append(" Configuration: ")
.append(configProto.getMnemonic())
.append('\n');
ImmutableList<AspectDescriptor> aspectDescriptors = actionOwner.getAspectDescriptors();

// In the case of aspect-on-aspect, AspectDescriptors are listed in
// topological order of the dependency graph.
// e.g. [A -> B] would imply that aspect A is applied on top of aspect B.
ImmutableList<AspectDescriptor> aspectDescriptors =
actionOwner.getAspectDescriptors().reverse();
if (!aspectDescriptors.isEmpty()) {
stringBuilder
.append(" AspectDescriptors: [")
Expand Down Expand Up @@ -164,8 +170,7 @@ private void writeAction(ActionAnalysisMetadata action, PrintStream printStream)
.append(')');
return aspectDescription.toString();
})
.sorted()
.collect(Collectors.joining(",\n")))
.collect(Collectors.joining("\n -> ")))
.append("]\n");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,17 @@ private void dumpSingleAction(ConfiguredTarget configuredTarget, ActionAnalysisM
BuildEvent event = actionOwner.getConfiguration();
actionBuilder.setConfigurationId(knownConfigurations.dataToId(event));

// store aspect
for (AspectDescriptor aspectDescriptor : actionOwner.getAspectDescriptors()) {
// Store aspects.
// Iterate through the aspect path and dump the aspect descriptors.
// In the case of aspect-on-aspect, AspectDescriptors are listed in topological order
// of the configured target graph.
// e.g. [A, B] would imply that aspect A is applied on top of aspect B.
for (AspectDescriptor aspectDescriptor : actionOwner.getAspectDescriptors().reverse()) {
actionBuilder.addAspectDescriptorIds(knownAspectDescriptors.dataToId(aspectDescriptor));
}
}

// store inputs
// Store inputs
Iterable<Artifact> inputs = action.getInputs();
if (!(inputs instanceof NestedSet)) {
inputs = NestedSetBuilder.wrap(Order.STABLE_ORDER, inputs);
Expand Down
3 changes: 3 additions & 0 deletions src/main/protobuf/analysis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ message Action {
string target_id = 1;

// The aspects that were responsible for the creation of the action (if any).
// In the case of aspect-on-aspect, AspectDescriptors are listed in
// topological order of the dependency graph.
// e.g. [A, B] would imply that aspect A is applied on top of aspect B.
repeated string aspect_descriptor_ids = 2;

// Encodes all significant behavior that might affect the output. The key
Expand Down
Loading

0 comments on commit ed99017

Please sign in to comment.