Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
grpc: move protos to a separate library
Browse files Browse the repository at this point in the history
- when compiling protos into a shared library, the shared library can not
be reloaded: protocolbuffers/protobuf#4126

- it is not recommended to have multiple shared libraries with protos
  compiled in them: protocolbuffers/protobuf#1489

Signed-off-by: László Várady <[email protected]>
  • Loading branch information
MrAnno committed Jul 4, 2023
1 parent 4ac5826 commit fd547fa
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
url = https://github.com/buytenh/ivykis.git
ignore = dirty
[submodule "modules/grpc/otel/opentelemetry-proto"]
path = modules/grpc/otel/opentelemetry-proto
path = modules/grpc/protos/opentelemetry-proto
url = https://github.com/open-telemetry/opentelemetry-proto.git
2 changes: 2 additions & 0 deletions modules/grpc/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include modules/grpc/protos/Makefile.am

include modules/grpc/otel/Makefile.am

if ENABLE_GRPC
Expand Down
52 changes: 5 additions & 47 deletions modules/grpc/otel/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,46 +1,7 @@
OTEL_PROTO_SRCDIR = $(top_srcdir)/modules/grpc/otel/opentelemetry-proto
OTEL_PROTO_BUILDDIR = $(top_builddir)/modules/grpc/otel/proto

if ENABLE_GRPC

OTEL_PROTO_PROTOC_FLAGS = $(PROTOC_GEN_GRPC_CPP_PLUGIN_FLAGS) --proto_path=$(OTEL_PROTO_SRCDIR) --cpp_out=$(OTEL_PROTO_BUILDDIR)

modules/grpc/otel/proto/%.grpc.pb.cc modules/grpc/otel/proto/%.grpc.pb.h:
mkdir -p $(OTEL_PROTO_BUILDDIR)
$(PROTOC) $(OTEL_PROTO_PROTOC_FLAGS) --grpc-cpp_out=$(OTEL_PROTO_BUILDDIR) $*.proto

modules/grpc/otel/proto/%.pb.cc modules/grpc/otel/proto/%.pb.h:
mkdir -p $(OTEL_PROTO_BUILDDIR)
$(PROTOC) $(OTEL_PROTO_PROTOC_FLAGS) $*.proto

OTEL_PROTO_BUILT_SOURCES = \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/common/v1/common.pb.h \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/common/v1/common.pb.cc \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/resource/v1/resource.pb.h \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/resource/v1/resource.pb.cc \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/logs/v1/logs.pb.h \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/logs/v1/logs.pb.cc \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/metrics/v1/metrics.pb.h \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/metrics/v1/metrics.pb.cc \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/trace/v1/trace.pb.h \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/trace/v1/trace.pb.cc \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.h \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.cc \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/logs/v1/logs_service.pb.h \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/logs/v1/logs_service.pb.cc \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.cc \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.cc \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/trace/v1/trace_service.pb.h \
$(OTEL_PROTO_BUILDDIR)/opentelemetry/proto/collector/trace/v1/trace_service.pb.cc

noinst_LTLIBRARIES += modules/grpc/otel/libotel_cpp.la

nodist_modules_grpc_otel_libotel_cpp_la_SOURCES = $(OTEL_PROTO_BUILT_SOURCES)

modules_grpc_otel_libotel_cpp_la_SOURCES = \
modules/grpc/otel/otel-source.h \
modules/grpc/otel/otel-source.hpp \
Expand All @@ -58,7 +19,7 @@ modules_grpc_otel_libotel_cpp_la_CXXFLAGS = \
$(AM_CXXFLAGS) \
$(PROTOBUF_CFLAGS) \
$(GRPCPP_CFLAGS) \
-I$(OTEL_PROTO_BUILDDIR) \
-I$(OPENTELEMETRY_PROTO_BUILDDIR) \
-I$(top_srcdir)/modules/grpc/otel \
-I$(top_builddir)/modules/grpc/otel

Expand All @@ -85,36 +46,33 @@ modules_grpc_otel_libotel_la_CPPFLAGS = \

modules_grpc_otel_libotel_la_LIBADD = \
$(MODULE_DEPS_LIBS) \
$(top_builddir)/modules/grpc/protos/libgrpc-protos.la \
$(top_builddir)/modules/grpc/otel/libotel_cpp.la \
-lstdc++

modules_grpc_otel_libotel_la_LDFLAGS = $(MODULE_LDFLAGS)

modules_grpc_otel_libotel_la_DEPENDENCIES = \
$(MODULE_DEPS_LIBS) \
$(top_builddir)/modules/grpc/protos/libgrpc-protos.la \
$(top_builddir)/modules/grpc/otel/libotel_cpp.la

modules/grpc/otel modules/grpc/otel/ mod-otel: modules/grpc/otel/libotel.la
else
modules/grpc/otel modules/grpc/otel/ mod-otel:
endif

CLEANFILES += \
$(OTEL_PROTO_BUILT_SOURCES)

BUILT_SOURCES += \
modules/grpc/otel/otel-grammar.y \
modules/grpc/otel/otel-grammar.c \
modules/grpc/otel/otel-grammar.h \
$(OTEL_PROTO_BUILT_SOURCES)
modules/grpc/otel/otel-grammar.h

NODIST_BUILT_SOURCES += \
$(OTEL_PROTO_BUILT_SOURCES)

EXTRA_DIST += \
modules/grpc/otel/otel-grammar.ym \
modules/grpc/otel/CMakeLists.txt \
$(OTEL_PROTO_SRCDIR)
modules/grpc/otel/CMakeLists.txt

.PHONY: modules/grpc/otel/ mod-otel

Expand Down
66 changes: 66 additions & 0 deletions modules/grpc/protos/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
GRPC_PROTOS_SRCDIR = $(top_srcdir)/modules/grpc/protos
GRPC_PROTOS_BUILDDIR = $(top_builddir)/modules/grpc/protos

if ENABLE_GRPC

OPENTELEMETRY_PROTO_SRCDIR = $(GRPC_PROTOS_SRCDIR)/opentelemetry-proto
OPENTELEMETRY_PROTO_BUILDDIR = $(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto

OPENTELEMETRY_PROTO_PROTOC_FLAGS = $(PROTOC_GEN_GRPC_CPP_PLUGIN_FLAGS) --proto_path=$(OPENTELEMETRY_PROTO_SRCDIR) --cpp_out=$(OPENTELEMETRY_PROTO_BUILDDIR)

modules/grpc/protos/opentelemetry-proto/%.grpc.pb.cc modules/grpc/protos/opentelemetry-proto/%.grpc.pb.h:
mkdir -p $(OPENTELEMETRY_PROTO_BUILDDIR)
$(PROTOC) $(OPENTELEMETRY_PROTO_PROTOC_FLAGS) --grpc-cpp_out=$(OPENTELEMETRY_PROTO_BUILDDIR) $*.proto

modules/grpc/protos/opentelemetry-proto/%.pb.cc modules/grpc/protos/opentelemetry-proto/%.pb.h:
mkdir -p $(OPENTELEMETRY_PROTO_BUILDDIR)
$(PROTOC) $(OPENTELEMETRY_PROTO_PROTOC_FLAGS) $*.proto

GRPC_PROTOS_BUILT_SOURCES = \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/common/v1/common.pb.h \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/common/v1/common.pb.cc \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.pb.h \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.pb.cc \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/logs/v1/logs.pb.h \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/logs/v1/logs.pb.cc \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.pb.h \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.pb.cc \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/trace/v1/trace.pb.h \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/trace/v1/trace.pb.cc \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.h \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.cc \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/logs/v1/logs_service.pb.h \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/logs/v1/logs_service.pb.cc \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.cc \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.cc \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.pb.h \
$(GRPC_PROTOS_BUILDDIR)/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.pb.cc

lib_LTLIBRARIES += modules/grpc/protos/libgrpc-protos.la

nodist_modules_grpc_protos_libgrpc_protos_la_SOURCES = $(GRPC_PROTOS_BUILT_SOURCES)

modules_grpc_protos_libgrpc_protos_la_CXXFLAGS = \
$(AM_CXXFLAGS) \
$(PROTOBUF_CLFAGS) \
$(GRPCPP_CFLAGS) \
-I$(OPENTELEMETRY_PROTO_SRCDIR) \
-I$(OPENTELEMETRY_PROTO_BUILDDIR)

modules_grpc_protos_libgrpc_protos_la_LIBADD = $(MODULE_DEPS_LIBS) $(PROTOBUF_LIBS) $(GRPCPP_LIBS) -lstdc++
modules_grpc_protos_libgrpc_protos_la_DEPENDENCIES = $(MODULE_DEPS_LIBS)

endif

CLEANFILES += \
$(GRPC_PROTOS_BUILT_SOURCES)

BUILT_SOURCES += \
$(GRPC_PROTOS_BUILT_SOURCES)

EXTRA_DIST += \
$(GRPC_PROTOS_SRCDIR)

0 comments on commit fd547fa

Please sign in to comment.