Skip to content

Commit bbcde2b

Browse files
[BUILD] Align ext headers with CMake install set
Narrow //ext:headers to the four headers installed by CMake and add internal targets for the remaining curl, client detail, and server headers. Update direct consumers so implementation-only dependencies do not propagate transitively. This brings the Bazel surface in line with the CMake package introduced in #4327 and closes #4625.
1 parent 7c1e77c commit bbcde2b

9 files changed

Lines changed: 108 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ Increment the:
1515

1616
## [Unreleased]
1717

18+
* [BUILD] Narrow the `//ext:headers` Bazel target to the four headers the
19+
CMake package installs, and add internal targets for the rest
20+
[#4634](https://github.com/open-telemetry/opentelemetry-cpp/pull/4634)
21+
* `//ext:headers` now exposes only the four that `ext/CMakeLists.txt`
22+
installs: `http/client/http_client.h`,
23+
`http/client/http_client_factory.h`,
24+
`http/client/curl/http_client_factory_curl.h` and
25+
`http/common/url_parser.h`.
26+
* Code that included any of the other six moves to an internal target:
27+
`//ext:curl_implementation_headers` or `//ext:http_client_detail` in
28+
`implementation_deps`, and `//ext:server_headers` for tests and examples.
29+
* CMake narrowed to the same four in #4327, which first shipped in 1.29.0.
30+
A CMake consumer of the other six lost them there, so this change brings
31+
the Bazel surface in line rather than removing anything CMake still
32+
installs.
33+
1834
* [CODE HEALTH] Prevent `std::out_of_range` escaping `noexcept` substr callers.
1935
[#4562](https://github.com/open-telemetry/opentelemetry-cpp/pull/4562)
2036

‎examples/http/BUILD‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ cc_binary(
3939
"//api",
4040
"//exporters/ostream:ostream_span_exporter",
4141
"//ext:headers",
42+
"//ext:server_headers",
4243
"//sdk/src/trace",
4344
],
4445
)

‎exporters/elasticsearch/BUILD‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ cc_library(
1616
"include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h",
1717
"include/opentelemetry/exporters/elasticsearch/es_log_recordable.h",
1818
],
19+
implementation_deps = [
20+
"//ext:http_client_detail",
21+
],
1922
linkopts = select({
2023
"//bazel:windows": [
2124
"-DEFAULTLIB:advapi32.lib",

‎exporters/otlp/BUILD‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ cc_library(
212212
copts = [
213213
"-DCURL_STATICLIB",
214214
],
215+
implementation_deps = [
216+
"//ext:http_client_detail",
217+
],
215218
linkopts = select({
216219
"//bazel:windows": [
217220
"-DEFAULTLIB:advapi32.lib",
@@ -804,6 +807,7 @@ cc_test(
804807
deps = [
805808
":otlp_http_exporter",
806809
"//api",
810+
"//ext:server_headers",
807811
"//sdk/src/metrics",
808812
"//test_common/src/http/client/nosend:http_client_nosend",
809813
"@com_google_googletest//:gtest_main",

‎exporters/zipkin/BUILD‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ cc_library(
3737
copts = [
3838
"-DCURL_STATICLIB",
3939
],
40+
implementation_deps = [
41+
"//ext:http_client_detail",
42+
],
4043
strip_include_prefix = "include",
4144
tags = ["zipkin"],
4245
deps = [
@@ -68,6 +71,7 @@ cc_test(
6871
deps = [
6972
":zipkin_exporter",
7073
":zipkin_recordable",
74+
"//ext:curl_implementation_headers",
7175
"//test_common/src/http/client/nosend:http_client_nosend",
7276
"@com_google_googletest//:gtest_main",
7377
],

‎ext/BUILD‎

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,83 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library")
55

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

8+
# Headers installed by CMake and exposed to Bazel consumers
89
cc_library(
910
name = "headers",
10-
hdrs = glob(["include/**/*.h"]),
11+
hdrs = [
12+
"include/opentelemetry/ext/http/client/curl/http_client_factory_curl.h",
13+
"include/opentelemetry/ext/http/client/http_client.h",
14+
"include/opentelemetry/ext/http/client/http_client_factory.h",
15+
"include/opentelemetry/ext/http/common/url_parser.h",
16+
],
17+
strip_include_prefix = "include",
18+
deps = [
19+
"//api",
20+
],
21+
)
22+
23+
# Internal: curl implementation headers
24+
# Used by: the curl client itself, its tests, and the w3c test server
25+
# These are implementation details and are not installed by CMake
26+
cc_library(
27+
name = "curl_implementation_headers",
28+
hdrs = [
29+
"include/opentelemetry/ext/http/client/curl/http_client_curl.h",
30+
"include/opentelemetry/ext/http/client/curl/http_operation_curl.h",
31+
"include/opentelemetry/ext/http/client/curl/http_time_util.h",
32+
],
33+
strip_include_prefix = "include",
34+
visibility = [
35+
"//exporters/zipkin:__pkg__",
36+
"//ext/src/http/client/curl:__pkg__",
37+
"//ext/test/http:__pkg__",
38+
"//ext/test/w3c_tracecontext_http_test_server:__pkg__",
39+
],
40+
deps = [
41+
":headers",
42+
"@curl",
43+
],
44+
)
45+
46+
# Internal: Detail headers for factory implementations
47+
# Used by: exporters/otlp, exporters/elasticsearch, exporters/zipkin
48+
cc_library(
49+
name = "http_client_detail",
50+
hdrs = [
51+
"include/opentelemetry/ext/http/client/detail/default_factory.h",
52+
],
53+
strip_include_prefix = "include",
54+
visibility = [
55+
"//exporters/elasticsearch:__pkg__",
56+
"//exporters/otlp:__pkg__",
57+
"//exporters/zipkin:__pkg__",
58+
],
59+
deps = [
60+
":headers",
61+
],
62+
)
63+
64+
# Internal: Embedded HTTP server headers (test and example use only)
65+
# TODO: Move to test_common per issue #4332
66+
# These are test infrastructure, not part of the public API
67+
cc_library(
68+
name = "server_headers",
69+
hdrs = [
70+
"include/opentelemetry/ext/http/server/http_server.h",
71+
"include/opentelemetry/ext/http/server/socket_tools.h",
72+
],
1173
linkopts = select({
12-
# socket_tools.h calls Winsock; declare it on the interface so consumers link it too.
1374
"//bazel:windows": ["-DEFAULTLIB:Ws2_32.lib"],
1475
"//conditions:default": [],
1576
}),
1677
strip_include_prefix = "include",
78+
visibility = [
79+
"//examples/http:__pkg__",
80+
"//exporters/otlp:__pkg__",
81+
"//ext/test/http:__pkg__",
82+
"//ext/test/w3c_tracecontext_http_test_server:__pkg__",
83+
],
84+
deps = [
85+
"//api",
86+
],
1787
)

‎ext/src/http/client/curl/BUILD‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ cc_library(
1616
defines = [
1717
"ENABLE_HTTP_CLIENT_CURL",
1818
],
19+
implementation_deps = [
20+
"//ext:curl_implementation_headers",
21+
],
1922
include_prefix = "src/http/client/curl",
2023
linkopts = select({
2124
"//bazel:windows": [

‎ext/test/http/BUILD‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ cc_test(
88
srcs = [
99
"socket_tools_test.cc",
1010
],
11-
# ws2_32 is an interface linkopt of //ext:headers, so it is inherited here rather than
12-
# relinked, which also lets the test verify the public target's usage requirements.
1311
tags = ["test"],
1412
deps = [
1513
"//ext:headers",
14+
"//ext:server_headers",
1615
"@com_google_googletest//:gtest_main",
1716
],
1817
)
@@ -24,7 +23,9 @@ cc_test(
2423
],
2524
tags = ["test"],
2625
deps = [
26+
"//ext:curl_implementation_headers",
2727
"//ext:headers",
28+
"//ext:server_headers",
2829
"//ext/src/http/client/curl:http_client_curl",
2930
"//sdk/src/trace",
3031
"@com_google_googletest//:gtest_main",

‎ext/test/w3c_tracecontext_http_test_server/BUILD‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ cc_binary(
1919
deps = [
2020
"//api",
2121
"//exporters/ostream:ostream_span_exporter",
22+
"//ext:curl_implementation_headers",
2223
"//ext:headers",
24+
"//ext:server_headers",
2325
"//ext/src/http/client/curl:http_client_curl",
2426
"//sdk/src/trace",
2527
"@curl",

0 commit comments

Comments
 (0)