Skip to content

feat: --<lang>_prefix cli option#24824

Closed
igor-sirotin wants to merge 11 commits into
protocolbuffers:mainfrom
igor-sirotin:main
Closed

feat: --<lang>_prefix cli option#24824
igor-sirotin wants to merge 11 commits into
protocolbuffers:mainfrom
igor-sirotin:main

Conversation

@igor-sirotin

@igor-sirotin igor-sirotin commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

Closes #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 #23509 (comment), 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

@igor-sirotin
igor-sirotin marked this pull request as ready for review December 12, 2025 23:30
@igor-sirotin igor-sirotin changed the title feat: --plugin-command-prefix feat: --plugin-command-prefix Dec 12, 2025
@igor-sirotin

Copy link
Copy Markdown
Contributor Author

@mkruskal-google can you please take a look? Or ping someone who should review this, I'm not sure.

@karenwuz
karenwuz requested a review from mkruskal-google April 8, 2026 15:54
@karenwuz karenwuz added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Apr 8, 2026
@github-actions github-actions Bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Apr 8, 2026
@mkruskal-google mkruskal-google added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Apr 8, 2026
@mkruskal-google mkruskal-google added 🅰️ safe for tests Mark a commit as safe to run presubmits over and removed 🅰️ safe for tests Mark a commit as safe to run presubmits over labels Apr 28, 2026
@github-actions github-actions Bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Apr 28, 2026

@mkruskal-google mkruskal-google left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the long delay on this!

Comment thread src/google/protobuf/compiler/command_line_interface.cc Outdated
Comment thread src/google/protobuf/compiler/command_line_interface.cc Outdated
Comment thread src/google/protobuf/compiler/command_line_interface.cc Outdated
Comment thread src/google/protobuf/compiler/command_line_interface_unittest.cc Outdated
Comment thread src/google/protobuf/compiler/subprocess.cc Outdated
Comment thread src/google/protobuf/compiler/command_line_interface.cc Outdated
@igor-sirotin

Copy link
Copy Markdown
Contributor Author

@mkruskal-google Thank you for the comments, I've addressed all of them.
Please take another look when you have a moment

Comment thread src/google/protobuf/compiler/command_line_interface.cc
Comment thread src/google/protobuf/compiler/command_line_interface_unittest.cc Outdated
Comment thread src/google/protobuf/compiler/command_line_interface.cc
@mkruskal-google mkruskal-google added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 2, 2026
@github-actions github-actions Bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 2, 2026
@mkruskal-google mkruskal-google added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 2, 2026
@github-actions github-actions Bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 2, 2026
@igor-sirotin

Copy link
Copy Markdown
Contributor Author

@mkruskal-google sorry for the delay, I addressed your last comments. Please take a look when you have a moment

@igor-sirotin igor-sirotin changed the title feat: --plugin-command-prefix feat: --<lang>_prefix cli option May 9, 2026
@igor-sirotin

Copy link
Copy Markdown
Contributor Author

Also updated PR name and description.

@JasonLunn JasonLunn added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 15, 2026
@github-actions github-actions Bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 15, 2026
@JasonLunn JasonLunn added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 15, 2026
@github-actions github-actions Bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 15, 2026
@JasonLunn

Copy link
Copy Markdown
Member

@igor-sirotin - can you take a look at the test failures we're seeing on Windows, e.g.:

[ RUN      ] CommandLineInterfaceTest.PluginPrefixForwardsArguments
src/google/protobuf/compiler/command_line_interface_tester.cc(131): error: Expected equality of these values:
  0
  return_code_
    Which is: 1

src/google/protobuf/compiler/command_line_interface_tester.cc(139): error: Value of: line
Expected: has substring "warning:"
  Actual: "'\"baz\"' is not recognized as an internal or external command,\r"

src/google/protobuf/compiler/command_line_interface_tester.cc(139): error: Value of: line
Expected: has substring "warning:"
  Actual: "operable program or batch file.\r"

src/google/protobuf/compiler/command_line_interface_tester.cc(139): error: Value of: line
Expected: has substring "warning:"
  Actual: "--plug_out: prefix-gen-plug: Plugin failed with status code 9009."

WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
F0000 00:00:1778868726.285409    6508 mock_code_generator.cc:124] Check failed: File::GetContents( absl::StrCat(output_directory, "/", GetOutputFileName(name, file)), &content, true) is OK (NOT_FOUND: Could not open file) 
*** Check failure stack trace: ***
    @   00007FF681E2561D  (unknown)

@igor-sirotin

Copy link
Copy Markdown
Contributor Author

can you take a look at the test failures we're seeing on Windows, e.g.:

@JasonLunn done! Hope it works now, unfortunately I don't have a Windows machine to verify it.

@JasonLunn JasonLunn added 🅰️ safe for tests Mark a commit as safe to run presubmits over and removed wait for user action labels May 16, 2026
@github-actions github-actions Bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 16, 2026
@JasonLunn
JasonLunn removed the request for review from mkruskal-google May 16, 2026 23:28
@JasonLunn JasonLunn added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 16, 2026
@github-actions github-actions Bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 16, 2026
@igor-sirotin

Copy link
Copy Markdown
Contributor Author

@mkruskal-google @JasonLunn is it good to go now?
I see there're some issues in feedback/copybara check, but I can't access details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support running Go generator as go tool protoc-gen-go

4 participants