| 1 |
# Copyright The OpenTelemetry Authors |
| 2 |
# SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
# gcc and clang, assumed to be used on this platform |
| 5 |
DEFAULT_NOWIN_COPTS = [ |
| 6 |
"-fvisibility=default", |
| 7 |
] |
| 8 |
|
| 9 |
# gcc and clang, assumed to be used on this platform |
| 10 |
HIDDEN_NOWIN_COPTS = [ |
| 11 |
"-fvisibility=hidden", |
| 12 |
] |
| 13 |
|
| 14 |
cc_library( |
| 15 |
name = "component_a", |
| 16 |
srcs = [ |
| 17 |
"component_a.cc", |
| 18 |
], |
| 19 |
hdrs = [ |
| 20 |
"component_a.h", |
| 21 |
], |
| 22 |
linkstatic = True, |
| 23 |
target_compatible_with = select({ |
| 24 |
"//bazel:windows": ["@platforms//:incompatible"], |
| 25 |
"//conditions:default": [], |
| 26 |
}), |
| 27 |
deps = [ |
| 28 |
"//api", |
| 29 |
], |
| 30 |
) |
| 31 |
|
| 32 |
cc_library( |
| 33 |
name = "component_b", |
| 34 |
srcs = [ |
| 35 |
"component_b.cc", |
| 36 |
], |
| 37 |
hdrs = [ |
| 38 |
"component_b.h", |
| 39 |
], |
| 40 |
linkstatic = True, |
| 41 |
target_compatible_with = select({ |
| 42 |
"//bazel:windows": ["@platforms//:incompatible"], |
| 43 |
"//conditions:default": [], |
| 44 |
}), |
| 45 |
deps = [ |
| 46 |
"//api", |
| 47 |
], |
| 48 |
) |
| 49 |
|
| 50 |
cc_library( |
| 51 |
name = "component_c", |
| 52 |
srcs = [ |
| 53 |
"component_c.cc", |
| 54 |
], |
| 55 |
hdrs = [ |
| 56 |
"component_c.h", |
| 57 |
], |
| 58 |
copts = DEFAULT_NOWIN_COPTS, |
| 59 |
linkstatic = False, |
| 60 |
target_compatible_with = select({ |
| 61 |
"//bazel:windows": ["@platforms//:incompatible"], |
| 62 |
"//conditions:default": [], |
| 63 |
}), |
| 64 |
deps = [ |
| 65 |
"//api", |
| 66 |
], |
| 67 |
) |
| 68 |
|
| 69 |
cc_library( |
| 70 |
name = "component_d", |
| 71 |
srcs = [ |
| 72 |
"component_d.cc", |
| 73 |
], |
| 74 |
hdrs = [ |
| 75 |
"component_d.h", |
| 76 |
], |
| 77 |
copts = HIDDEN_NOWIN_COPTS, |
| 78 |
linkstatic = False, |
| 79 |
target_compatible_with = select({ |
| 80 |
"//bazel:windows": ["@platforms//:incompatible"], |
| 81 |
"//conditions:default": [], |
| 82 |
}), |
| 83 |
deps = [ |
| 84 |
"//api", |
| 85 |
], |
| 86 |
) |
| 87 |
|
| 88 |
cc_library( |
| 89 |
name = "component_e", |
| 90 |
srcs = [ |
| 91 |
"component_e.cc", |
| 92 |
], |
| 93 |
hdrs = [ |
| 94 |
"component_e.h", |
| 95 |
], |
| 96 |
copts = DEFAULT_NOWIN_COPTS, |
| 97 |
linkstatic = False, |
| 98 |
target_compatible_with = select({ |
| 99 |
"//bazel:windows": ["@platforms//:incompatible"], |
| 100 |
"//conditions:default": [], |
| 101 |
}), |
| 102 |
deps = [ |
| 103 |
"//api", |
| 104 |
], |
| 105 |
) |
| 106 |
|
| 107 |
cc_library( |
| 108 |
name = "component_f", |
| 109 |
srcs = [ |
| 110 |
"component_f.cc", |
| 111 |
], |
| 112 |
hdrs = [ |
| 113 |
"component_f.h", |
| 114 |
], |
| 115 |
copts = HIDDEN_NOWIN_COPTS, |
| 116 |
linkstatic = False, |
| 117 |
target_compatible_with = select({ |
| 118 |
"//bazel:windows": ["@platforms//:incompatible"], |
| 119 |
"//conditions:default": [], |
| 120 |
}), |
| 121 |
deps = [ |
| 122 |
"//api", |
| 123 |
], |
| 124 |
) |
| 125 |
|
| 126 |
# no cc_shared_library in bazel 4.2 |
| 127 |
cc_binary( |
| 128 |
name = "component_g", |
| 129 |
srcs = [ |
| 130 |
"component_g.cc", |
| 131 |
], |
| 132 |
copts = DEFAULT_NOWIN_COPTS, |
| 133 |
linkshared = True, |
| 134 |
target_compatible_with = select({ |
| 135 |
"//bazel:windows": ["@platforms//:incompatible"], |
| 136 |
"//conditions:default": [], |
| 137 |
}), |
| 138 |
deps = [ |
| 139 |
"//api", |
| 140 |
], |
| 141 |
) |
| 142 |
|
| 143 |
# no cc_shared_library in bazel 4.2 |
| 144 |
cc_binary( |
| 145 |
name = "component_h", |
| 146 |
srcs = [ |
| 147 |
"component_h.cc", |
| 148 |
], |
| 149 |
copts = HIDDEN_NOWIN_COPTS, |
| 150 |
linkshared = True, |
| 151 |
target_compatible_with = select({ |
| 152 |
"//bazel:windows": ["@platforms//:incompatible"], |
| 153 |
"//conditions:default": [], |
| 154 |
}), |
| 155 |
deps = [ |
| 156 |
"//api", |
| 157 |
], |
| 158 |
) |
| 159 |
|
| 160 |
# |
| 161 |
# To build this test alone: |
| 162 |
# - bazel build //api/test/singleton:singleton_test |
| 163 |
# - bazel build //api/test/singleton:component_g |
| 164 |
# - bazel build //api/test/singleton:component_h |
| 165 |
# |
| 166 |
# Note that singleton_test does not depend on |
| 167 |
# component_g and component_h, on purpose. |
| 168 |
# |
| 169 |
# To run this test: |
| 170 |
# bazel test //api/test/singleton:singleton_test |
| 171 |
# |
| 172 |
|
| 173 |
cc_test( |
| 174 |
name = "singleton_test", |
| 175 |
srcs = [ |
| 176 |
"singleton_test.cc", |
| 177 |
], |
| 178 |
defines = ["BAZEL_BUILD"], |
| 179 |
linkopts = [ |
| 180 |
"-ldl", |
| 181 |
], |
| 182 |
linkstatic = False, |
| 183 |
tags = [ |
| 184 |
"api", |
| 185 |
"test", |
| 186 |
], |
| 187 |
target_compatible_with = select({ |
| 188 |
"//bazel:windows": ["@platforms//:incompatible"], |
| 189 |
"//conditions:default": [], |
| 190 |
}), |
| 191 |
deps = [ |
| 192 |
"component_a", |
| 193 |
"component_b", |
| 194 |
"component_c", |
| 195 |
"component_d", |
| 196 |
"component_e", |
| 197 |
"component_f", |
| 198 |
"//api", |
| 199 |
"@com_google_googletest//:gtest_main", |
| 200 |
], |
| 201 |
) |