aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Cozzette <acozzette@google.com>2023-10-21 09:37:33 -0700
committerMike Kruskal <mkruskal@google.com>2023-11-02 12:57:13 -0700
commit1155c804efe5457071b813ca9cc17c7535e7ba09 (patch)
treef31be409473dd4ab1e74f8d2708e8ecfb1e48b54
parent3105b8d57eebb74867daadf1ca32dfa6a55040df (diff)
downloadprotobuf-1155c804efe5457071b813ca9cc17c7535e7ba09.tar.gz
Update `cc_file_list_aspect` to handle targets with missing `hdrs/textual_hdrs`
Our stale file regeneration logic broke with Bazel 6.4.0, and I suspect it was caused by this change: https://github.com/bazelbuild/bazel/pull/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
-rw-r--r--pkg/cc_dist_library.bzl4
1 files changed, 2 insertions, 2 deletions
diff --git a/pkg/cc_dist_library.bzl b/pkg/cc_dist_library.bzl
index 42553ca3f..9fc2c414e 100644
--- a/pkg/cc_dist_library.bzl
+++ b/pkg/cc_dist_library.bzl
@@ -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,
),