Fix if guards for opentelemetry plugin library

pull/36063/head
Yash Tibrewal 12 months ago
parent 8ccd20491a
commit 310c42f68e
  1. 31
      CMakeLists.txt
  2. 2
      build_autogenerated.yaml
  3. 2
      examples/cpp/otel/README.md
  4. 14
      templates/CMakeLists.txt.template
  5. 1
      templates/README.md
  6. 5
      tools/buildgen/extract_metadata_from_bazel_xml.py

31
CMakeLists.txt generated

@ -50,7 +50,6 @@ set(gRPC_BUILD_MSVC_MP_COUNT 0 CACHE STRING "The maximum number of processes for
option(gRPC_BUILD_TESTS "Build tests" OFF)
option(gRPC_BUILD_CODEGEN "Build codegen" ON)
option(gRPC_DOWNLOAD_ARCHIVES "Download archives for empty 3rd party directories" ON)
option(gRPC_BUILD_OPENTELEMETRY_PLUGIN "Build gRPC OpenTelemetry Plugin" OFF)
set(gRPC_INSTALL_default ON)
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
@ -354,7 +353,8 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX)
set(_gRPC_ALLTARGETS_LIBRARIES ${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_SYSTEMD_LIBRARIES})
endif()
if(gRPC_BUILD_OPENTELEMETRY_PLUGIN)
option(gRPC_BUILD_GRPCPP_OTEL_PLUGIN "Build grpcpp_otel_plugin" OFF)
if(gRPC_BUILD_GRPCPP_OTEL_PLUGIN)
include(cmake/opentelemetry-cpp.cmake)
endif()
@ -1620,7 +1620,6 @@ if(gRPC_INSTALL)
endif()
add_library(gpr
src/core/lib/config/config_vars.cc
src/core/lib/config/config_vars_non_generated.cc
@ -1785,7 +1784,6 @@ if(gRPC_INSTALL)
endif()
add_library(grpc
src/core/client_channel/backup_poller.cc
src/core/client_channel/client_channel_channelz.cc
@ -2754,7 +2752,6 @@ endif()
if(gRPC_BUILD_TESTS)
add_library(grpc_test_util
test/core/event_engine/test_init.cc
test/core/util/build.cc
@ -2821,7 +2818,6 @@ endif()
endif()
if(gRPC_BUILD_TESTS)
add_library(grpc_test_util_unsecure
test/core/event_engine/test_init.cc
test/core/util/build.cc
@ -2886,7 +2882,6 @@ endif()
endif()
add_library(grpc_unsecure
src/core/client_channel/backup_poller.cc
src/core/client_channel/client_channel_channelz.cc
@ -3461,7 +3456,6 @@ endif()
if(gRPC_BUILD_TESTS)
add_library(gtest
third_party/googletest/googlemock/src/gmock-cardinalities.cc
third_party/googletest/googlemock/src/gmock-internal-utils.cc
@ -3534,7 +3528,6 @@ target_link_libraries(gtest
endif()
add_library(upb_base_lib
third_party/upb/upb/base/status.c
)
@ -3586,7 +3579,6 @@ if(gRPC_INSTALL)
endif()
add_library(upb_json_lib ${_gRPC_STATIC_WIN32}
src/core/ext/upb-gen/google/protobuf/descriptor.upb_minitable.c
third_party/upb/upb/json/decode.c
@ -3674,7 +3666,6 @@ if(gRPC_INSTALL)
endif()
add_library(upb_mem_lib
third_party/upb/upb/mem/alloc.c
third_party/upb/upb/mem/arena.c
@ -3727,7 +3718,6 @@ if(gRPC_INSTALL)
endif()
add_library(upb_message_lib
third_party/upb/upb/hash/common.c
third_party/upb/upb/message/array.c
@ -3788,7 +3778,6 @@ if(gRPC_INSTALL)
endif()
add_library(upb_textformat_lib ${_gRPC_STATIC_WIN32}
src/core/ext/upb-gen/google/protobuf/descriptor.upb_minitable.c
third_party/upb/upb/lex/atoi.c
@ -3875,7 +3864,6 @@ if(gRPC_INSTALL)
endif()
add_library(utf8_range_lib
third_party/utf8_range/naive.c
third_party/utf8_range/range2-neon.c
@ -3931,7 +3919,6 @@ endif()
if(gRPC_BUILD_TESTS)
if(gRPC_BUILD_CODEGEN)
add_library(benchmark_helpers ${_gRPC_STATIC_WIN32}
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.grpc.pb.cc
@ -4014,7 +4001,6 @@ endif()
endif()
add_library(grpc++
src/core/ext/transport/binder/client/binder_connector.cc
src/core/ext/transport/binder/client/channel_create.cc
@ -4355,7 +4341,6 @@ if(gRPC_INSTALL)
endif()
add_library(grpc++_alts
src/cpp/common/alts_context.cc
src/cpp/common/alts_util.cc
@ -4429,7 +4414,6 @@ if(gRPC_INSTALL)
endif()
add_library(grpc++_error_details
src/cpp/util/error_details.cc
)
@ -4502,7 +4486,6 @@ endif()
if(gRPC_BUILD_CODEGEN)
add_library(grpc++_reflection ${_gRPC_STATIC_WIN32}
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1/reflection.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1/reflection.grpc.pb.cc
@ -4587,7 +4570,6 @@ endif()
endif()
if(gRPC_BUILD_TESTS)
add_library(grpc++_test
src/cpp/client/channel_test_peer.cc
)
@ -4661,7 +4643,6 @@ endforeach()
endif()
if(gRPC_BUILD_TESTS)
add_library(grpc++_test_config
test/cpp/util/test_config_cc.cc
)
@ -4714,7 +4695,6 @@ target_link_libraries(grpc++_test_config
endif()
if(gRPC_BUILD_TESTS)
add_library(grpc++_test_util
src/core/lib/gpr/subprocess_posix.cc
src/core/lib/gpr/subprocess_windows.cc
@ -4787,7 +4767,6 @@ target_link_libraries(grpc++_test_util
endif()
add_library(grpc++_unsecure
src/cpp/client/channel_cc.cc
src/cpp/client/client_callback.cc
@ -5096,7 +5075,6 @@ if(gRPC_INSTALL)
endif()
add_library(grpc_authorization_provider
src/core/ext/upb-gen/google/protobuf/any.upb_minitable.c
src/core/ext/upb-gen/google/protobuf/descriptor.upb_minitable.c
@ -5534,7 +5512,6 @@ if(gRPC_INSTALL)
endif()
add_library(grpc_plugin_support
src/compiler/cpp_generator.cc
src/compiler/csharp_generator.cc
@ -5609,7 +5586,6 @@ endif()
# grpcpp_channelz doesn't build with protobuf-lite
# See https://github.com/grpc/grpc/issues/19473
if(gRPC_BUILD_CODEGEN AND NOT gRPC_USE_PROTO_LITE)
add_library(grpcpp_channelz ${_gRPC_STATIC_WIN32}
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc
@ -5689,7 +5665,7 @@ if(gRPC_INSTALL AND NOT gRPC_USE_PROTO_LITE)
endif()
endif()
if(gRPC_BUILD_GRPCPP_OTEL_PLUGIN)
add_library(grpcpp_otel_plugin
src/cpp/ext/otel/otel_client_filter.cc
@ -5763,6 +5739,7 @@ if(gRPC_INSTALL)
)
endif()
endif()
if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)

@ -5098,7 +5098,7 @@ libs:
deps:
- grpc++
- name: grpcpp_otel_plugin
build: all
build: plugin
language: c++
public_headers:
- include/grpcpp/ext/otel_plugin.h

@ -46,7 +46,7 @@ The following libraries need to be installed before building the example with CM
* protobuf
* prometheus-cpp
* opentelemetry-cpp (with the options `-DWITH_ABSEIL=ON` `-DWITH_PROMETHEUS=ON`)
* grpc (with the option `-DgRPC_BUILD_OPENTELEMETRY_PLUGIN=ON`)
* grpc (with the option `-DgRPC_BUILD_GRPCPP_OTEL_PLUGIN=ON`)
You can find a complete set of instructions for building gRPC and running the
Hello World app in the [C++ Quick Start][].

@ -200,7 +200,7 @@
def is_generate_cmake_target(lib_or_target):
"""Returns True if a cmake target should be generated for given library/target."""
# TODO(jtattermusch): extract the metadata to a centralized location.
if lib_or_target.build not in ["all", "protoc", "tool", "test", "private"]:
if lib_or_target.build not in ["all", "plugin", "protoc", "tool", "test", "private"]:
return False
if lib_or_target.boringssl:
# Don't generate target for boringssl libs or tests
@ -300,7 +300,6 @@
option(gRPC_BUILD_TESTS "Build tests" OFF)
option(gRPC_BUILD_CODEGEN "Build codegen" ON)
option(gRPC_DOWNLOAD_ARCHIVES "Download archives for empty 3rd party directories" ON)
option(gRPC_BUILD_OPENTELEMETRY_PLUGIN "Build gRPC OpenTelemetry Plugin" OFF)
set(gRPC_INSTALL_default ON)
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
@ -492,7 +491,8 @@
set(_gRPC_ALLTARGETS_LIBRARIES <%text>${_gRPC_ALLTARGETS_LIBRARIES}</%text> <%text>${_gRPC_SYSTEMD_LIBRARIES}</%text>)
endif()
if(gRPC_BUILD_OPENTELEMETRY_PLUGIN)
option(gRPC_BUILD_GRPCPP_OTEL_PLUGIN "Build grpcpp_otel_plugin" OFF)
if(gRPC_BUILD_GRPCPP_OTEL_PLUGIN)
include(cmake/opentelemetry-cpp.cmake)
endif()
@ -737,12 +737,16 @@
if not is_generate_cmake_target(lib): continue
cmake_libs.append(lib)
%>
% for lib in cmake_libs:
% if lib.build in ["test", "private"]:
if(gRPC_BUILD_TESTS)
${cc_library(lib)}
endif()
% else:
% if lib.build in ["plugin"]:
if(gRPC_BUILD_${lib.name.upper()})
% endif
${cc_library(lib)}
% if not lib.build in ["tool"]:
% if any(proto_re.match(src) for src in lib.src):
@ -753,6 +757,9 @@
endif()
% endif
% endif
% if lib.build in ["plugin"]:
endif()
% endif
% endif
% endfor
@ -792,7 +799,6 @@
if(gRPC_BUILD_CODEGEN)
% endif
% endif
add_library(${lib.name}${lib_type_for_lib(lib.name)}
% for src in lib.src:
% if not proto_re.match(src):

@ -89,6 +89,7 @@ dll: "..." # see below.
Currently, the "`build`" tag have these meanings:
* `"all"`: library to build on `"make all"`, and install on the system.
* `"plugin"`: library to build on `"make all"`, and install, but the corresponding CMake option defaults to off. The option needs to be declared manually at present to allow depending on third-party dependencies.
* `"protoc"`: a protoc plugin to build on `"make all"` and install on the system.
* `"private"`: a library to only build for tests.
* `"test"`: a test binary to run on `"make test"`.

@ -1160,7 +1160,10 @@ _BUILD_EXTRA_METADATA = {
"generate_plugin_registry": True,
},
"grpcpp_channelz": {"language": "c++", "build": "all"},
"grpcpp_otel_plugin": {"language": "c++", "build": "all"},
"grpcpp_otel_plugin": {
"language": "c++",
"build": "plugin",
},
"grpc++_test": {
"language": "c++",
"build": "private",

Loading…
Cancel
Save