Skip to content

Commit d1dcf3d

Browse files
mkruskal-googlecopybara-github
authored andcommitted
Update protobuf compatibility and add a dependency on Abseil
PiperOrigin-RevId: 516544976
1 parent f7dc11a commit d1dcf3d

21 files changed

+151
-104
lines changed

.github/workflows/ABCL-test.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ jobs:
3939
run: echo "::add-path:$GITHUB_WORKSPACE/quicklisp/local-projects/cl-protobufs/protoc/"
4040

4141
- name: Download and install protobuf
42-
run: git clone --recursive https://github.com/google/protobuf $GITHUB_WORKSPACE/protobuf && cd $GITHUB_WORKSPACE/protobuf && ./autogen.sh && ./configure --prefix=/usr/local && make && sudo make install && sudo ldconfig
42+
run: |
43+
set -ex
44+
git clone --recursive https://github.com/google/protobuf $GITHUB_WORKSPACE/protobuf
45+
cd $GITHUB_WORKSPACE/protobuf
46+
cmake . -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF -Dprotobuf_BUILD_EXAMPLES=OFF -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_CXX_STANDARD=14
47+
make -j20
48+
sudo make install
49+
sudo ldconfig
4350
4451
- name: Install protoc plug-in
4552
run: cd $GITHUB_WORKSPACE/quicklisp/local-projects/cl-protobufs/protoc && PROTOC_ROOT=/usr/local make

.github/workflows/CCL-test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ jobs:
5454
sudo ldconfig
5555
popd
5656
57+
- name: Download and install Abseil
58+
run: |
59+
set -ex
60+
git clone --recursive https://github.com/abseil/abseil-cpp $GITHUB_WORKSPACE/abseil-cpp
61+
cd $GITHUB_WORKSPACE/abseil-cpp
62+
cmake . -DCMAKE_CXX_STANDARD=14
63+
make -j20
64+
sudo make install
65+
sudo ldconfig
66+
5767
- name: Install protoc plug-in
5868
run: |
5969
cd $GITHUB_WORKSPACE/quicklisp/local-projects/cl-protobufs/protoc &&

.github/workflows/SBCL-test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ jobs:
5151
sudo ldconfig
5252
popd
5353
54+
- name: Download and install Abseil
55+
run: |
56+
set -ex
57+
git clone --recursive https://github.com/abseil/abseil-cpp $GITHUB_WORKSPACE/abseil-cpp
58+
cd $GITHUB_WORKSPACE/abseil-cpp
59+
cmake . -DCMAKE_CXX_STANDARD=14
60+
make -j20
61+
sudo make install
62+
sudo ldconfig
63+
5464
- name: Install protoc plug-in
5565
run: |
5666
cd $GITHUB_WORKSPACE/quicklisp/local-projects/cl-protobufs/protoc &&

protoc/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ INSTALL_ROOT ?= /usr/local/bin
1818
# ./configure when installing protobuf.
1919
PROTOC_ROOT ?= /usr/local
2020
PROTOC ?= $(PROTOC_ROOT)/bin/protoc
21+
PROTOC_DEPS ?= -lutf8_validity -lutf8_range -labsl_symbolize -labsl_bad_any_cast_impl -labsl_bad_optional_access -labsl_bad_variant_access -labsl_base -labsl_city -labsl_civil_time -labsl_cord -labsl_cord_internal -labsl_cordz_functions -labsl_cordz_handle -labsl_cordz_info -labsl_cordz_sample_token -labsl_crc32c -labsl_crc_cord_state -labsl_crc_cpu_detect -labsl_crc_internal -labsl_debugging_internal -labsl_demangle_internal -labsl_die_if_null -labsl_examine_stack -labsl_exponential_biased -labsl_failure_signal_handler -labsl_flags -labsl_flags_commandlineflag -labsl_flags_commandlineflag_internal -labsl_flags_config -labsl_flags_internal -labsl_flags_marshalling -labsl_flags_parse -labsl_flags_private_handle_accessor -labsl_flags_program_name -labsl_flags_reflection -labsl_flags_usage -labsl_flags_usage_internal -labsl_graphcycles_internal -labsl_hash -labsl_hashtablez_sampler -labsl_int128 -labsl_leak_check -labsl_log_entry -labsl_log_flags -labsl_log_globals -labsl_log_initialize -labsl_log_internal_check_op -labsl_log_internal_conditions -labsl_log_internal_format -labsl_log_internal_globals -labsl_log_internal_log_sink_set -labsl_log_internal_message -labsl_log_internal_nullguard -labsl_log_internal_proto -labsl_log_severity -labsl_log_sink -labsl_low_level_hash -labsl_malloc_internal -labsl_periodic_sampler -labsl_random_distributions -labsl_random_internal_distribution_test_util -labsl_random_internal_platform -labsl_random_internal_pool_urbg -labsl_random_internal_randen -labsl_random_internal_randen_hwaes -labsl_random_internal_randen_hwaes_impl -labsl_random_internal_randen_slow -labsl_random_internal_seed_material -labsl_random_seed_gen_exception -labsl_random_seed_sequences -labsl_raw_hash_set -labsl_raw_logging_internal -labsl_scoped_set_env -labsl_spinlock_wait -labsl_stacktrace -labsl_status -labsl_statusor -labsl_strerror -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_synchronization -labsl_throw_delegate -labsl_time -labsl_time_zone
2122

2223
OFILES = enum.o field.o file.o generator.o literals.o message.o \
2324
names.o service.o proto2-descriptor-extensions.o main.o
2425

2526
CXXFLAGS = -std=c++14 -I$(PROTOC_ROOT)/include -I.
26-
LIBS = -Wl,-L$(PROTOC_ROOT)/lib -Wl,-rpath -Wl,$(PROTOC_ROOT)/lib -lprotoc -lprotobuf -pthread
27+
LIBS = -Wl,-L$(PROTOC_ROOT)/lib -Wl,-rpath -Wl,$(PROTOC_ROOT)/lib -lprotoc -lprotobuf -pthread $(PROTOC_DEPS) $(PROTOC_DEPS)
2728

2829
protoc-gen-cl-pb: $(OFILES) Makefile
2930
$(CXX) $(OFILES) -o protoc-gen-cl-pb $(LIBS)

protoc/enum.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
#include "enum.h"
88

9-
#include <google/protobuf/stubs/strutil.h>
9+
#include "absl/strings/str_cat.h"
1010
#include "proto2-descriptor-extensions.pb.h"
1111
#include "names.h"
12-
#include <google/protobuf/io/printer.h>
12+
#include "google/protobuf/io/printer.h"
1313

1414
namespace google {
1515
namespace protobuf {
@@ -43,7 +43,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
4343
for (int i = 0; i < descriptor_->value_count(); i++) {
4444
printer->Print("\n(:$name$ :index $number$)", "name",
4545
ToLispEnumValue(descriptor_->value(i)->name()), "number",
46-
StrCat(descriptor_->value(i)->number()));
46+
absl::StrCat(descriptor_->value(i)->number()));
4747
printer->Annotate("name", descriptor_);
4848
}
4949
printer->Print(")");

protoc/enum.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <string>
1111
#include <vector>
1212

13-
#include <google/protobuf/descriptor.h>
14-
#include <google/protobuf/io/printer.h>
13+
#include "google/protobuf/descriptor.h"
14+
#include "google/protobuf/io/printer.h"
1515

1616
namespace google {
1717
namespace protobuf {

protoc/field.cc

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
#include <map>
1010

1111
#include <cstdint>
12-
#include <google/protobuf/stubs/logging.h>
13-
#include <google/protobuf/descriptor.pb.h>
14-
#include <google/protobuf/descriptor.h>
15-
#include <google/protobuf/extension_set.h>
16-
#include <google/protobuf/stubs/strutil.h>
12+
#include "absl/log/absl_log.h"
13+
#include "absl/strings/str_cat.h"
1714
#include "proto2-descriptor-extensions.pb.h"
1815
#include "literals.h"
1916
#include "names.h"
17+
#include "google/protobuf/descriptor.h"
18+
#include "google/protobuf/descriptor.pb.h"
19+
#include "google/protobuf/extension_set.h"
2020

2121
namespace google {
2222
namespace protobuf {
@@ -82,8 +82,8 @@ const std::string FieldLispType(const FieldDescriptor* field) {
8282
type = "cl-protobufs:sint64";
8383
break;
8484
default:
85-
GOOGLE_LOG(FATAL) << "Unsupported FileDescriptorType: "
86-
<< field->DebugString();
85+
ABSL_LOG(FATAL) << "Unsupported FileDescriptorType: "
86+
<< field->DebugString();
8787
break;
8888
}
8989
}
@@ -149,8 +149,8 @@ const std::string FieldLispKind(const FieldDescriptor* field) {
149149
proto_kind = ":enum";
150150
break;
151151
default:
152-
GOOGLE_LOG(FATAL) << "Unsupported FileDescriptorType: "
153-
<< field->DebugString();
152+
ABSL_LOG(FATAL) << "Unsupported FileDescriptorType: "
153+
<< field->DebugString();
154154
break;
155155
}
156156
return proto_kind;
@@ -178,7 +178,7 @@ const std::string FieldLispLabel(const FieldDescriptor* field) {
178178
}
179179
}
180180

181-
GOOGLE_LOG(FATAL) << "Error determining field arity: " << field->DebugString();
181+
ABSL_LOG(FATAL) << "Error determining field arity: " << field->DebugString();
182182
return "(:error)";
183183
}
184184

@@ -192,20 +192,20 @@ const std::string FieldLispDefault(const FieldDescriptor* field) {
192192
return LispBool(field->default_value_bool());
193193
case FieldDescriptor::CPPTYPE_ENUM: {
194194
const EnumValueDescriptor* value = field->default_value_enum();
195-
return StrCat(":", ToLispName(value->name()));
195+
return absl::StrCat(":", ToLispName(value->name()));
196196
}
197197
case FieldDescriptor::CPPTYPE_INT32:
198-
return StrCat(field->default_value_int32());
198+
return absl::StrCat(field->default_value_int32());
199199
case FieldDescriptor::CPPTYPE_UINT32:
200-
return StrCat(field->default_value_uint32());
200+
return absl::StrCat(field->default_value_uint32());
201201
case FieldDescriptor::CPPTYPE_INT64:
202-
return StrCat(field->default_value_int64());
202+
return absl::StrCat(field->default_value_int64());
203203
case FieldDescriptor::CPPTYPE_UINT64:
204-
return StrCat(field->default_value_uint64());
204+
return absl::StrCat(field->default_value_uint64());
205205
case FieldDescriptor::CPPTYPE_STRING: {
206206
switch (field->type()) {
207207
case FieldDescriptor::TYPE_BYTES:
208-
return StrCat(
208+
return absl::StrCat(
209209
"(cl:make-array ", field->default_value_string().size(),
210210
" :element-type '(cl:unsigned-byte 8)", " :initial-contents '(",
211211
StringOctets(field->default_value_string()), "))");
@@ -220,7 +220,7 @@ const std::string FieldLispDefault(const FieldDescriptor* field) {
220220
// Unsupported by cl_protobufs.
221221
// case FieldDescriptor::CPPTYPE_MESSAGE:
222222
// Report errors as early as possible.
223-
GOOGLE_LOG(FATAL) << "Unsupported FileDescriptorType: " << field->DebugString();
223+
ABSL_LOG(FATAL) << "Unsupported FileDescriptorType: " << field->DebugString();
224224
return "";
225225
}
226226
} // namespace
@@ -241,7 +241,7 @@ const std::string FieldLispName(const FieldDescriptor* field) {
241241
void GenerateField(io::Printer* printer, const FieldDescriptor* field) {
242242
std::map<std::string, std::string> vars;
243243
vars["name"] = FieldLispName(field);
244-
vars["tag"] = StrCat(field->number());
244+
vars["tag"] = absl::StrCat(field->number());
245245
vars["json-name"] = field->json_name();
246246
if (field->is_map()) {
247247
vars["key-type"] = FieldLispType(field->message_type()->field(0));
@@ -250,7 +250,7 @@ void GenerateField(io::Printer* printer, const FieldDescriptor* field) {
250250
vars["val-default"]
251251
= field->message_type()->field(1)->cpp_type()
252252
== FieldDescriptor::CPPTYPE_ENUM ?
253-
StrCat("\n :val-default ",
253+
absl::StrCat("\n :val-default ",
254254
FieldLispDefault(field->message_type()->field(1))) : "";
255255
printer->Print(vars,
256256
"\n(pi:define-map $name$\n"
@@ -268,7 +268,7 @@ void GenerateField(io::Printer* printer, const FieldDescriptor* field) {
268268
vars["default"] = field->has_default_value() ||
269269
(field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM &&
270270
field->label() != FieldDescriptor::Label::LABEL_REPEATED)
271-
? StrCat(" :default ", FieldLispDefault(field))
271+
? absl::StrCat(" :default ", FieldLispDefault(field))
272272
: "";
273273
printer->Print(vars,
274274
"\n($name$\n"

protoc/field.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <memory>
1111
#include <string>
1212

13-
#include <google/protobuf/descriptor.h>
14-
#include <google/protobuf/io/printer.h>
13+
#include "google/protobuf/descriptor.h"
14+
#include "google/protobuf/io/printer.h"
1515

1616
namespace google {
1717
namespace protobuf {

protoc/file.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
#include <memory>
1212
#include <set>
1313

14-
#include <google/protobuf/stubs/strutil.h>
14+
#include "absl/log/absl_log.h"
1515
#include "proto2-descriptor-extensions.pb.h"
1616
#include "enum.h"
1717
#include "field.h"
1818
#include "message.h"
1919
#include "names.h"
2020
#include "service.h"
21-
#include <google/protobuf/io/printer.h>
21+
#include "google/protobuf/io/printer.h"
2222

2323
namespace google {
2424
namespace protobuf {
@@ -53,7 +53,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file) :
5353
syntax_ = ":proto3";
5454
break;
5555
default:
56-
GOOGLE_LOG(FATAL) << "Unknown syntax for file: " << file->DebugString();
56+
ABSL_LOG(FATAL) << "Unknown syntax for file: " << file->DebugString();
5757
break;
5858
}
5959
}

protoc/file.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#include <string>
1212
#include <vector>
1313

14-
#include <google/protobuf/descriptor.pb.h>
15-
#include <google/protobuf/descriptor.h>
1614
#include "enum.h"
1715
#include "message.h"
1816
#include "service.h"
19-
#include <google/protobuf/io/printer.h>
17+
#include "google/protobuf/descriptor.h"
18+
#include "google/protobuf/descriptor.pb.h"
19+
#include "google/protobuf/io/printer.h"
2020

2121
namespace google {
2222
namespace protobuf {

protoc/generator.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
#include <unordered_set>
1111
#include <vector>
1212

13-
#include <google/protobuf/descriptor.h>
13+
#include "absl/log/absl_check.h"
1414
#include "file.h"
15-
#include <google/protobuf/io/printer.h>
16-
#include <google/protobuf/io/zero_copy_stream.h>
15+
#include "google/protobuf/descriptor.h"
16+
#include "google/protobuf/io/printer.h"
17+
#include "google/protobuf/io/zero_copy_stream.h"
1718

1819
namespace google {
1920
namespace protobuf {
@@ -59,7 +60,7 @@ bool LispGenerator::Generate(const FileDescriptor* file,
5960
if (annotate) {
6061
std::unique_ptr<io::ZeroCopyOutputStream> meta(
6162
output_directory->Open(file_name + ".meta"));
62-
GOOGLE_CHECK(annotations.SerializeToZeroCopyStream(meta.get()));
63+
ABSL_CHECK(annotations.SerializeToZeroCopyStream(meta.get()));
6364
}
6465

6566
return true;
@@ -132,7 +133,7 @@ bool LispGenerator::GenerateAll(const std::vector<const FileDescriptor*>& files,
132133
if (annotate) {
133134
std::unique_ptr<io::ZeroCopyOutputStream> meta(
134135
context->Open(file_name + ".meta"));
135-
GOOGLE_CHECK(annotations.SerializeToZeroCopyStream(meta.get()));
136+
ABSL_CHECK(annotations.SerializeToZeroCopyStream(meta.get()));
136137
}
137138
return true;
138139
}

protoc/generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <string>
1313
#include <vector>
1414

15-
#include <google/protobuf/compiler/code_generator.h>
15+
#include "google/protobuf/compiler/code_generator.h"
1616

1717
namespace google {
1818
class FileDescriptor;

0 commit comments

Comments
 (0)