Skip to content

Commit

Permalink
Update cc_file_list_aspect to handle targets with missing `hdrs/tex…
Browse files Browse the repository at this point in the history
…tual_hdrs`

Our stale file regeneration logic broke with Bazel 6.4.0, and I suspect it was
caused by this change: bazelbuild/bazel#19534 Our logic
assumed that any target with a `CcInfo` provider must have `hdrs` and
`textual_hdrs` attributes, but it seems that this is no longer true for
`cc_proto_library` starting with Bazel 6.4.0. The fix is just to use `getattr`
and treat the item as an empty list if it's missing.

PiperOrigin-RevId: 575473886
  • Loading branch information
acozzette authored and mkruskal-google committed Nov 2, 2023
1 parent 3105b8d commit 1155c80
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/cc_dist_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ def _cc_file_list_aspect_impl(target, ctx):

return [CcFileList(
hdrs = _get_transitive_sources(
_flatten_target_files(rule_attr.hdrs).to_list(),
_flatten_target_files(getattr(rule_attr, "hdrs", [])).to_list(),
"hdrs",
rule_attr.deps,
),
textual_hdrs = _get_transitive_sources(
_flatten_target_files(rule_attr.textual_hdrs).to_list(),
_flatten_target_files(getattr(rule_attr, "textual_hdrs", [])).to_list(),
"textual_hdrs",
rule_attr.deps,
),
Expand Down

0 comments on commit 1155c80

Please sign in to comment.