Skip to content

[BUILD] Bazel //ext:headers exposes headers the CMake install excludes #4625

Description

@thc1006

The two build systems do not agree on which ext headers a consumer is allowed to include.

CMake installs four, by name, and excludes the detail and server directories outright, in ext/CMakeLists.txt#L37-L51:

  FILES_MATCHING
  PATTERN
  "http_client.h"
  PATTERN
  "http_client_factory.h"
  PATTERN
  "http_client_factory_curl.h"
  PATTERN
  "url_parser.h"
  PATTERN
  "detail"
  EXCLUDE
  PATTERN
  "server"
  EXCLUDE)

Bazel takes all ten, in ext/BUILD#L10:

cc_library(
    name = "headers",
    hdrs = glob(["include/**/*.h"]),

The six a Bazel consumer gets and a CMake consumer does not:

ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h
ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h
ext/include/opentelemetry/ext/http/client/curl/http_time_util.h
ext/include/opentelemetry/ext/http/client/detail/default_factory.h
ext/include/opentelemetry/ext/http/server/http_server.h
ext/include/opentelemetry/ext/http/server/socket_tools.h

Both halves compile. On b4257f0a, with a package whose only deps are //api and //ext:headers:

$ bazel build //extprobe:server_consumer   # #include ".../ext/http/server/http_server.h"
INFO: Build completed successfully

$ bazel build //extprobe:curl_consumer     # #include ".../ext/http/client/curl/http_operation_curl.h"
INFO: Build completed successfully

The comment above the CMake block says why each exclusion is there: detail/default_factory.h is an internal helper, the two concrete curl headers are reached through http_client_factory_curl.h, and the server headers are for tests and the http example. None of that is enforced on the Bazel side, so the curl Session and HttpOperation layouts are reachable by a Bazel consumer today, and changing either is a break for them even though the install tree says they are not part of the surface.

I ran into this while looking at whether making a member of HttpOperation atomic was an ABI question. Under CMake it plainly is not. Under Bazel I could not say the same.

Two directions, and I do not think the choice is mine to make:

  1. Narrow //ext:headers to the four CMake installs, and give the rest their own target for the in-tree tests and examples that need them.
  2. Treat the Bazel glob as the real surface and widen the CMake install to match, which contradicts the reasoning already written into ext/CMakeLists.txt.

#4332 proposes moving the server headers somewhere internal, which removes two of the six either way, but not the curl four.

The open decisions in #4458 record the same disagreement, since whichever shape the transport rewrite takes has to say what happens to a Bazel consumer that includes a concrete header.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedGood for taking. Extra help will be provided by maintainerstriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions