Skip to content

Commit

Permalink
Merge and for ABI Version 2 for dll version
Browse files Browse the repository at this point in the history
  • Loading branch information
malkia committed Aug 10, 2024
2 parents 900d814 + 41538b0 commit 13b64ec
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
-DCMAKE_CXX_STANDARD=14 \
-DWITH_STL=CXX14 \
-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \
-DBUILD_TESTING=OFF \
-DBUILD_W3CTRACECONTEXT_TEST=OFF \
-DBUILD_TESTING=ON \
-DBUILD_W3CTRACECONTEXT_TEST=ON \
-DWITH_OTLP_GRPC=OFF \
-DWITH_OTLP_HTTP=ON \
-DWITH_OTLP_FILE=ON \
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ if(WITH_OTLP_GRPC
if(WITH_OTLP_GRPC)
find_package(gRPC)
endif()
if((NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND) OR (NOT gRPC_FOUND))
if((NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND) OR (WITH_OTLP_GRPC
AND NOT gRPC_FOUND))
if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE))
install_windows_deps()
endif()
Expand Down
21 changes: 20 additions & 1 deletion api/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "int_flag", "string_flag")
load("//bazel:otel_cc.bzl", "otel_cc_binary", "otel_cc_import", "otel_cc_library", "otel_cc_shared_library", "otel_cc_test")

package(default_visibility = ["//visibility:public"])
Expand Down Expand Up @@ -39,6 +39,10 @@ otel_cc_library(
}) + select({
"//:with_dll_enabled": ["OPENTELEMETRY_DLL=-1"],
"//conditions:default": ["OPENTELEMETRY_DLL=0"],
}) + select({
"//:with_dll_enabled": [], # always use ABI Version 2
":abi_version_no_1": ["OPENTELEMETRY_ABI_VERSION_NO=1"],
":abi_version_no_2": ["OPENTELEMETRY_ABI_VERSION_NO=2"],
}),
strip_include_prefix = "include",
tags = ["api"],
Expand Down Expand Up @@ -80,3 +84,18 @@ bool_flag(
build_setting_default = False,
deprecation = "The value of this flag is ignored. Bazel builds always depend on Abseil for its pre-adopted `std::` types. You should remove this flag from your build command.",
)

int_flag(
name = "abi_version_no",
build_setting_default = 1,
)

config_setting(
name = "abi_version_no_1",
flag_values = {":abi_version_no": "1"},
)

config_setting(
name = "abi_version_no_2",
flag_values = {":abi_version_no": "2"},
)
3 changes: 3 additions & 0 deletions api/include/opentelemetry/common/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ point.
// Build settings for otel_sdk are hard-coded in this file, so users don't have to define them.
# define OPENTELEMETRY_STL_VERSION 2017
# define OPENTELEMETRY_OPTION_USE_STD_SPAN 0 // Use the nostd version, std::span is in C++2020
# ifdef OPENTELEMETRY_ABI_VERSION_NO
# undef OPENTELEMETRY_ABI_VERSION_NO
# endif
# define OPENTELEMETRY_ABI_VERSION_NO 2 // Use the new api
# define ENABLE_METRICS_EXEMPLAR_PREVIEW 1
# define ENABLE_ASYNC_EXPORT 1
Expand Down
2 changes: 2 additions & 0 deletions cmake/opentelemetry-proto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ add_library(
${TRACE_SERVICE_PB_CPP_FILE}
${LOGS_SERVICE_PB_CPP_FILE}
${METRICS_SERVICE_PB_CPP_FILE})
set_target_version(opentelemetry_proto)

# Disable include-what-you-use on generated code.
set_target_properties(
Expand All @@ -341,6 +342,7 @@ if(WITH_OTLP_GRPC)
opentelemetry_proto_grpc
${OTELCPP_PROTO_TARGET_OPTIONS} ${TRACE_SERVICE_GRPC_PB_CPP_FILE}
${LOGS_SERVICE_GRPC_PB_CPP_FILE} ${METRICS_SERVICE_GRPC_PB_CPP_FILE})
set_target_version(opentelemetry_proto_grpc)

list(APPEND OPENTELEMETRY_PROTO_TARGETS opentelemetry_proto_grpc)
target_link_libraries(opentelemetry_proto_grpc PUBLIC opentelemetry_proto)
Expand Down

0 comments on commit 13b64ec

Please sign in to comment.