Internal change

PiperOrigin-RevId: 586770525
pull/14887/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent 4d31a3451b
commit bcd41429c9
  1. 1
      src/google/protobuf/compiler/allowlists/BUILD.bazel
  2. 32
      src/google/protobuf/compiler/allowlists/editions.cc
  3. 11
      src/google/protobuf/compiler/command_line_interface.cc

@ -21,7 +21,6 @@ cc_library(
cc_library(
name = "allowlists",
srcs = [
"editions.cc",
"empty_package.cc",
"open_enum.cc",
],

@ -1,32 +0,0 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google LLC. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "absl/strings/string_view.h"
#include "google/protobuf/compiler/allowlists/allowlist.h"
#include "google/protobuf/compiler/allowlists/allowlists.h"
namespace google {
namespace protobuf {
namespace compiler {
// NOTE: These files have early default access to go/editions. The protoc flag
// `--experimental_editions` can also be used to enable editions.
static constexpr auto kEarlyEditionsFile = internal::MakeAllowlist(
{
// Intentionally left blank.
"google/protobuf/",
"upb/",
},
internal::AllowlistFlags::kMatchPrefix);
bool IsEarlyEditionsFile(absl::string_view file) {
return kEarlyEditionsFile.Allows(file);
}
} // namespace compiler
} // namespace protobuf
} // namespace google

@ -1598,7 +1598,9 @@ bool CommandLineInterface::ParseInputFiles(
}
parsed_files->push_back(parsed_file);
if (!experimental_editions_ && !IsEarlyEditionsFile(parsed_file->name())) {
if (!experimental_editions_ &&
!absl::StartsWith(parsed_file->name(), "google/protobuf/") &&
!absl::StartsWith(parsed_file->name(), "upb/")) {
if (FileDescriptorLegacy(parsed_file).syntax() ==
FileDescriptorLegacy::Syntax::SYNTAX_EDITIONS) {
std::cerr
@ -2563,9 +2565,10 @@ bool CommandLineInterface::EnforceEditionsSupport(
continue;
}
// Skip enforcement for allowlisted files.
if (IsEarlyEditionsFile(fd->name())) continue;
if (absl::StartsWith(fd->name(), "google/protobuf/") ||
absl::StartsWith(fd->name(), "upb/")) {
continue;
}
if ((supported_features & CodeGenerator::FEATURE_SUPPORTS_EDITIONS) == 0) {
std::cerr << absl::Substitute(
"$0: is an editions file, but code generator $1 hasn't been "

Loading…
Cancel
Save