SIGN IN SIGN UP

Protocol Buffers - Google's data interchange format

0 0 84 C++

feat: `--<lang>_prefix` cli option (#24824)

Closes https://github.com/protocolbuffers/protobuf/issues/23509

# Description

- Add per-plugin `--<lang>_prefix=COMMAND` flag to `protoc`, allowing a plugin to be invoked through a user-supplied command wrapper.
- `<lang>` matches the plugin used by `--<lang>_out`, so different plugins can use different wrappers in a single invocation.
- protoc executes `COMMAND <plugin>`; COMMAND's first token is resolved via the search path (PATH), the value is tokenized on whitespace into argv, and quotes are rejected at parse time. Use a wrapper script for more complex invocations.
- Wrapper still honours custom plugin paths set with `--plugin`.
- Cross-platform tests (POSIX shell scripts; Windows `.bat`) cover happy-path invocation, argument forwarding, PATH-based resolution, missing executable, duplicate flags, empty values, and quote rejection.

# Naming

Earlier revisions of this PR used a single global `--plugin-command-prefix` flag. Per https://github.com/protocolbuffers/protobuf/issues/23509#issuecomment-3478221497, this PR now uses per-plugin `--<lang>_prefix` to match the existing `--<lang>_out` / `--<lang>_opt` convention.

# Testing

I've tested this in https://github.com/status-im/status-go with this command in `messaging/layers/encryption/`:
```
protoc --go_prefix="go tool" --go_out=. ./messaging/layers/encryption/protocol_message.proto
```

Closes #24824

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/24824 from igor-sirotin:main d68d58819f1fbf90644a0cce3f4685a7d9c2a980
PiperOrigin-RevId: 917294550
I
Igor Sirotin committed
92dd27ccf0c5c674b48de48310e0ebf45d0d5b88
Parent: ea4cdef
Committed by Copybara-Service <copybara-worker@google.com> on 5/18/2026, 5:05:37 PM