From 2051716eb8310db2dea16a3b1a8b11ca497f0cbf Mon Sep 17 00:00:00 2001 From: Jiacheng Lu Date: Tue, 29 Oct 2024 18:10:45 +0000 Subject: [PATCH] pw_protobuf_compiler: GN no oneof callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow downstream GN based project to keep using the old oneof interfaces. Change-Id: Iaec07014ddf8653ab49ab01429967922b932449e Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/245272 Commit-Queue: Alexei Frolov Docs-Not-Needed: Alexei Frolov Reviewed-by: Alexei Frolov Lint: Lint 🤖 Presubmit-Verified: CQ Bot Account --- pw_protobuf_compiler/proto.gni | 3 +++ pw_protobuf_compiler/toolchain.gni | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/pw_protobuf_compiler/proto.gni b/pw_protobuf_compiler/proto.gni index 9056b2234..7c199e5e0 100644 --- a/pw_protobuf_compiler/proto.gni +++ b/pw_protobuf_compiler/proto.gni @@ -116,6 +116,9 @@ template("_pw_invoke_protoc") { if (pw_protobuf_compiler_NO_GENERIC_OPTIONS_FILES) { args += [ "--pwpb-no-generic-options-files" ] } + if (pw_protobuf_compiler_NO_ONEOF_CALLBACKS) { + args += [ "--pwpb-no-oneof-callbacks" ] + } if (pw_protobuf_compiler_PROTOC_TARGET != "") { assert( pw_protobuf_compiler_PROTOC_BINARY != "", diff --git a/pw_protobuf_compiler/toolchain.gni b/pw_protobuf_compiler/toolchain.gni index c9c20b000..ae6374609 100644 --- a/pw_protobuf_compiler/toolchain.gni +++ b/pw_protobuf_compiler/toolchain.gni @@ -30,4 +30,8 @@ declare_args() { # If true, requires the use of the `.pwpb_options` extensions for pw_protobuf # options files. If false, allows the generic `.options` to be used as well. pw_protobuf_compiler_NO_GENERIC_OPTIONS_FILES = false + + # If true, disables using callback interfaces for oneof fields, and keep the + # legacy "oneof as struct member" interface. + pw_protobuf_compiler_NO_ONEOF_CALLBACKS = false }