Skip to content

Commit

Permalink
[BUILD] Better handling of OPENTELEMETRY_STL_VERSION under Bazel. (#2503
Browse files Browse the repository at this point in the history
)
  • Loading branch information
bcsgh authored Jan 30, 2024
1 parent 732f0b2 commit 497eaf4
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 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")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")

package(default_visibility = ["//visibility:public"])

Expand All @@ -10,12 +10,39 @@ bool_flag(
build_setting_default = False,
)

CPP_STDLIBS = [
"none",
"best",
"2014",
"2017",
"2020",
"2023",
]

string_flag(
name = "with_cxx_stdlib",
build_setting_default = "best",
values = CPP_STDLIBS,
)

cc_library(
name = "api",
hdrs = glob(["include/**/*.h"]),
defines = select({
":with_external_abseil": ["HAVE_ABSEIL"],
"//conditions:default": [],
}) + select({
":set_cxx_stdlib_none": [],
### automatic selection
":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"],
# See https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
":set_cxx_stdlib_best_and_msvc": ["OPENTELEMETRY_STL_VERSION=(_MSVC_LANG/100)"],
### manual selection
":set_cxx_stdlib_2014": ["OPENTELEMETRY_STL_VERSION=2014"],
":set_cxx_stdlib_2017": ["OPENTELEMETRY_STL_VERSION=2017"],
":set_cxx_stdlib_2020": ["OPENTELEMETRY_STL_VERSION=2020"],
":set_cxx_stdlib_2023": ["OPENTELEMETRY_STL_VERSION=2023"],
"//conditions:default": [],
}),
strip_include_prefix = "include",
tags = ["api"],
Expand All @@ -33,3 +60,14 @@ config_setting(
name = "with_external_abseil",
flag_values = {":with_abseil": "true"},
)

[config_setting(
name = "set_cxx_stdlib_%s" % v,
flag_values = {":with_cxx_stdlib": v},
) for v in CPP_STDLIBS]

config_setting(
name = "set_cxx_stdlib_best_and_msvc",
constraint_values = ["@bazel_tools//tools/cpp:msvc"],
flag_values = {":with_cxx_stdlib": "best"},
)

1 comment on commit 497eaf4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp sdk Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 497eaf4 Previous: 732f0b2 Ratio
BM_LockFreeBuffer/4 9001796.245574951 ns/iter 1128673.9941665735 ns/iter 7.98

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.