aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs
diff options
context:
space:
mode:
authorinnokentii <innokentii@yandex-team.com>2024-02-16 20:10:55 +0300
committerinnokentii <innokentii@yandex-team.com>2024-02-16 20:25:26 +0300
commit3ce9cf4c333518fc721cc89f404c835ba63411d8 (patch)
tree4e48459e2137197712dea748393473287e70ec26 /contrib/libs
parentce3d6ca3ea728ae0ddc30aba2e1ee88a6f79985a (diff)
downloadydb-3ce9cf4c333518fc721cc89f404c835ba63411d8.tar.gz
Make PROTOC_TRANSITIVE_HEADERS=no compatible with GRPC()
add new deps to protobuf out done with grpc done with pb fix add patch to make intransitive pb compatible with grpc 60ab6319b92d29a98a74971c6906cd8eea1aab1e
Diffstat (limited to 'contrib/libs')
-rw-r--r--contrib/libs/grpc/src/compiler/cpp_generator.cc3
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc19
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h5
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc19
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h3
5 files changed, 42 insertions, 7 deletions
diff --git a/contrib/libs/grpc/src/compiler/cpp_generator.cc b/contrib/libs/grpc/src/compiler/cpp_generator.cc
index 52e3a61ac6..d8e4b3b609 100644
--- a/contrib/libs/grpc/src/compiler/cpp_generator.cc
+++ b/contrib/libs/grpc/src/compiler/cpp_generator.cc
@@ -114,6 +114,9 @@ TString GetHeaderPrologue(grpc_generator::File* file,
printer->Print(vars, "#pragma GCC system_header\n");
printer->Print(vars, "#endif\n");
printer->Print(vars, "\n");
+ printer->Print(vars, "#if __has_include(\"$filename_base$.deps$message_header_ext$\")\n");
+ printer->Print(vars, "#include \"$filename_base$.deps$message_header_ext$\"\n");
+ printer->Print(vars, "#endif\n");
printer->Print(vars, "#include \"$filename_base$$message_header_ext$\"\n");
printer->Print(vars, file->additional_headers().c_str());
printer->Print(vars, "\n");
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc
index 681e16a947..2a98ad0b02 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc
@@ -317,6 +317,17 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer,
GenerateBottomHeaderGuard(printer, true);
}
+void FileGenerator::GeneratePBDeps(io::Printer* printer,
+ const TProtoStringType& info_path) {
+ Formatter format(printer, variables_);
+
+ GenerateTopHeaderGuard(printer, true, true);
+
+ GenerateDependencyIncludes(printer);
+
+ GenerateBottomHeaderGuard(printer, true, true);
+}
+
void FileGenerator::DoIncludeFile(const TProtoStringType& google3_name,
bool do_export, io::Printer* printer) {
Formatter format(printer, variables_);
@@ -1142,7 +1153,7 @@ void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) {
format("PROTOBUF_NAMESPACE_CLOSE\n");
}
-void FileGenerator::GenerateTopHeaderGuard(io::Printer* printer, bool pb_h) {
+void FileGenerator::GenerateTopHeaderGuard(io::Printer* printer, bool pb_h, bool deps) {
Formatter format(printer, variables_);
// Generate top of header.
format(
@@ -1154,7 +1165,7 @@ void FileGenerator::GenerateTopHeaderGuard(io::Printer* printer, bool pb_h) {
"\n"
"#include <limits>\n"
"#include <string>\n",
- IncludeGuard(file_, pb_h, options_));
+ IncludeGuard(file_, pb_h, deps, options_));
if (!options_.opensource_runtime && !enum_generators_.empty()) {
// Add header to provide std::is_integral for safe Enum_Name() function.
format("#include <type_traits>\n");
@@ -1162,10 +1173,10 @@ void FileGenerator::GenerateTopHeaderGuard(io::Printer* printer, bool pb_h) {
format("\n");
}
-void FileGenerator::GenerateBottomHeaderGuard(io::Printer* printer, bool pb_h) {
+void FileGenerator::GenerateBottomHeaderGuard(io::Printer* printer, bool pb_h, bool deps) {
Formatter format(printer, variables_);
format("#endif // $GOOGLE_PROTOBUF$_INCLUDED_$1$\n",
- IncludeGuard(file_, pb_h, options_));
+ IncludeGuard(file_, pb_h, deps, options_));
}
void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h
index 984bd26a31..041d5ea4ab 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h
@@ -80,6 +80,7 @@ class FileGenerator {
// info_path, if non-empty, should be the path (relative to printer's
// output) to the metadata file describing this PB header.
void GeneratePBHeader(io::Printer* printer, const TProtoStringType& info_path);
+ void GeneratePBDeps(io::Printer* printer, const TProtoStringType& info_path);
void GenerateSource(io::Printer* printer);
// The following member functions are used when the lite_implicit_weak_fields
@@ -133,8 +134,8 @@ class FileGenerator {
void GenerateForwardDeclarations(io::Printer* printer);
// Generates top or bottom of a header file.
- void GenerateTopHeaderGuard(io::Printer* printer, bool pb_h);
- void GenerateBottomHeaderGuard(io::Printer* printer, bool pb_h);
+ void GenerateTopHeaderGuard(io::Printer* printer, bool pb_h, bool deps = false);
+ void GenerateBottomHeaderGuard(io::Printer* printer, bool pb_h, bool deps = false);
// Generates #include directives.
void GenerateLibraryIncludes(io::Printer* printer);
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc
index 7fe7511d0d..3673c09a61 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc
@@ -214,6 +214,25 @@ bool CppGenerator::Generate(const FileDescriptor* file,
}
}
+ if (!file_options.transitive_pb_h) {
+ std::unique_ptr<io::ZeroCopyOutputStream> output(
+ generator_context->Open(basename + ".deps.pb.h"));
+ GeneratedCodeInfo annotations;
+ io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
+ &annotations);
+ TProtoStringType info_path = basename + ".deps.pb.h.meta";
+ io::Printer printer(
+ output.get(), '$',
+ file_options.annotate_headers ? &annotation_collector : NULL);
+ file_generator.GeneratePBDeps(
+ &printer, file_options.annotate_headers ? info_path : "");
+ if (file_options.annotate_headers) {
+ std::unique_ptr<io::ZeroCopyOutputStream> info_output(
+ generator_context->Open(info_path));
+ annotations.SerializeToZeroCopyStream(info_output.get());
+ }
+ }
+
// Generate cc file(s).
if (UsingImplicitWeakFields(file, file_options)) {
{
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
index 12c8cdbde1..ceb9a54f38 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
@@ -478,11 +478,12 @@ bool IsAnyMessage(const Descriptor* descriptor, const Options& options);
bool IsWellKnownMessage(const FileDescriptor* descriptor);
inline TProtoStringType IncludeGuard(const FileDescriptor* file, bool pb_h,
+ bool deps,
const Options& options) {
// If we are generating a .pb.h file and the proto_h option is enabled, then
// the .pb.h gets an extra suffix.
TProtoStringType filename_identifier = FilenameIdentifier(
- file->name() + (pb_h && options.proto_h ? ".pb.h" : ""));
+ file->name() + (deps ? ".deps": "") + (pb_h && options.proto_h ? ".pb.h" : ""));
if (IsWellKnownMessage(file)) {
// For well-known messages we need third_party/protobuf and net/proto2 to