Skip to content

Commit f5a17df

Browse files
authored
Merge pull request #33 from lightstep/jmacd/build_with_protoc
Generate protobuf code at build time
2 parents 5a71d62 + c810779 commit f5a17df

13 files changed

+54
-7177
lines changed

configure.ac

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# by homebrew, see the commands to set PKG_CONFIG_PATH in build.sh.
55

66
AC_PREREQ([2.69])
7-
AC_INIT([lightstep-tracer-cpp], [0.19],
7+
AC_INIT([lightstep-tracer-cpp], [0.20],
88
[https://github.com/lightstep/lightstep-tracer-cpp/issues])
99
LT_INIT([disable-shared])
1010
AM_INIT_AUTOMAKE([1.14 foreign subdir-objects])
@@ -29,6 +29,9 @@ CPPFLAGS="${SAVE_CPPFLAGS}"
2929
AC_SUBST(protobuf_LIBS)
3030
AC_SUBST(protobuf_CFLAGS)
3131

32+
AC_CACHE_VAL(protobuf_cv_PREFIX, [protobuf_cv_PREFIX=`$PKG_CONFIG --variable=prefix protobuf`])
33+
AC_SUBST(PROTOC, $protobuf_cv_PREFIX/bin/protoc)
34+
3235
AC_ARG_ENABLE([grpc],
3336
[AS_HELP_STRING([--disable-grpc],
3437
[Enable gRPC networking @<:@yes@:>@])],

src/c++11/Makefile.am

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
# TODO(jmacd): Replace the proto-generation rule with one using the protoc docker image.
2-
PROTOC = protoc
3-
PROTO_SRC = $(top_srcdir)/lightstep-tracer-common
2+
PROTOC = @PROTOC@
3+
COLLECTOR_SRC = $(top_srcdir)/lightstep-tracer-common
44
ENVOY_SRC = ./envoy
5-
PROTO_OUT = proto
5+
PROTO_DIR = proto
6+
7+
PROTO_SRC = \
8+
$(COLLECTOR_SRC)/collector.proto \
9+
$(ENVOY_SRC)/envoy_carrier.proto
10+
11+
PROTO_GEN = \
12+
lightstep/collector.grpc.pb.h \
13+
lightstep/collector.pb.h \
14+
lightstep/envoy_carrier.pb.h \
15+
proto/collector.grpc.pb.cc \
16+
proto/collector.pb.cc \
17+
proto/envoy_carrier.pb.cc
18+
19+
CLEANFILES = $(PROTO_GEN)
620

721
.PHONY: proto
822

923
AM_CXXFLAGS = -Wno-deprecated-declarations
1024

11-
proto:
12-
mkdir -p $(PROTO_OUT)
13-
$(PROTOC) --proto_path=$(PROTO_SRC) --grpc_out=$(PROTO_OUT) --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` $(PROTO_SRC)/collector.proto
14-
$(PROTOC) --proto_path=$(PROTO_SRC) --cpp_out=$(PROTO_OUT) $(PROTO_SRC)/collector.proto
15-
$(PROTOC) --proto_path=$(ENVOY_SRC) --cpp_out=$(PROTO_OUT) $(ENVOY_SRC)/envoy_carrier.proto
25+
$(PROTO_GEN): $(PROTO_SRC) $(PROTOC)
26+
mkdir -p $(PROTO_DIR)
27+
$(PROTOC) --proto_path=$(COLLECTOR_SRC) --grpc_out=$(PROTO_DIR) --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` $(COLLECTOR_SRC)/collector.proto
28+
$(PROTOC) --proto_path=$(COLLECTOR_SRC) --cpp_out=$(PROTO_DIR) $(COLLECTOR_SRC)/collector.proto
29+
$(PROTOC) --proto_path=$(ENVOY_SRC) --cpp_out=$(PROTO_DIR) $(ENVOY_SRC)/envoy_carrier.proto
1630
mv proto/*.h lightstep
1731

32+
BUILT_SOURCES = $(PROTO_GEN)
33+
1834
lib_LTLIBRARIES = liblightstep_core_cxx11.la
1935

2036
nobase_include_HEADERS = \
21-
lightstep/collector.grpc.pb.h \
22-
lightstep/collector.pb.h \
23-
lightstep/envoy_carrier.pb.h \
2437
lightstep/envoy.h \
2538
lightstep/impl.h \
2639
lightstep/options.h \
@@ -33,6 +46,11 @@ nobase_include_HEADERS = \
3346
mapbox_variant/recursive_wrapper.hpp \
3447
mapbox_variant/variant.hpp
3548

49+
nobase_nodist_include_HEADERS = \
50+
lightstep/collector.grpc.pb.h \
51+
lightstep/collector.pb.h \
52+
lightstep/envoy_carrier.pb.h
53+
3654
EXTRA_DIST = \
3755
mapbox_variant/LICENSE \
3856
envoy/envoy_carrier.proto
@@ -41,7 +59,9 @@ liblightstep_core_cxx11_la_SOURCES = \
4159
impl.cc \
4260
span.cc \
4361
tracer.cc \
44-
util.cc \
62+
util.cc
63+
64+
nodist_liblightstep_core_cxx11_la_SOURCES = \
4565
proto/collector.pb.cc \
4666
proto/envoy_carrier.pb.cc
4767

@@ -53,7 +73,9 @@ if ENABLE_GRPC
5373
lib_LTLIBRARIES += liblightstep_grpc_cxx11.la
5474

5575
liblightstep_grpc_cxx11_la_SOURCES = \
56-
recorder.cc \
76+
recorder.cc
77+
78+
nodist_liblightstep_grpc_cxx11_la_SOURCES = \
5779
proto/collector.grpc.pb.cc
5880

5981
# Note $(grpc_LIBS)++ shenanigans. The grpc C++ pkg-config input (grpc++.pc) uses

src/c++11/impl.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace lightstep {
2020

21-
const char TracerIDKey[] = "lightstep.guid";
21+
const char ReporterIDKey[] = "lightstep.guid";
2222

2323
namespace {
2424

@@ -55,13 +55,13 @@ TracerImpl::TracerImpl(const TracerOptions& options_in)
5555
rand_source_(std::random_device()()),
5656
tracer_start_time_(Clock::now()) {
5757

58-
tracer_id_ = GetOneId();
58+
reporter_id_ = GetOneId();
5959

6060
if (options_.tracer_attributes.find(ComponentNameKey) == options_.tracer_attributes.end()) {
6161
options_.tracer_attributes.emplace(std::make_pair(ComponentNameKey, util::program_name()));
6262
}
63-
// Note: drop the TracerIDKey, this is copied from tracer_id_.
64-
auto guid_lookup = options_.tracer_attributes.find(TracerIDKey);
63+
// Note: drop the ReporterIDKey, this is copied from reporter_id_.
64+
auto guid_lookup = options_.tracer_attributes.find(ReporterIDKey);
6565
if (guid_lookup != options_.tracer_attributes.end()) {
6666
options_.tracer_attributes.erase(guid_lookup);
6767
}

src/c++11/lightstep/collector.grpc.pb.h

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)