diff --git a/BUILD.bazel b/BUILD.bazel index aee45348..2ba20a29 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -10,6 +10,16 @@ licenses(["notice"]) # MIT # Configuration Flags # ============================================================================== +label_flag( + name = "std_module", + build_setting_default = ":empty_std_module", +) + +config_setting( + name = "config_std_module_empty", + flag_values = {":std_module": ":empty_std_module"}, +) + bool_flag( name = "no_exceptions", build_setting_default = False, @@ -192,6 +202,10 @@ cc_library( includes = ["include"], ) +cc_library( + name = "empty_std_module", +) + quill_module( name = "quill_module", copts = select({ @@ -199,7 +213,10 @@ quill_module( "@rules_cc//cc/compiler:clang": ["-Wno-gnu-zero-variadic-macro-arguments"], "//conditions:default": [], }), - defines = ["QUILL_USE_MODULE="], + defines = ["QUILL_USE_MODULE="] + select({ + ":config_std_module_empty": [], + "//conditions:default": ["QUILL_IMPORT_STD"], + }), # rules_cc 0.2.22 uses the same module metadata path for PIC and non-PIC outputs. features = [ "cpp_modules", @@ -208,5 +225,8 @@ quill_module( module_interfaces = ["src/quill.cc"], # Prevent users without --experimental_cpp_modules support from accidentally building this tags = ["manual"], - deps = [":quill"], + deps = [":quill"] + select({ + ":config_std_module_empty": [], + "//conditions:default": [":std_module"], + }), ) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ed2d028..3fdde534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,6 +111,8 @@ Use `register_*_family()` when there is no initial metadata pointer to register. - Added the opt-in `QUILL_IMPORT_STD` option for named module builds on toolchains supporting `import std`; standard library headers remain the default. +- Added the `--@quill//:std_module` Bazel flag to configure the standard library module target + for `quill_module`, automatically enabling `QUILL_IMPORT_STD`. - CMake and Bazel module targets now define `QUILL_USE_MODULE` automatically for consumers, while retaining compatibility with an explicit `#define QUILL_USE_MODULE` in source code. - Uncaught exceptions from `Frontend` logger creation and sink lookup or creation no longer leave diff --git a/docs/installing.rst b/docs/installing.rst index c7fbd46d..85bc43b5 100644 --- a/docs/installing.rst +++ b/docs/installing.rst @@ -158,6 +158,12 @@ whole build and pass ``--experimental_cpp_modules`` (for Clang, use deps = ["@quill//:quill_module"], ) +To enable experimental ``import std`` support with Bazel, configure the ``--@quill//:std_module`` +flag to point to your toolchain's standard library module target (for example, in ``.bazelrc`` via +``build --@quill//:std_module=@std_module``). When configured, Quill automatically defines +``QUILL_IMPORT_STD`` and adds the target as a dependency. If omitted, ``@quill//:std_module`` +defaults to an empty target, falling back to standard library headers. + The selected Clang toolchain must also provide a matching ``clang-scan-deps`` beside the compiler executable. On Ubuntu 24.04, install ``clang-18`` and ``clang-tools-18``, and set ``CC=/usr/lib/llvm-18/bin/clang`` and ``CXX=/usr/lib/llvm-18/bin/clang++``.