Skip to content

Commit

Permalink
cquery --output=proto: include more dependencies in `configured_rule_…
Browse files Browse the repository at this point in the history
…input`

This is an iteration of bazelbuild/bazel#15038. That PR added the concept of `configured_rule_input`, where `--output=proto` rules include both the labels and configurations of their dependencies.

That used `CqueryTransitionResolver` to find the dependencies. `CqueryTransitionResolver` does this by directly querying the Skyframe graph. However, cquery's view of the graph doesn't directly match the Skyframe graph.

For example, cquery doesn't explicitly list aspects: if CT `//foo` depends on aspect A which has an implicit dep on CT `//bar`, the Skyframe graph shows `//foo -> A -> //bar`.

Since cquery can't directly show `A` (see [More accurate cquery](https://docs.google.com/document/d/1x-RqFFEcGIzVgtYHIq6s6Qt4vYtJWz3nuHIuqeI89dU/edit#heading=h.5mcn15i0e1ch)), cquery instead shows `//foo -> //bar`.

For any cquery use we want to use cquery's interpretation of the graph as a consistent source of truth. This change refactors `--output=proto` to do that.

This means, for example, that `cquery --output=proto` will now have `configured_rule_input` entries  for deps like `//bar`. Before this change there's no way to tell where the dependency on `//bar` comes from.

Also correctly includes aliases (doesn't dereference them as either outputs or `configured_rule_input` entries of other outputs).

Also updates the API contract for `configured_rule_input`. Before, "same configuration" deps had their configuration fields omitted. Now they're always included, except for source files which have no configuration.

PiperOrigin-RevId: 621245620
  • Loading branch information
Googler authored and copybara-github committed Apr 2, 2024
1 parent 3af3f13 commit 654d988
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions third_party/bazel/src/main/protobuf/build.proto
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,16 @@ message Rule {
repeated string definition_stack = 14;
}

// Direct dependencies of a rule in <depLabel, depConfiguration> form.
message ConfiguredRuleInput {
// Dep's target label.
optional string label = 1;
// Dep's configuration if the dep isn't a source file, else unset.
optional string configuration_checksum = 2;
// Reference to this dep's configuration if --proto:include_configurations is
// set: see
// https://github.com/bazelbuild/bazel/blob/7278be3f9b0c26842ecb8225f0215c1e4aede5a9/src/main/protobuf/analysis_v2.proto#L189.
// If this dep is a source file, this is unset.
optional uint32 configuration_id = 3;
}

Expand Down

0 comments on commit 654d988

Please sign in to comment.