From e26193d16868bcdb2616f551b6a17f8d641dddc4 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Tue, 20 Feb 2024 10:42:35 -0800 Subject: [PATCH] Add no-op support for the experimental_strip_nonfunctional_codegen parameter. This will be used for codegen tests to verify that an editions upgrade hasn't changed anything meaningful. PiperOrigin-RevId: 608660846 --- upb_generator/protoc-gen-upb.cc | 2 ++ upb_generator/protoc-gen-upb_minitable-main.cc | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/upb_generator/protoc-gen-upb.cc b/upb_generator/protoc-gen-upb.cc index 0235307a95..871819dd78 100644 --- a/upb_generator/protoc-gen-upb.cc +++ b/upb_generator/protoc-gen-upb.cc @@ -1106,6 +1106,8 @@ bool ParseOptions(Plugin* plugin, Options* options) { for (const auto& pair : ParseGeneratorParameter(plugin->parameter())) { if (pair.first == "bootstrap_upb") { options->bootstrap = true; + } else if (pair.first == "experimental_strip_nonfunctional_codegen") { + continue; } else { plugin->SetError(absl::Substitute("Unknown parameter: $0", pair.first)); return false; diff --git a/upb_generator/protoc-gen-upb_minitable-main.cc b/upb_generator/protoc-gen-upb_minitable-main.cc index ea73f9553d..5aa6fc5668 100644 --- a/upb_generator/protoc-gen-upb_minitable-main.cc +++ b/upb_generator/protoc-gen-upb_minitable-main.cc @@ -42,10 +42,13 @@ void GenerateFile(const DefPoolPair& pools, upb::FileDefPtr file, } bool ParseOptions(Plugin* plugin) { - const auto param = ParseGeneratorParameter(plugin->parameter()); - if (!param.empty()) { - plugin->SetError(absl::Substitute("Unknown parameter: $0", param[0].first)); - return false; + for (const auto& pair : ParseGeneratorParameter(plugin->parameter())) { + if (pair.first == "experimental_strip_nonfunctional_codegen") { + continue; + } else { + plugin->SetError(absl::Substitute("Unknown parameter: $0", pair.first)); + return false; + } } return true;