mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-26 21:04:23 +08:00
Merge pull request #676 from protobuf-c/edmonds/protobuf2-removal
Remove protobuf 2.x support
This commit is contained in:
commit
94d8a28db5
48
Makefile.am
48
Makefile.am
@ -139,11 +139,13 @@ LOG_COMPILER = $(VALGRIND)
|
||||
check_PROGRAMS += \
|
||||
t/generated-code/test-generated-code \
|
||||
t/generated-code2/test-generated-code2 \
|
||||
t/generated-code3/test-generated-code3 \
|
||||
t/version/version
|
||||
|
||||
TESTS += \
|
||||
t/generated-code/test-generated-code \
|
||||
t/generated-code2/test-generated-code2 \
|
||||
t/generated-code3/test-generated-code3 \
|
||||
t/version/version
|
||||
|
||||
t_generated_code_test_generated_code_SOURCES = \
|
||||
@ -159,6 +161,16 @@ t_generated_code2_test_generated_code2_SOURCES = \
|
||||
t_generated_code2_test_generated_code2_LDADD = \
|
||||
protobuf-c/libprotobuf-c.la
|
||||
|
||||
t_generated_code3_test_generated_code3_CPPFLAGS = \
|
||||
-DPROTO3
|
||||
|
||||
t_generated_code3_test_generated_code3_SOURCES = \
|
||||
t/generated-code/test-generated-code.c \
|
||||
t/test-proto3.pb-c.c
|
||||
|
||||
t_generated_code3_test_generated_code3_LDADD = \
|
||||
protobuf-c/libprotobuf-c.la
|
||||
|
||||
noinst_PROGRAMS += \
|
||||
t/generated-code2/cxx-generate-packed-data
|
||||
|
||||
@ -185,6 +197,9 @@ t/test-full.pb-c.c t/test-full.pb-c.h: $(top_builddir)/protoc-c/protoc-gen-c$(EX
|
||||
t/test-full.pb.cc t/test-full.pb.h: @PROTOC@ $(top_srcdir)/t/test-full.proto
|
||||
$(AM_V_GEN)@PROTOC@ -I$(top_srcdir) --cpp_out=$(top_builddir) $(top_srcdir)/t/test-full.proto
|
||||
|
||||
t/test-proto3.pb-c.c t/test-proto3.pb-c.h: $(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) $(top_srcdir)/t/test-proto3.proto
|
||||
$(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/test-proto3.proto
|
||||
|
||||
t/generated-code2/test-full-cxx-output.inc: t/generated-code2/cxx-generate-packed-data$(EXEEXT)
|
||||
$(AM_V_GEN)$(top_builddir)/t/generated-code2/cxx-generate-packed-data$(EXEEXT) > $(top_builddir)/t/generated-code2/test-full-cxx-output.inc
|
||||
|
||||
@ -193,34 +208,9 @@ BUILT_SOURCES += \
|
||||
t/test-full.pb-c.c t/test-full.pb-c.h \
|
||||
t/test-optimized.pb-c.c t/test-optimized.pb-c.h \
|
||||
t/test-full.pb.cc t/test-full.pb.h \
|
||||
t/test-proto3.pb-c.c t/test-proto3.pb-c.h \
|
||||
t/generated-code2/test-full-cxx-output.inc
|
||||
|
||||
if BUILD_PROTO3
|
||||
|
||||
check_PROGRAMS += \
|
||||
t/generated-code3/test-generated-code3
|
||||
|
||||
TESTS += \
|
||||
t/generated-code3/test-generated-code3
|
||||
|
||||
t_generated_code3_test_generated_code3_CPPFLAGS = \
|
||||
-DPROTO3
|
||||
|
||||
t_generated_code3_test_generated_code3_LDADD = \
|
||||
protobuf-c/libprotobuf-c.la
|
||||
|
||||
t_generated_code3_test_generated_code3_SOURCES = \
|
||||
t/generated-code/test-generated-code.c \
|
||||
t/test-proto3.pb-c.c
|
||||
|
||||
t/test-proto3.pb-c.c t/test-proto3.pb-c.h: $(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) $(top_srcdir)/t/test-proto3.proto
|
||||
$(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/test-proto3.proto
|
||||
|
||||
BUILT_SOURCES += \
|
||||
t/test-proto3.pb-c.c t/test-proto3.pb-c.h
|
||||
|
||||
endif # BUILD_PROTO3
|
||||
|
||||
t_version_version_SOURCES = \
|
||||
t/version/version.c
|
||||
t_version_version_LDADD = \
|
||||
@ -278,7 +268,6 @@ EXTRA_DIST += \
|
||||
t/issue251/issue251.proto
|
||||
|
||||
# Issue #330
|
||||
if BUILD_PROTO3
|
||||
check_PROGRAMS += \
|
||||
t/issue330/issue330
|
||||
TESTS += \
|
||||
@ -292,6 +281,8 @@ t/issue330/issue330.pb-c.c t/issue330/issue330.pb-c.h: $(top_builddir)/protoc-c/
|
||||
$(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/issue330/issue330.proto
|
||||
BUILT_SOURCES += \
|
||||
t/issue330/issue330.pb-c.c t/issue330/issue330.pb-c.h
|
||||
EXTRA_DIST += \
|
||||
t/issue330/issue330.proto
|
||||
|
||||
t_issue330_issue330_SOURCES += \
|
||||
t/issue389/issue389.pb-c.c # Tack onto issue330 since there is no need for a separate binary here
|
||||
@ -317,9 +308,6 @@ BUILT_SOURCES += \
|
||||
t/issue440/issue440.pb-c.c t/issue440/issue440.pb-c.h
|
||||
EXTRA_DIST += \
|
||||
t/issue440/issue440.proto
|
||||
endif # BUILD_PROTO3
|
||||
EXTRA_DIST += \
|
||||
t/issue330/issue330.proto
|
||||
|
||||
# Issue #375
|
||||
check_PROGRAMS += \
|
||||
|
@ -9,7 +9,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)
|
||||
PROJECT(protobuf-c)
|
||||
|
||||
#options
|
||||
option(BUILD_PROTO3 "BUILD_PROTO3" ON)
|
||||
option(BUILD_PROTOC "Build protoc-gen-c" ON)
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
option(BUILD_TESTS "Build tests" ON)
|
||||
@ -73,9 +72,6 @@ endif (MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
FIND_PACKAGE(Protobuf REQUIRED)
|
||||
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
|
||||
|
||||
if (BUILD_PROTO3)
|
||||
ADD_DEFINITIONS(-DHAVE_PROTO3)
|
||||
endif()
|
||||
ENDIF()
|
||||
|
||||
if (MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
|
@ -69,14 +69,12 @@ if test -n "$PKG_CONFIG"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
proto3_supported="no"
|
||||
|
||||
AC_ARG_ENABLE([protoc],
|
||||
AS_HELP_STRING([--disable-protoc], [Disable building protoc_c (also disables tests)]))
|
||||
if test "x$enable_protoc" != "xno"; then
|
||||
AC_LANG_PUSH([C++])
|
||||
AX_CXX_COMPILE_STDCXX(17, noext, mandatory)
|
||||
PKG_CHECK_MODULES([protobuf], [protobuf >= 3.0.0], [proto3_supported=yes])
|
||||
PKG_CHECK_MODULES([protobuf], [protobuf >= 3.0.0])
|
||||
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$save_CPPFLAGS $protobuf_CFLAGS"
|
||||
@ -99,11 +97,8 @@ else
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([BUILD_COMPILER], [test "x$enable_protoc" != "xno"])
|
||||
AM_CONDITIONAL([BUILD_PROTO3], [test "x$proto3_supported" != "xno"])
|
||||
AM_CONDITIONAL([CROSS_COMPILING], [test "x$cross_compiling" != "xno"])
|
||||
|
||||
AM_COND_IF([BUILD_PROTO3], [AC_DEFINE([HAVE_PROTO3], [1], [Support proto3 syntax])])
|
||||
|
||||
gl_LD_VERSION_SCRIPT
|
||||
|
||||
gl_VALGRIND_TESTS
|
||||
|
@ -118,15 +118,13 @@ void FileGenerator::GenerateHeader(io::Printer* printer) {
|
||||
std::string filename_identifier = FilenameIdentifier(file_->name());
|
||||
|
||||
int min_header_version = 1000000;
|
||||
#if defined(HAVE_PROTO3)
|
||||
# if GOOGLE_PROTOBUF_VERSION >= 4023000
|
||||
#if GOOGLE_PROTOBUF_VERSION >= 4023000
|
||||
if (FileDescriptorLegacy(file_).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3) {
|
||||
# else
|
||||
#else
|
||||
if (file_->syntax() == FileDescriptor::SYNTAX_PROTO3) {
|
||||
#endif
|
||||
min_header_version = 1003000;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Generate top of header.
|
||||
printer->Print(
|
||||
|
@ -175,14 +175,10 @@ int compare_name_indices_by_name(const void*, const void*);
|
||||
// Return the syntax version of the file containing the field.
|
||||
// This wrapper is needed to be able to compile against protobuf2.
|
||||
inline int FieldSyntax(const FieldDescriptor* field) {
|
||||
#ifdef HAVE_PROTO3
|
||||
# if GOOGLE_PROTOBUF_VERSION >= 4023000
|
||||
#if GOOGLE_PROTOBUF_VERSION >= 4023000
|
||||
return FileDescriptorLegacy(field->file()).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3 ? 3 : 2;
|
||||
# else
|
||||
return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ? 3 : 2;
|
||||
# endif
|
||||
#else
|
||||
return 2;
|
||||
return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ? 3 : 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
syntax = "proto2";
|
||||
|
||||
import "protobuf-c/protobuf-c.proto";
|
||||
|
||||
option (pb_c_file).use_oneof_field_name = true;
|
||||
|
@ -1,3 +1,5 @@
|
||||
syntax = "proto2";
|
||||
|
||||
message TopLevel {
|
||||
oneof submessages {
|
||||
MessageType1 type1 = 1;
|
||||
|
@ -1,3 +1,5 @@
|
||||
syntax = "proto2";
|
||||
|
||||
message two_oneofs {
|
||||
oneof first_oneof {
|
||||
bool a = 10;
|
||||
|
@ -1,3 +1,5 @@
|
||||
syntax = "proto2";
|
||||
|
||||
package foo;
|
||||
|
||||
import "protobuf-c/protobuf-c.proto";
|
||||
|
@ -1,3 +1,5 @@
|
||||
syntax = "proto2";
|
||||
|
||||
package foo;
|
||||
|
||||
option optimize_for = CODE_SIZE;
|
||||
|
@ -1,3 +1,5 @@
|
||||
syntax = "proto2";
|
||||
|
||||
package foo;
|
||||
|
||||
import "protobuf-c/protobuf-c.proto";
|
||||
|
Loading…
x
Reference in New Issue
Block a user