diff options
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_file.cc')
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_file.cc | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 414da2f8..1e80715d 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -256,6 +256,8 @@ void FileGenerator::GenerateProtoHeader(io::Printer* printer, GenerateHeader(printer); + IncludeFile("net/proto2/public/port_undef.inc", printer); + GenerateBottomHeaderGuard(printer, filename_identifier); } @@ -425,20 +427,6 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* printer) { } } - // TODO(gerbens) Remove this when all code in google is using the same - // proto library. This is a temporary hack to force build errors if - // the proto library is compiled with GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS - // and is also linking internal proto2. This is to prevent regressions while - // we work cleaning up the code base. After this is completed and we have - // one proto lib all code uses this should be removed. - if (options_.opensource_runtime) { - format( - "// This is a temporary google only hack\n" - "#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS\n" - "#include \"third_party/protobuf/version.h\"\n" - "#endif\n"); - } - format("// @@protoc_insertion_point(includes)\n"); IncludeFile("net/proto2/public/port_def.inc", printer); } @@ -702,6 +690,8 @@ void FileGenerator::GenerateSource(io::Printer* printer) { format( "\n" "// @@protoc_insertion_point(global_scope)\n"); + + IncludeFile("net/proto2/public/port_undef.inc", printer); } void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { @@ -751,7 +741,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { format( "\n" "const $uint32$ $tablename$::offsets[] " - "$GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n"); + "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); format.Indent(); std::vector<std::pair<size_t, size_t> > pairs; pairs.reserve(message_generators_.size()); @@ -762,7 +752,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { format( "};\n" "static const ::$proto_ns$::internal::MigrationSchema schemas[] " - "$GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n"); + "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); format.Indent(); { int offset = 0; @@ -958,7 +948,7 @@ void FileGenerator::GenerateTables(io::Printer* printer) { format( "PROTOBUF_CONSTEXPR_VAR ::$proto_ns$::internal::ParseTableField\n" " const $tablename$::entries[] " - "$GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n"); + "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); format.Indent(); std::vector<size_t> entries; @@ -981,7 +971,7 @@ void FileGenerator::GenerateTables(io::Printer* printer) { "PROTOBUF_CONSTEXPR_VAR " "::$proto_ns$::internal::AuxillaryParseTableField\n" " const $tablename$::aux[] " - "$GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n"); + "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); format.Indent(); std::vector<size_t> aux_entries; @@ -1001,7 +991,7 @@ void FileGenerator::GenerateTables(io::Printer* printer) { "};\n" "PROTOBUF_CONSTEXPR_VAR ::$proto_ns$::internal::ParseTable const\n" " $tablename$::schema[] " - "$GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {\n"); + "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); format.Indent(); size_t offset = 0; @@ -1199,25 +1189,25 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { } if (options_.opensource_runtime) { - DoIncludeFile("net/proto2/public/stubs/common.h", false, printer); - // Verify the protobuf library header version is compatible with the protoc // version before going any further. + IncludeFile("net/proto2/public/port_def.inc", printer); format( - "#if GOOGLE_PROTOBUF_VERSION < $1$\n" + "#if PROTOBUF_VERSION < $1$\n" "#error This file was generated by a newer version of protoc which is\n" "#error incompatible with your Protocol Buffer headers. Please update\n" "#error your headers.\n" "#endif\n" - "#if $2$ < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n" + "#if $2$ < PROTOBUF_MIN_PROTOC_VERSION\n" "#error This file was generated by an older version of protoc which " "is\n" "#error incompatible with your Protocol Buffer headers. Please\n" "#error regenerate this file with a newer version of protoc.\n" "#endif\n" "\n", - GOOGLE_PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC, // 1 - GOOGLE_PROTOBUF_VERSION); // 2 + PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC, // 1 + PROTOBUF_VERSION); // 2 + IncludeFile("net/proto2/public/port_undef.inc", printer); } // OK, it's now safe to #include other files. @@ -1341,11 +1331,11 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( // These tables describe how to serialize and parse messages. Used // for table driven code. " static const ::$proto_ns$::internal::ParseTableField entries[]\n" - " $GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);\n" + " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n" " static const ::$proto_ns$::internal::AuxillaryParseTableField aux[]\n" - " $GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);\n" + " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n" " static const ::$proto_ns$::internal::ParseTable schema[$1$]\n" - " $GOOGLE_PROTOBUF$_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold);\n" + " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n" " static const ::$proto_ns$::internal::FieldMetadata field_metadata[];\n" " static const ::$proto_ns$::internal::SerializationTable " "serialization_table[];\n" |