BUILD 4.0 KB

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