✨ add bazel build for grpc example (#910)
This commit is contained in:
Родитель
ecb9a27f12
Коммит
40d2eb5c72
|
@ -29,6 +29,7 @@ load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
|
|||
|
||||
grpc_extra_deps()
|
||||
|
||||
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
|
||||
load("@upb//bazel:workspace_deps.bzl", "upb_deps")
|
||||
|
||||
upb_deps()
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
|
||||
|
||||
proto_library(
|
||||
name = "messages_proto",
|
||||
srcs = ["protos/messages.proto"],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "messages_cc_proto",
|
||||
deps = [":messages_proto"],
|
||||
)
|
||||
|
||||
cc_grpc_library(
|
||||
name = "messages_cc_grpc",
|
||||
srcs = [":messages_proto"],
|
||||
grpc_only = True,
|
||||
deps = [":messages_cc_proto"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "tracer_common",
|
||||
srcs = ["tracer_common.h"],
|
||||
defines = ["BAZEL_BUILD"],
|
||||
deps = [
|
||||
"//exporters/ostream:ostream_span_exporter",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "client_grpc",
|
||||
srcs = [
|
||||
"client.cpp",
|
||||
],
|
||||
defines = ["BAZEL_BUILD"],
|
||||
deps = [
|
||||
"messages_cc_grpc",
|
||||
":tracer_common",
|
||||
"//api",
|
||||
"//sdk/src/trace",
|
||||
"@com_github_grpc_grpc//:grpc++",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "server_grpc",
|
||||
srcs = [
|
||||
"server.cpp",
|
||||
],
|
||||
defines = ["BAZEL_BUILD"],
|
||||
deps = [
|
||||
"messages_cc_grpc",
|
||||
":tracer_common",
|
||||
"//api",
|
||||
"//sdk/src/trace",
|
||||
"@com_github_grpc_grpc//:grpc++",
|
||||
],
|
||||
)
|
|
@ -2,7 +2,11 @@
|
|||
// ambiguity with `nostd::variant` if compiled with Visual Studio 2015. Other
|
||||
// modern compilers are unaffected.
|
||||
#include <grpcpp/grpcpp.h>
|
||||
#ifdef BAZEL_BUILD
|
||||
#include "examples/grpc/protos/messages.grpc.pb.h"
|
||||
#else
|
||||
#include "messages.grpc.pb.h"
|
||||
#endif
|
||||
|
||||
#include "tracer_common.h"
|
||||
#include <iostream>
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
#ifdef BAZEL_BUILD
|
||||
#include "examples/grpc/protos/messages.grpc.pb.h"
|
||||
#else
|
||||
#include "messages.grpc.pb.h"
|
||||
#endif
|
||||
#include "tracer_common.h"
|
||||
#include "opentelemetry/trace/span_context_kv_iterable_view.h"
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче