1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
|
From 66a0b0d205224f63f19dd8f96abf9dcdc2112331 Mon Sep 17 00:00:00 2001
From: Xiangyu Chen <xiangyu.chen@windriver.com>
Date: Wed, 29 Mar 2023 14:25:17 +0800
Subject: [PATCH] add support of protobuf 4.22.x
after upgrade the protobuf to 4.22.x, the protobuf-c cannot compile anymore (#544) due to following changes:
1.protobuf using c++14, that cause the command_line_interface.h report error
2.protobuf using abseil-cpp library instead the trace API with GOOGLE_ header
3. removed GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
Upstream-Status: Pending [https://github.com/protobuf-c/protobuf-c/pull/548]
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
---
Makefile.am | 2 +-
configure.ac | 8 ++++++++
protoc-c/c_bytes_field.h | 1 -
protoc-c/c_enum.h | 1 -
protoc-c/c_enum_field.h | 1 -
protoc-c/c_extension.h | 1 -
protoc-c/c_field.cc | 2 +-
protoc-c/c_field.h | 3 ---
protoc-c/c_file.h | 1 -
protoc-c/c_generator.h | 2 --
protoc-c/c_helpers.cc | 4 ++--
protoc-c/c_message.cc | 4 ++--
protoc-c/c_message.h | 1 -
protoc-c/c_message_field.h | 3 ---
protoc-c/c_primitive_field.cc | 6 +++---
protoc-c/c_primitive_field.h | 3 ---
protoc-c/c_service.h | 1 -
protoc-c/c_string_field.h | 1 -
18 files changed, 17 insertions(+), 28 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index c7339ef..3b0d1d6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,7 +20,7 @@ AM_CPPFLAGS = \
-I${top_builddir} \
-I${top_srcdir}
AM_CFLAGS = ${my_CFLAGS}
-AM_LDFLAGS =
+AM_LDFLAGS = ${ABSL_LOG_INTERNAL_CHECK_OP_LIBS} ${ABSL_LOG_RAW_HASH_SET_LIBS}
# code coverage
diff --git a/configure.ac b/configure.ac
index f5a0261..8ed549a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,6 +78,14 @@ if test "x$enable_protoc" != "xno"; then
AX_CXX_COMPILE_STDCXX(11, noext, mandatory)
+# now checking 4.22.x protobuf, if so, set cxx as 14
+ AS_IF([pkg-config --atleast-version 4.22.0 protobuf],[AX_CXX_COMPILE_STDCXX(14, noext, mandatory)])
+
+ AS_IF([pkg-config --atleast-version 4.22.0 protobuf],
+ [PKG_CHECK_MODULES([ABSL_LOG_INTERNAL_CHECK_OP], [absl_log_internal_check_op],
+ [PKG_CHECK_MODULES([ABSL_LOG_RAW_HASH_SET], [absl_raw_hash_set], [], [AC_MSG_ERROR([Missing absl_raw_hash_set library.])])],
+ [AC_MSG_ERROR([Missing absl_log_internal_check_op library.])])])
+
PKG_CHECK_MODULES([protobuf], [protobuf >= 3.0.0],
[proto3_supported=yes],
[PKG_CHECK_MODULES([protobuf], [protobuf >= 2.6.0])]
diff --git a/protoc-c/c_bytes_field.h b/protoc-c/c_bytes_field.h
index bf873f0..8fc63d3 100644
--- a/protoc-c/c_bytes_field.h
+++ b/protoc-c/c_bytes_field.h
@@ -88,7 +88,6 @@ class BytesFieldGenerator : public FieldGenerator {
private:
std::map<std::string, std::string> variables_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(BytesFieldGenerator);
};
diff --git a/protoc-c/c_enum.h b/protoc-c/c_enum.h
index 9c34b69..d5e58f0 100644
--- a/protoc-c/c_enum.h
+++ b/protoc-c/c_enum.h
@@ -107,7 +107,6 @@ class EnumGenerator {
const EnumDescriptor* descriptor_;
std::string dllexport_decl_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
};
} // namespace c
diff --git a/protoc-c/c_enum_field.h b/protoc-c/c_enum_field.h
index 3f8c005..03eb402 100644
--- a/protoc-c/c_enum_field.h
+++ b/protoc-c/c_enum_field.h
@@ -86,7 +86,6 @@ class EnumFieldGenerator : public FieldGenerator {
private:
std::map<std::string, std::string> variables_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);
};
diff --git a/protoc-c/c_extension.h b/protoc-c/c_extension.h
index 9541388..9c5797d 100644
--- a/protoc-c/c_extension.h
+++ b/protoc-c/c_extension.h
@@ -99,7 +99,6 @@ class ExtensionGenerator {
std::string type_traits_;
std::string dllexport_decl_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
};
} // namespace c
diff --git a/protoc-c/c_field.cc b/protoc-c/c_field.cc
index 0716744..4abdc6d 100644
--- a/protoc-c/c_field.cc
+++ b/protoc-c/c_field.cc
@@ -231,7 +231,7 @@ FieldGeneratorMap::~FieldGeneratorMap() {}
const FieldGenerator& FieldGeneratorMap::get(
const FieldDescriptor* field) const {
- GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);
+ ABSL_CHECK_EQ(field->containing_type(), descriptor_);
return *field_generators_[field->index()];
}
diff --git a/protoc-c/c_field.h b/protoc-c/c_field.h
index 3cad35d..76d3b0b 100644
--- a/protoc-c/c_field.h
+++ b/protoc-c/c_field.h
@@ -104,8 +104,6 @@ class FieldGenerator {
const std::string &descriptor_addr) const;
const FieldDescriptor *descriptor_;
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);
};
// Convenience class which constructs FieldGenerators for a Descriptor.
@@ -122,7 +120,6 @@ class FieldGeneratorMap {
static FieldGenerator* MakeGenerator(const FieldDescriptor* field);
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);
};
} // namespace c
diff --git a/protoc-c/c_file.h b/protoc-c/c_file.h
index 8dfd8ba..ec55906 100644
--- a/protoc-c/c_file.h
+++ b/protoc-c/c_file.h
@@ -104,7 +104,6 @@ class FileGenerator {
std::unique_ptr<std::unique_ptr<ServiceGenerator>[]> service_generators_;
std::unique_ptr<std::unique_ptr<ExtensionGenerator>[]> extension_generators_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);
};
} // namespace c
diff --git a/protoc-c/c_generator.h b/protoc-c/c_generator.h
index ac1ffaf..9260116 100644
--- a/protoc-c/c_generator.h
+++ b/protoc-c/c_generator.h
@@ -94,8 +94,6 @@ class PROTOC_C_EXPORT CGenerator : public CodeGenerator {
OutputDirectory* output_directory,
std::string* error) const;
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CGenerator);
};
} // namespace c
diff --git a/protoc-c/c_helpers.cc b/protoc-c/c_helpers.cc
index 6fd0cd3..1eaeeb4 100644
--- a/protoc-c/c_helpers.cc
+++ b/protoc-c/c_helpers.cc
@@ -286,7 +286,7 @@ const char* const kKeywordList[] = {
std::set<std::string> MakeKeywordsMap() {
std::set<std::string> result;
- for (int i = 0; i < GOOGLE_ARRAYSIZE(kKeywordList); i++) {
+ for (int i = 0; i < ABSL_ARRAYSIZE(kKeywordList); i++) {
result.insert(kKeywordList[i]);
}
return result;
@@ -548,7 +548,7 @@ std::string CEscape(const std::string& src) {
std::unique_ptr<char[]> dest(new char[dest_length]);
const int len = CEscapeInternal(src.data(), src.size(),
dest.get(), dest_length, false);
- GOOGLE_DCHECK_GE(len, 0);
+ ABSL_DCHECK_GE(len, 0);
return std::string(dest.get(), len);
}
diff --git a/protoc-c/c_message.cc b/protoc-c/c_message.cc
index 37e8bf8..c7e8515 100755
--- a/protoc-c/c_message.cc
+++ b/protoc-c/c_message.cc
@@ -499,7 +499,7 @@ GenerateMessageDescriptor(io::Printer* printer, bool gen_init) {
// NOTE: not supported by protobuf
vars["maybe_static"] = "";
vars["field_dv_ctype"] = "{ ... }";
- GOOGLE_LOG(DFATAL) << "Messages can't have default values!";
+ ABSL_LOG(FATAL) << "Messages can't have default values!";
break;
case FieldDescriptor::CPPTYPE_STRING:
if (fd->type() == FieldDescriptor::TYPE_BYTES || opt.string_as_bytes())
@@ -521,7 +521,7 @@ GenerateMessageDescriptor(io::Printer* printer, bool gen_init) {
break;
}
default:
- GOOGLE_LOG(DFATAL) << "Unknown CPPTYPE";
+ ABSL_LOG(FATAL) << "Unknown CPPTYPE";
break;
}
if (!already_defined)
diff --git a/protoc-c/c_message.h b/protoc-c/c_message.h
index ea1c3ab..e90782b 100644
--- a/protoc-c/c_message.h
+++ b/protoc-c/c_message.h
@@ -137,7 +137,6 @@ class MessageGenerator {
std::unique_ptr<std::unique_ptr<EnumGenerator>[]> enum_generators_;
std::unique_ptr<std::unique_ptr<ExtensionGenerator>[]> extension_generators_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
};
} // namespace c
diff --git a/protoc-c/c_message_field.h b/protoc-c/c_message_field.h
index 39b8d99..42efe36 100644
--- a/protoc-c/c_message_field.h
+++ b/protoc-c/c_message_field.h
@@ -83,9 +83,6 @@ class MessageFieldGenerator : public FieldGenerator {
std::string GetDefaultValue(void) const;
void GenerateStaticInit(io::Printer* printer) const;
- private:
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);
};
diff --git a/protoc-c/c_primitive_field.cc b/protoc-c/c_primitive_field.cc
index 6990893..d5a7b60 100644
--- a/protoc-c/c_primitive_field.cc
+++ b/protoc-c/c_primitive_field.cc
@@ -99,7 +99,7 @@ void PrimitiveFieldGenerator::GenerateStructMembers(io::Printer* printer) const
case FieldDescriptor::TYPE_STRING :
case FieldDescriptor::TYPE_BYTES :
case FieldDescriptor::TYPE_GROUP :
- case FieldDescriptor::TYPE_MESSAGE : GOOGLE_LOG(FATAL) << "not a primitive type"; break;
+ case FieldDescriptor::TYPE_MESSAGE : ABSL_LOG(FATAL) << "not a primitive type"; break;
// No default because we want the compiler to complain if any new
// types are added.
@@ -143,7 +143,7 @@ std::string PrimitiveFieldGenerator::GetDefaultValue() const
case FieldDescriptor::CPPTYPE_BOOL:
return descriptor_->default_value_bool() ? "1" : "0";
default:
- GOOGLE_LOG(DFATAL) << "unexpected CPPTYPE in c_primitive_field";
+ ABSL_LOG(FATAL) << "unexpected CPPTYPE in c_primitive_field";
return "UNEXPECTED_CPPTYPE";
}
}
@@ -197,7 +197,7 @@ void PrimitiveFieldGenerator::GenerateDescriptorInitializer(io::Printer* printer
case FieldDescriptor::TYPE_STRING :
case FieldDescriptor::TYPE_BYTES :
case FieldDescriptor::TYPE_GROUP :
- case FieldDescriptor::TYPE_MESSAGE : GOOGLE_LOG(FATAL) << "not a primitive type"; break;
+ case FieldDescriptor::TYPE_MESSAGE : ABSL_LOG(FATAL) << "not a primitive type"; break;
// No default because we want the compiler to complain if any new
// types are added.
diff --git a/protoc-c/c_primitive_field.h b/protoc-c/c_primitive_field.h
index a9eb893..d2bb724 100644
--- a/protoc-c/c_primitive_field.h
+++ b/protoc-c/c_primitive_field.h
@@ -83,9 +83,6 @@ class PrimitiveFieldGenerator : public FieldGenerator {
std::string GetDefaultValue(void) const;
void GenerateStaticInit(io::Printer* printer) const;
- private:
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);
};
} // namespace c
diff --git a/protoc-c/c_service.h b/protoc-c/c_service.h
index 27125a6..4737ff3 100644
--- a/protoc-c/c_service.h
+++ b/protoc-c/c_service.h
@@ -101,7 +101,6 @@ class ServiceGenerator {
const ServiceDescriptor* descriptor_;
std::map<std::string, std::string> vars_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);
};
} // namespace c
diff --git a/protoc-c/c_string_field.h b/protoc-c/c_string_field.h
index 513cea7..ba258e4 100644
--- a/protoc-c/c_string_field.h
+++ b/protoc-c/c_string_field.h
@@ -88,7 +88,6 @@ class StringFieldGenerator : public FieldGenerator {
private:
std::map<std::string, std::string> variables_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator);
};
--
2.34.1
|