From fd25391628ac9ab9c60807b239c11006b32682d9 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 26 Feb 2025 11:28:23 -0500 Subject: [PATCH] Format `src/libstore/build/drv-output-substitution-goal.{cc,hh}` I am about to change these files a lot, so before I do so is a good time to remove them from the no-formatting blacklist. --- maintainers/flake-module.nix | 2 - .../build/drv-output-substitution-goal.cc | 49 ++++++++++--------- .../build/drv-output-substitution-goal.hh | 17 +++++-- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/maintainers/flake-module.nix b/maintainers/flake-module.nix index 224f47268..d548f419b 100644 --- a/maintainers/flake-module.nix +++ b/maintainers/flake-module.nix @@ -280,8 +280,6 @@ ''^src/libstore/include/nix/store/build/derivation-building-goal\.hh$'' ''^src/libstore/build/derivation-goal\.cc$'' ''^src/libstore/include/nix/store/build/derivation-goal\.hh$'' - ''^src/libstore/build/drv-output-substitution-goal\.cc$'' - ''^src/libstore/include/nix/store/build/drv-output-substitution-goal\.hh$'' ''^src/libstore/build/entry-points\.cc$'' ''^src/libstore/build/goal\.cc$'' ''^src/libstore/include/nix/store/build/goal\.hh$'' diff --git a/src/libstore/build/drv-output-substitution-goal.cc b/src/libstore/build/drv-output-substitution-goal.cc index e87a796f6..71acc3ec2 100644 --- a/src/libstore/build/drv-output-substitution-goal.cc +++ b/src/libstore/build/drv-output-substitution-goal.cc @@ -8,10 +8,7 @@ namespace nix { DrvOutputSubstitutionGoal::DrvOutputSubstitutionGoal( - const DrvOutput & id, - Worker & worker, - RepairFlag repair, - std::optional ca) + const DrvOutput & id, Worker & worker, RepairFlag repair, std::optional ca) : Goal(worker, init()) , id(id) { @@ -19,7 +16,6 @@ DrvOutputSubstitutionGoal::DrvOutputSubstitutionGoal( trace("created"); } - Goal::Co DrvOutputSubstitutionGoal::init() { trace("init"); @@ -40,32 +36,35 @@ Goal::Co DrvOutputSubstitutionGoal::init() some other error occurs), so it must not touch `this`. So put the shared state in a separate refcounted object. */ auto outPipe = std::make_shared(); - #ifndef _WIN32 +#ifndef _WIN32 outPipe->create(); - #else +#else outPipe->createAsyncPipe(worker.ioport.get()); - #endif +#endif auto promise = std::make_shared>>(); sub->queryRealisation( - id, - { [outPipe(outPipe), promise(promise)](std::future> res) { + id, {[outPipe(outPipe), promise(promise)](std::future> res) { try { Finally updateStats([&]() { outPipe->writeSide.close(); }); promise->set_value(res.get()); } catch (...) { promise->set_exception(std::current_exception()); } - } }); + }}); - worker.childStarted(shared_from_this(), { - #ifndef _WIN32 - outPipe->readSide.get() - #else - &*outPipe - #endif - }, true, false); + worker.childStarted( + shared_from_this(), + { +#ifndef _WIN32 + outPipe->readSide.get() +#else + &*outPipe +#endif + }, + true, + false); co_await Suspend{}; @@ -84,7 +83,8 @@ Goal::Co DrvOutputSubstitutionGoal::init() substituterFailed = true; } - if (!outputInfo) continue; + if (!outputInfo) + continue; bool failed = false; @@ -101,8 +101,7 @@ Goal::Co DrvOutputSubstitutionGoal::init() sub->getUri(), depId.to_string(), worker.store.printStorePath(localOutputInfo->outPath), - worker.store.printStorePath(depPath) - ); + worker.store.printStorePath(depPath)); failed = true; break; } @@ -110,7 +109,8 @@ Goal::Co DrvOutputSubstitutionGoal::init() } } - if (failed) continue; + if (failed) + continue; co_return realisationFetched(std::move(waitees), outputInfo, sub); } @@ -130,7 +130,9 @@ Goal::Co DrvOutputSubstitutionGoal::init() co_return amDone(substituterFailed ? ecFailed : ecNoSubstituters); } -Goal::Co DrvOutputSubstitutionGoal::realisationFetched(Goals waitees, std::shared_ptr outputInfo, nix::ref sub) { +Goal::Co DrvOutputSubstitutionGoal::realisationFetched( + Goals waitees, std::shared_ptr outputInfo, nix::ref sub) +{ waitees.insert(worker.makePathSubstitutionGoal(outputInfo->outPath)); co_await await(std::move(waitees)); @@ -160,5 +162,4 @@ void DrvOutputSubstitutionGoal::handleEOF(Descriptor fd) worker.wakeUp(shared_from_this()); } - } diff --git a/src/libstore/include/nix/store/build/drv-output-substitution-goal.hh b/src/libstore/include/nix/store/build/drv-output-substitution-goal.hh index 0176f001a..60892d84e 100644 --- a/src/libstore/include/nix/store/build/drv-output-substitution-goal.hh +++ b/src/libstore/include/nix/store/build/drv-output-substitution-goal.hh @@ -20,7 +20,8 @@ class Worker; * 2. Substitute the corresponding output path * 3. Register the output info */ -class DrvOutputSubstitutionGoal : public Goal { +class DrvOutputSubstitutionGoal : public Goal +{ /** * The drv output we're trying to substitute @@ -28,7 +29,11 @@ class DrvOutputSubstitutionGoal : public Goal { DrvOutput id; public: - DrvOutputSubstitutionGoal(const DrvOutput& id, Worker & worker, RepairFlag repair = NoRepair, std::optional ca = std::nullopt); + DrvOutputSubstitutionGoal( + const DrvOutput & id, + Worker & worker, + RepairFlag repair = NoRepair, + std::optional ca = std::nullopt); typedef void (DrvOutputSubstitutionGoal::*GoalState)(); GoalState state; @@ -36,13 +41,17 @@ public: Co init(); Co realisationFetched(Goals waitees, std::shared_ptr outputInfo, nix::ref sub); - void timedOut(Error && ex) override { unreachable(); }; + void timedOut(Error && ex) override + { + unreachable(); + }; std::string key() override; void handleEOF(Descriptor fd) override; - JobCategory jobCategory() const override { + JobCategory jobCategory() const override + { return JobCategory::Substitution; }; };