Skip to content

Switch to "protobuf" module when generating proto_library rules#2284

Merged
jayconrod merged 15 commits intobazel-contrib:masterfrom
mateusz-olczyk:deprecated-rules-proto
Feb 20, 2026
Merged

Switch to "protobuf" module when generating proto_library rules#2284
jayconrod merged 15 commits intobazel-contrib:masterfrom
mateusz-olczyk:deprecated-rules-proto

Conversation

@mateusz-olczyk
Copy link
Copy Markdown
Contributor

@mateusz-olczyk mateusz-olczyk commented Feb 11, 2026

What type of PR is this?

Other

What package or component does this PR mostly affect?

language/proto

What does this PR do? Why is it needed?

Because "rules_proto" is a deprecated module, proto_library rule should be fetched from the "protobuf" module. This change updates ApparentLoads() method for proto extension and updates the test scenarios accordingly. Moreover, rules_proto is not mentioned in README.md anymore; now it refers to protobuf.

Which issues(s) does this PR fix?

Fixes #2283

Other notes for review

I wasn't sure if "rules_proto" should also be removed from MODULE.bazel. It looks like bazel test //... passes after removing both "rules_proto" and "protobuf" from MODULE.bazel. But I see those may be required by the submodules: tests/bcr/go_mod and tests/bcr/go_work.

Signed-off-by: Mateusz Olczyk <molczyk@virtuslab.com>
Signed-off-by: Mateusz Olczyk <molczyk@virtuslab.com>
Signed-off-by: Mateusz Olczyk <molczyk@virtuslab.com>
Signed-off-by: Mateusz Olczyk <molczyk@virtuslab.com>
@fmeum fmeum requested a review from jayconrod February 11, 2026 19:46
@fmeum
Copy link
Copy Markdown
Member

fmeum commented Feb 11, 2026

+1 for doing this, even if we may have to migrate again at some point in the future if protobuf is split up.

Copy link
Copy Markdown
Contributor

@jayconrod jayconrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this. One small comment about the module name, but it will affect lots of files.

Comment thread language/proto/kinds.go Outdated
Comment thread README.md Outdated
Comment thread language/proto/kinds.go
@jayconrod
Copy link
Copy Markdown
Contributor

I wasn't sure if "rules_proto" should also be removed from MODULE.bazel. It looks like bazel test //... passes after removing both "rules_proto" and "protobuf" from MODULE.bazel. But I see those may be required by the submodules: tests/bcr/go_mod and tests/bcr/go_work.

Please update tests/bcr/go_mod/MODULE.bazel and tests/bcr/go_work/MODULE.bazel to depend on protobuf rather than rules_proto. These are end-to-end tests that run Gazelle in a fake repo and verify that it generates real targets that can be built. There are .proto files here.

Let's drop the rules_proto dependency from the main MODULE.bazel completely. Gazelle itself doesn't have .proto files or proto_library targets, so we don't need it. (I think... perhaps CI will prove me wrong.)

mateusz-olczyk and others added 6 commits February 16, 2026 14:09
Signed-off-by: Mateusz Olczyk <molczyk@virtuslab.com>
Signed-off-by: Mateusz Olczyk <molczyk@virtuslab.com>
buildtools/labels/BUILD.bazel already contains Bazel files, so the
dependency is set directly on the go_library(name = "labels") instead of
its "go_default_library" alias.

Signed-off-by: Mateusz Olczyk <molczyk@virtuslab.com>
Signed-off-by: Mateusz Olczyk <molczyk@virtuslab.com>
Signed-off-by: Mateusz Olczyk <molczyk@virtuslab.com>
Co-authored-by: Jay Conrod <jayconrod@gmail.com>
@mateusz-olczyk
Copy link
Copy Markdown
Contributor Author

I wasn't sure if "rules_proto" should also be removed from MODULE.bazel. It looks like bazel test //... passes after removing both "rules_proto" and "protobuf" from MODULE.bazel. But I see those may be required by the submodules: tests/bcr/go_mod and tests/bcr/go_work.

Please update tests/bcr/go_mod/MODULE.bazel and tests/bcr/go_work/MODULE.bazel to depend on protobuf rather than rules_proto. These are end-to-end tests that run Gazelle in a fake repo and verify that it generates real targets that can be built. There are .proto files here.

Let's drop the rules_proto dependency from the main MODULE.bazel completely. Gazelle itself doesn't have .proto files or proto_library targets, so we don't need it. (I think... perhaps CI will prove me wrong.)

Done 👍

Signed-off-by: Mateusz Olczyk <molczyk@virtuslab.com>
Signed-off-by: Mateusz Olczyk <molczyk@virtuslab.com>
Copy link
Copy Markdown
Contributor

@jayconrod jayconrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One more minor comment.

Comment thread language/proto/fix.go Outdated
Comment thread language/proto/fix_test.go
@jayconrod jayconrod enabled auto-merge (squash) February 20, 2026 17:56
@jayconrod jayconrod merged commit 72178d1 into bazel-contrib:master Feb 20, 2026
15 checks passed
rdesgroppes added a commit to DataDog/datadog-agent that referenced this pull request Mar 2, 2026
What does this PR do?
Advances the gazelle git_override from Feb 13 to Feb 26, 2026
(6b2aeccd → a3e63b06).

Motivation
bazel-contrib/bazel-gazelle#2284 (Feb 20, 2026) switches the proto
language extension from the deprecated rules_proto module to the
protobuf module when generating proto_library load statements. Without
this, generated BUILD.bazel files carry a dependency on rules_proto
that should no longer be required.
gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/datadog-agent that referenced this pull request Mar 2, 2026
### What does this PR do?
Advance  `git_override` for `gazelle` from Feb 13 to Feb 26, 2026.

### Motivation
This eliminates a source of discrepancy when generating `BUILD.bazel` files dealing with code generation.

bazel-contrib/bazel-gazelle#2284 indeed switches the proto language extension from the _deprecated_ `rules_proto` module to the `protobuf` module when generating `load` statements for `proto_library`.

Without this, generated `BUILD.bazel` files carry a dependency on `rules_proto` that should no longer be required.

Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>
rdesgroppes added a commit to DataDog/datadog-agent that referenced this pull request Mar 26, 2026
### What does this PR do?
Bump `gazelle` from 0.47.0 to 0.48.0 and drop the `git_override` that
pinned to an unreleased commit on their `master`.

### Motivation
v0.48.0 ships both fixes the override was waiting for:
- bazel-contrib/bazel-gazelle#2274
- bazel-contrib/bazel-gazelle#2284

### Describe how you validated your changes
`bazel run //:gazelle` produces no change.
gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/datadog-agent that referenced this pull request Mar 26, 2026
### What does this PR do?
Bump `gazelle` from 0.47.0 to 0.48.0 and drop the `git_override` that pinned to an unreleased commit on their `master`.

### Motivation
v0.48.0 ships both fixes the override was waiting for:
- bazel-contrib/bazel-gazelle#2274
- bazel-contrib/bazel-gazelle#2284

### Describe how you validated your changes
`bazel run //:gazelle` produces no change.

Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Module "rules_proto" is deprecated

3 participants