From 1f4bbded618d405199b3e758bf57d567b7446056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 11 Dec 2023 22:05:02 +0100 Subject: [PATCH] optimize imports with "include-what-you-use" --- src/buffered-io.cc | 6 +++++- src/drv.cc | 21 ++++++++++++++++++-- src/drv.hh | 16 ++++++++++----- src/eval-args.cc | 12 +++++++++++ src/eval-args.hh | 7 ++++++- src/nix-eval-jobs.cc | 47 +++++++++++++++++++++++++++++++------------- src/worker.cc | 46 +++++++++++++++++++++++++++++++++++++++---- src/worker.hh | 10 +++++++++- 8 files changed, 137 insertions(+), 28 deletions(-) diff --git a/src/buffered-io.cc b/src/buffered-io.cc index 6d3ab6d..4354740 100644 --- a/src/buffered-io.cc +++ b/src/buffered-io.cc @@ -1,7 +1,11 @@ -#include "buffered-io.hh" #include #include #include +#include +#include +#include + +#include "buffered-io.hh" [[nodiscard]] int tryWriteLine(int fd, std::string s) { s += "\n"; diff --git a/src/drv.cc b/src/drv.cc index 2eca9b0..14fd352 100644 --- a/src/drv.cc +++ b/src/drv.cc @@ -1,10 +1,27 @@ -#include "drv.hh" -#include +#include // IWYU pragma: keep + #include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "drv.hh" +#include "eval-args.hh" static bool queryIsCached(nix::Store &store, std::map &outputs) { diff --git a/src/drv.hh b/src/drv.hh index 4f1fbd0..a5de64a 100644 --- a/src/drv.hh +++ b/src/drv.hh @@ -1,16 +1,22 @@ +#include +#include +#include +#include #include #include #include #include #include -#include -#include - -#include - #include "eval-args.hh" +class MyArgs; + +namespace nix { +class EvalState; +struct DrvInfo; +} // namespace nix + /* The fields of a derivation that are printed in json form */ struct Drv { std::string name; diff --git a/src/eval-args.cc b/src/eval-args.cc index b25ecc7..5ccf732 100644 --- a/src/eval-args.cc +++ b/src/eval-args.cc @@ -1,3 +1,15 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "eval-args.hh" MyArgs::MyArgs() : MixCommonArgs("nix-eval-jobs") { diff --git a/src/eval-args.hh b/src/eval-args.hh index e0ce2d2..fe50583 100644 --- a/src/eval-args.hh +++ b/src/eval-args.hh @@ -1,9 +1,14 @@ #pragma once -#include #include #include #include +#include +#include +#include +#include +#include +#include class MyArgs : virtual public nix::MixEvalArgs, virtual public nix::MixCommonArgs, diff --git a/src/nix-eval-jobs.cc b/src/nix-eval-jobs.cc index 0fe5a39..704afe1 100644 --- a/src/nix-eval-jobs.cc +++ b/src/nix-eval-jobs.cc @@ -1,30 +1,49 @@ -#include -#include -#include -#include -#include +#include // IWYU pragma: keep -#include #include -#include -#include #include #include #include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "eval-args.hh" -#include "drv.hh" #include "buffered-io.hh" #include "worker.hh" -#include - using namespace nix; using namespace nlohmann; diff --git a/src/worker.cc b/src/worker.cc index 42d4d73..cb0a7d3 100644 --- a/src/worker.cc +++ b/src/worker.cc @@ -1,14 +1,52 @@ -#include "worker.hh" -#include "drv.hh" -#include "buffered-io.hh" +#include // IWYU pragma: keep + +// doesn't exist on macOS +// IWYU pragma: no_include #include #include #include #include - #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "worker.hh" +#include "drv.hh" +#include "buffered-io.hh" +#include "eval-args.hh" static nix::Value *releaseExprTopLevelValue(nix::EvalState &state, nix::Bindings &autoArgs, diff --git a/src/worker.hh b/src/worker.hh index 0f7d735..45e9032 100644 --- a/src/worker.hh +++ b/src/worker.hh @@ -1,9 +1,17 @@ #pragma once -#include #include #include #include "eval-args.hh" +class MyArgs; + +namespace nix { +class AutoCloseFD; +class Bindings; +class EvalState; +template class ref; +} // namespace nix + void worker(nix::ref state, nix::Bindings &autoArgs, nix::AutoCloseFD &to, nix::AutoCloseFD &from, MyArgs &args);