From e5b9c86e59860f0a4c1cc5793b30e8be9c63a493 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 23 Mar 2025 15:36:11 +0100 Subject: [PATCH] libutil: remove *-json.hh headers we can inline them into their parents now. fixes #598 Change-Id: I7bc9371885cc0adde11da1e2c67bf0a4cf833a98 --- lix/libstore/build/derivation-goal.cc | 1 - lix/libutil/abstract-setting-to-json.hh | 2 -- lix/libutil/args.cc | 1 - lix/libutil/deprecated-features-json.hh | 23 ---------------- lix/libutil/deprecated-features.cc | 2 -- lix/libutil/deprecated-features.hh | 15 +++++++++++ lix/libutil/experimental-features-json.hh | 23 ---------------- lix/libutil/experimental-features.cc | 2 -- lix/libutil/experimental-features.hh | 15 +++++++++++ lix/libutil/logging-json.hh | 33 ----------------------- lix/libutil/logging.hh | 21 +++++++++++++++ lix/libutil/meson.build | 3 --- lix/nix/main.cc | 2 -- 13 files changed, 51 insertions(+), 92 deletions(-) delete mode 100644 lix/libutil/deprecated-features-json.hh delete mode 100644 lix/libutil/experimental-features-json.hh delete mode 100644 lix/libutil/logging-json.hh diff --git a/lix/libstore/build/derivation-goal.cc b/lix/libstore/build/derivation-goal.cc index 6896b6ef7..f96cec1ed 100644 --- a/lix/libstore/build/derivation-goal.cc +++ b/lix/libstore/build/derivation-goal.cc @@ -9,7 +9,6 @@ #include "lix/libstore/common-protocol.hh" #include "lix/libstore/common-protocol-impl.hh" // IWYU pragma: keep #include "lix/libstore/local-store.hh" // TODO remove, along with remaining downcasts -#include "lix/libutil/logging-json.hh" #include "lix/libstore/build/substitution-goal.hh" #include "lix/libstore/build/drv-output-substitution-goal.hh" #include "lix/libutil/result.hh" diff --git a/lix/libutil/abstract-setting-to-json.hh b/lix/libutil/abstract-setting-to-json.hh index f8f8c9636..ca1d35049 100644 --- a/lix/libutil/abstract-setting-to-json.hh +++ b/lix/libutil/abstract-setting-to-json.hh @@ -2,8 +2,6 @@ ///@file #include "lix/libutil/config.hh" -// Required for instances of to_json and from_json for ExperimentalFeature -#include "lix/libutil/experimental-features-json.hh" #include "lix/libutil/json.hh" namespace nix { diff --git a/lix/libutil/args.cc b/lix/libutil/args.cc index cb7eb9662..a95641b54 100644 --- a/lix/libutil/args.cc +++ b/lix/libutil/args.cc @@ -5,7 +5,6 @@ #include "lix/libutil/json.hh" // IWYU pragma: keep (instances) #include "lix/libutil/environment-variables.hh" -#include "lix/libutil/experimental-features-json.hh" // IWYU pragma: keep (instances) #include "lix/libutil/logging.hh" #include diff --git a/lix/libutil/deprecated-features-json.hh b/lix/libutil/deprecated-features-json.hh deleted file mode 100644 index e99613df0..000000000 --- a/lix/libutil/deprecated-features-json.hh +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -///@file - -#include "lix/libutil/deprecated-features.hh" -#include "lix/libutil/json-fwd.hh" - -namespace nix { - -/** - * Compute the documentation of all deprecated features. - * - * See `doc/manual` for how this information is used. - */ -JSON documentDeprecatedFeatures(); - -/** - * Semi-magic conversion to and from json. - * See the nlohmann/json readme for more details. - */ -void to_json(JSON &, const DeprecatedFeature &); -void from_json(const JSON &, DeprecatedFeature &); - -}; diff --git a/lix/libutil/deprecated-features.cc b/lix/libutil/deprecated-features.cc index ad2d1600b..f4737158e 100644 --- a/lix/libutil/deprecated-features.cc +++ b/lix/libutil/deprecated-features.cc @@ -1,6 +1,4 @@ #include "lix/libutil/deprecated-features.hh" -// Required for instances of to_json and from_json for DeprecatedFeature -#include "lix/libutil/deprecated-features-json.hh" #include "lix/libutil/json.hh" #include "lix/libutil/strings.hh" diff --git a/lix/libutil/deprecated-features.hh b/lix/libutil/deprecated-features.hh index 7f58ea3d3..f8c176e20 100644 --- a/lix/libutil/deprecated-features.hh +++ b/lix/libutil/deprecated-features.hh @@ -2,6 +2,7 @@ ///@file #include "lix/libutil/error.hh" +#include "lix/libutil/json-fwd.hh" #include "lix/libutil/types.hh" namespace nix { @@ -63,6 +64,20 @@ std::ostream & operator<<( */ DeprecatedFeatures parseDeprecatedFeatures(const std::set &); +/** + * Compute the documentation of all deprecated features. + * + * See `doc/manual` for how this information is used. + */ +JSON documentDeprecatedFeatures(); + +/** + * Semi-magic conversion to and from json. + * See the nlohmann/json readme for more details. + */ +void to_json(JSON &, const DeprecatedFeature &); +void from_json(const JSON &, DeprecatedFeature &); + /** * A deprecated feature used for some * operation, but was not enabled. diff --git a/lix/libutil/experimental-features-json.hh b/lix/libutil/experimental-features-json.hh deleted file mode 100644 index 1f34ccd52..000000000 --- a/lix/libutil/experimental-features-json.hh +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -///@file - -#include "lix/libutil/experimental-features.hh" -#include "lix/libutil/json-fwd.hh" - -namespace nix { - -/** - * Compute the documentation of all experimental features. - * - * See `doc/manual` for how this information is used. - */ -JSON documentExperimentalFeatures(); - -/** - * Semi-magic conversion to and from json. - * See the nlohmann/json readme for more details. - */ -void to_json(JSON &, const ExperimentalFeature &); -void from_json(const JSON &, ExperimentalFeature &); - -}; diff --git a/lix/libutil/experimental-features.cc b/lix/libutil/experimental-features.cc index 9982087f6..e8989c509 100644 --- a/lix/libutil/experimental-features.cc +++ b/lix/libutil/experimental-features.cc @@ -1,6 +1,4 @@ #include "lix/libutil/experimental-features.hh" -// Required for instances of to_json and from_json for ExperimentalFeature -#include "lix/libutil/experimental-features-json.hh" #include "lix/libutil/json.hh" #include "lix/libutil/strings.hh" diff --git a/lix/libutil/experimental-features.hh b/lix/libutil/experimental-features.hh index 349d71e4d..1026323a4 100644 --- a/lix/libutil/experimental-features.hh +++ b/lix/libutil/experimental-features.hh @@ -2,6 +2,7 @@ ///@file #include "lix/libutil/error.hh" +#include "lix/libutil/json-fwd.hh" #include "lix/libutil/types.hh" namespace nix { @@ -60,6 +61,20 @@ std::ostream & operator<<( */ ExperimentalFeatures parseFeatures(const std::set &); +/** + * Compute the documentation of all experimental features. + * + * See `doc/manual` for how this information is used. + */ +JSON documentExperimentalFeatures(); + +/** + * Semi-magic conversion to and from json. + * See the nlohmann/json readme for more details. + */ +void to_json(JSON &, const ExperimentalFeature &); +void from_json(const JSON &, ExperimentalFeature &); + /** * An experimental feature was required for some (experimental) * operation, but was not enabled. diff --git a/lix/libutil/logging-json.hh b/lix/libutil/logging-json.hh deleted file mode 100644 index d7404afdb..000000000 --- a/lix/libutil/logging-json.hh +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -///@file logging-json.hh -/// -///@brief Logging functions for json specifically, split due to the cost of -///including nlohmann. - -#include "lix/libutil/json-fwd.hh" -#include "lix/libutil/logging.hh" - -namespace nix { - -/** - * @param source A noun phrase describing the source of the message, e.g. "the builder". - */ -std::optional parseJSONMessage(const std::string & msg, std::string_view source); - -/** - * @param source A noun phrase describing the source of the message, e.g. "the builder". - */ -bool handleJSONLogMessage(JSON & json, - const Activity & act, std::map & activities, - std::string_view source, - bool trusted); - -/** - * @param source A noun phrase describing the source of the message, e.g. "the builder". - */ -bool handleJSONLogMessage(const std::string & msg, - const Activity & act, std::map & activities, - std::string_view source, - bool trusted); - -}; diff --git a/lix/libutil/logging.hh b/lix/libutil/logging.hh index 20588c828..97a00808b 100644 --- a/lix/libutil/logging.hh +++ b/lix/libutil/logging.hh @@ -307,4 +307,25 @@ void writeLogsToStderr(std::string_view s); * The purpose of this function is making failures with redirected stderr louder. */ void logFatal(std::string const & s); +/** + * @param source A noun phrase describing the source of the message, e.g. "the builder". + */ +std::optional parseJSONMessage(const std::string & msg, std::string_view source); + +/** + * @param source A noun phrase describing the source of the message, e.g. "the builder". + */ +bool handleJSONLogMessage(JSON & json, + const Activity & act, std::map & activities, + std::string_view source, + bool trusted); + +/** + * @param source A noun phrase describing the source of the message, e.g. "the builder". + */ +bool handleJSONLogMessage(const std::string & msg, + const Activity & act, std::map & activities, + std::string_view source, + bool trusted); + } diff --git a/lix/libutil/meson.build b/lix/libutil/meson.build index 642b87bcc..22798456f 100644 --- a/lix/libutil/meson.build +++ b/lix/libutil/meson.build @@ -77,7 +77,6 @@ libutil_headers = files( 'config-impl.hh', 'config.hh', 'current-process.hh', - 'deprecated-features-json.hh', 'deprecated-features.hh', 'english.hh', 'environment-variables.hh', @@ -85,7 +84,6 @@ libutil_headers = files( 'escape-char.hh', 'escape-string.hh', 'exit.hh', - 'experimental-features-json.hh', 'experimental-features.hh', 'file-descriptor.hh', 'file-system.hh', @@ -98,7 +96,6 @@ libutil_headers = files( 'input-accessor.hh', 'json-fwd.hh', 'json.hh', - 'logging-json.hh', 'logging.hh', 'lru-cache.hh', 'manually-drop.hh', diff --git a/lix/nix/main.cc b/lix/nix/main.cc index ca5bcd43c..b22f13217 100644 --- a/lix/nix/main.cc +++ b/lix/nix/main.cc @@ -14,8 +14,6 @@ #include "lix/libutil/json.hh" #include "lix/libmain/loggers.hh" #include "lix/libcmd/markdown.hh" -#include "lix/libutil/experimental-features-json.hh" -#include "lix/libutil/deprecated-features-json.hh" #include "add-to-store.hh" #include "build-remote.hh" #include "build.hh"