Fix Bazel 7 related protobuf build failures #1620
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes protobuf related build failures under Bazel 7, while remaining compatible with Bazel 6.
Related to #1482, #1618, and #1619. Results from the investigation documented at:
Updates
_import_paths()
inscala_proto_aspect.bzl
to handle differencesProtoInfo.proto_source_root
andProtoInfo.direct_sources
values between Bazel 6 and Bazel 7.Without this change,
_import_paths()
emits incorrect values under Bazel 7, causing targets containing generated.proto
inputs to fail, e.g.//test/proto3:test_generated_proto
.See also:
Fix paths for sibling repository setup and generated .proto files bazelbuild/bazel@6c6c196
The docstring for
ProtoInfo.proto_source_root
in the Bazel sources: https://github.com/bazelbuild/bazel/blob/7.3.2/src/main/starlark/builtins_bzl/common/proto/proto_info.bzl#L155-L172Remove incompatible_generated_protos_in_virtual_imports bazelbuild/bazel@3efaa32
Comment from: Generated Protos are no longer considered as virtual_imports in Bazel 7 Generated Protos are no longer considered as virtual_imports in Bazel 7 bazel#21075 (comment)
Motivation
This helps unblock the resolution of #1482 to add Bzlmod support, by removing an obstacle to updating to Bazel 7. I decided not to include this in #1619 to give this subtle, substantial issue the focused attention it deserves. Either PR can go in first, but both must go in before updating to Bazel 7.
cc: @BillyAutrey @jayconrod @benjaminp @TheGrizzlyDev