xref: /aosp_15_r20/external/pytorch/third_party/opentelemetry-cpp.BUILD (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1load("@rules_cc//cc:defs.bzl", "cc_library")
2load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
3
4package(default_visibility = ["//visibility:public"])
5
6bool_flag(
7    name = "with_abseil",
8    build_setting_default = False,
9)
10
11CPP_STDLIBS = [
12    "none",
13    "best",
14    "2014",
15    "2017",
16    "2020",
17    "2023",
18]
19
20string_flag(
21    name = "with_cxx_stdlib",
22    build_setting_default = "best",
23    values = CPP_STDLIBS,
24)
25
26cc_library(
27    name = "api",
28    hdrs = glob(["include/**/*.h"]),
29    defines = select({
30        ":with_external_abseil": ["HAVE_ABSEIL"],
31        "//conditions:default": [],
32    }) + select({
33        ":set_cxx_stdlib_none": [],
34        ### automatic selection
35        ":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"],
36        # See https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
37        ":set_cxx_stdlib_best_and_msvc": ["OPENTELEMETRY_STL_VERSION=(_MSVC_LANG/100)"],
38        ### manual selection
39        ":set_cxx_stdlib_2014": ["OPENTELEMETRY_STL_VERSION=2014"],
40        ":set_cxx_stdlib_2017": ["OPENTELEMETRY_STL_VERSION=2017"],
41        ":set_cxx_stdlib_2020": ["OPENTELEMETRY_STL_VERSION=2020"],
42        ":set_cxx_stdlib_2023": ["OPENTELEMETRY_STL_VERSION=2023"],
43        "//conditions:default": [],
44    }),
45    strip_include_prefix = "include",
46    tags = ["api"],
47    deps = select({
48        ":with_external_abseil": [
49            "@com_google_absl//absl/base",
50            "@com_google_absl//absl/strings",
51            "@com_google_absl//absl/types:variant",
52        ],
53        "//conditions:default": [],
54    }),
55)
56
57config_setting(
58    name = "with_external_abseil",
59    flag_values = {":with_abseil": "true"},
60)
61
62[config_setting(
63    name = "set_cxx_stdlib_%s" % v,
64    flag_values = {":with_cxx_stdlib": v},
65) for v in CPP_STDLIBS]
66
67config_setting(
68    name = "set_cxx_stdlib_best_and_msvc",
69    constraint_values = ["@bazel_tools//tools/cpp:msvc"],
70    flag_values = {":with_cxx_stdlib": "best"},
71)
72