Skip to content

Commit a85bfd8

Browse files
Add support for --rbs_out (#4382)
Originally in #4361, but we need to add our typical version checks and testing. Ref: https://github.com/protocolbuffers/protobuf/releases/tag/v34.0 Ref: protocolbuffers/protobuf#15633 Supersedes #4361.
1 parent de1d947 commit a85bfd8

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## [Unreleased]
44

5-
- No changes yet.
5+
- Add support for `--rbs_out` as a `protoc_builtin` plugin (requires protoc v34.0+).
66

77
## [v1.66.1] - 2026-03-09
88

private/buf/bufprotopluginexec/protoc_proxy_handler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ func (h *protocProxyHandler) Handle(
8888
if h.pluginName == "rust" && !getRustSupportedAsBuiltin(protocVersion) {
8989
return fmt.Errorf("rust is not supported for protoc version %s", versionString(protocVersion))
9090
}
91+
if h.pluginName == "rbs" && !getRbsSupportedAsBuiltin(protocVersion) {
92+
return fmt.Errorf("rbs is not supported for protoc version %s", versionString(protocVersion))
93+
}
9194
// When we create protocProxyHandlers in NewHandler, we always prefer protoc-gen-.* plugins
9295
// over builtin plugins, so we only get here if we did not find protoc-gen-js, so this
9396
// is an error

private/buf/bufprotopluginexec/version.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ func getRustSupportedAsBuiltin(version *pluginpb.Version) bool {
150150
return true
151151
}
152152

153+
// Is rbs supported as a builtin plugin?
154+
func getRbsSupportedAsBuiltin(version *pluginpb.Version) bool {
155+
if version.GetSuffix() == "buf" {
156+
return true
157+
}
158+
// rbs was added in protoc v34.0
159+
return version.GetMajor() >= 34
160+
}
161+
153162
// Is js supported as a builtin plugin?
154163
func getJSSupportedAsBuiltin(version *pluginpb.Version) bool {
155164
if version.GetSuffix() == "buf" {

private/buf/bufprotopluginexec/version_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ func TestGetRustSupportedAsBuiltin(t *testing.T) {
7575
assert.False(t, getRustSupportedAsBuiltin(newVersion(3, 14, 1, "")))
7676
}
7777

78+
func TestGetRbsSupportedAsBuiltin(t *testing.T) {
79+
t.Parallel()
80+
assert.True(t, getRbsSupportedAsBuiltin(newVersion(3, 11, 1, "buf")))
81+
assert.True(t, getRbsSupportedAsBuiltin(newVersion(34, 0, 0, "")))
82+
assert.True(t, getRbsSupportedAsBuiltin(newVersion(35, 0, 0, "")))
83+
assert.False(t, getRbsSupportedAsBuiltin(newVersion(33, 5, 0, "")))
84+
assert.False(t, getRbsSupportedAsBuiltin(newVersion(21, 1, 0, "")))
85+
}
86+
7887
func TestGetJSSupportedAsBuiltin(t *testing.T) {
7988
t.Parallel()
8089
assert.False(t, getJSSupportedAsBuiltin(newVersion(2, 11, 1, "")))

private/bufpkg/bufconfig/generate_plugin_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ var (
7070
"python": {},
7171
"pyi": {},
7272
"ruby": {},
73+
"rbs": {},
7374
"kotlin": {},
7475
"rust": {},
7576
}

0 commit comments

Comments
 (0)