Skip to content

Commit

Permalink
Modularise folly/logging:logging
Browse files Browse the repository at this point in the history
Summary:
Allows `folly/logging:logging` to be imported as a C++20 header unit (module) in dependant targets that use header units (`use_header_units=True`).

This does not impact any other target, including `logging` itself. Right now, no target uses modules yet, so this change should do nothing, unless you request to build the module explicitly (`[header-unit]` subtarget).

Caveat: `xlog.h` can be modularised, but the anonymous namespace trick used to implement `XLOG_SET_CATEGORY_NAME` does not work if the library is imported as a header unit (or any kind of C++ module, in fact). Eventually, I think we should phase out the usage of `XLOG_SET_CATEGORY_NAME` inside fbcode, as it seems very seldom used: fbgs returns one instance. (T204728450)

On the other hand, the same anonymous namespace trick means that `xlog.h` must be modularised if we want to use it in any other module (i.e. if we want to turn any header which includes `xlog.h` into its own module), since the anonymous namespace cannot be duplicated.

Reviewed By: dmpolukhin

Differential Revision: D64400928

fbshipit-source-id: 16929a082a4c362817c57511aedadb1693686401
  • Loading branch information
Nhat Minh Le authored and facebook-github-bot committed Oct 16, 2024
1 parent 33c3f25 commit f01c6bb
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions folly/logging/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ cpp_library(
"StreamHandlerFactory.h",
"xlog.h",
],
export_header_unit = "preload",
preprocessor_flags = [
"-DFOLLY_XLOG_SUPPORT_BUCK2",
],
Expand Down

0 comments on commit f01c6bb

Please sign in to comment.