1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

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.
This commit is contained in:
John Ericson 2025-02-26 11:28:23 -05:00
parent 8a9bde362a
commit fd25391628
3 changed files with 38 additions and 30 deletions

View file

@ -280,8 +280,6 @@
''^src/libstore/include/nix/store/build/derivation-building-goal\.hh$'' ''^src/libstore/include/nix/store/build/derivation-building-goal\.hh$''
''^src/libstore/build/derivation-goal\.cc$'' ''^src/libstore/build/derivation-goal\.cc$''
''^src/libstore/include/nix/store/build/derivation-goal\.hh$'' ''^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/entry-points\.cc$''
''^src/libstore/build/goal\.cc$'' ''^src/libstore/build/goal\.cc$''
''^src/libstore/include/nix/store/build/goal\.hh$'' ''^src/libstore/include/nix/store/build/goal\.hh$''

View file

@ -8,10 +8,7 @@
namespace nix { namespace nix {
DrvOutputSubstitutionGoal::DrvOutputSubstitutionGoal( DrvOutputSubstitutionGoal::DrvOutputSubstitutionGoal(
const DrvOutput & id, const DrvOutput & id, Worker & worker, RepairFlag repair, std::optional<ContentAddress> ca)
Worker & worker,
RepairFlag repair,
std::optional<ContentAddress> ca)
: Goal(worker, init()) : Goal(worker, init())
, id(id) , id(id)
{ {
@ -19,7 +16,6 @@ DrvOutputSubstitutionGoal::DrvOutputSubstitutionGoal(
trace("created"); trace("created");
} }
Goal::Co DrvOutputSubstitutionGoal::init() Goal::Co DrvOutputSubstitutionGoal::init()
{ {
trace("init"); trace("init");
@ -40,32 +36,35 @@ Goal::Co DrvOutputSubstitutionGoal::init()
some other error occurs), so it must not touch `this`. So put some other error occurs), so it must not touch `this`. So put
the shared state in a separate refcounted object. */ the shared state in a separate refcounted object. */
auto outPipe = std::make_shared<MuxablePipe>(); auto outPipe = std::make_shared<MuxablePipe>();
#ifndef _WIN32 #ifndef _WIN32
outPipe->create(); outPipe->create();
#else #else
outPipe->createAsyncPipe(worker.ioport.get()); outPipe->createAsyncPipe(worker.ioport.get());
#endif #endif
auto promise = std::make_shared<std::promise<std::shared_ptr<const Realisation>>>(); auto promise = std::make_shared<std::promise<std::shared_ptr<const Realisation>>>();
sub->queryRealisation( sub->queryRealisation(
id, id, {[outPipe(outPipe), promise(promise)](std::future<std::shared_ptr<const Realisation>> res) {
{ [outPipe(outPipe), promise(promise)](std::future<std::shared_ptr<const Realisation>> res) {
try { try {
Finally updateStats([&]() { outPipe->writeSide.close(); }); Finally updateStats([&]() { outPipe->writeSide.close(); });
promise->set_value(res.get()); promise->set_value(res.get());
} catch (...) { } catch (...) {
promise->set_exception(std::current_exception()); promise->set_exception(std::current_exception());
} }
} }); }});
worker.childStarted(shared_from_this(), { worker.childStarted(
#ifndef _WIN32 shared_from_this(),
{
#ifndef _WIN32
outPipe->readSide.get() outPipe->readSide.get()
#else #else
&*outPipe &*outPipe
#endif #endif
}, true, false); },
true,
false);
co_await Suspend{}; co_await Suspend{};
@ -84,7 +83,8 @@ Goal::Co DrvOutputSubstitutionGoal::init()
substituterFailed = true; substituterFailed = true;
} }
if (!outputInfo) continue; if (!outputInfo)
continue;
bool failed = false; bool failed = false;
@ -101,8 +101,7 @@ Goal::Co DrvOutputSubstitutionGoal::init()
sub->getUri(), sub->getUri(),
depId.to_string(), depId.to_string(),
worker.store.printStorePath(localOutputInfo->outPath), worker.store.printStorePath(localOutputInfo->outPath),
worker.store.printStorePath(depPath) worker.store.printStorePath(depPath));
);
failed = true; failed = true;
break; break;
} }
@ -110,7 +109,8 @@ Goal::Co DrvOutputSubstitutionGoal::init()
} }
} }
if (failed) continue; if (failed)
continue;
co_return realisationFetched(std::move(waitees), outputInfo, sub); co_return realisationFetched(std::move(waitees), outputInfo, sub);
} }
@ -130,7 +130,9 @@ Goal::Co DrvOutputSubstitutionGoal::init()
co_return amDone(substituterFailed ? ecFailed : ecNoSubstituters); co_return amDone(substituterFailed ? ecFailed : ecNoSubstituters);
} }
Goal::Co DrvOutputSubstitutionGoal::realisationFetched(Goals waitees, std::shared_ptr<const Realisation> outputInfo, nix::ref<nix::Store> sub) { Goal::Co DrvOutputSubstitutionGoal::realisationFetched(
Goals waitees, std::shared_ptr<const Realisation> outputInfo, nix::ref<nix::Store> sub)
{
waitees.insert(worker.makePathSubstitutionGoal(outputInfo->outPath)); waitees.insert(worker.makePathSubstitutionGoal(outputInfo->outPath));
co_await await(std::move(waitees)); co_await await(std::move(waitees));
@ -160,5 +162,4 @@ void DrvOutputSubstitutionGoal::handleEOF(Descriptor fd)
worker.wakeUp(shared_from_this()); worker.wakeUp(shared_from_this());
} }
} }

View file

@ -20,7 +20,8 @@ class Worker;
* 2. Substitute the corresponding output path * 2. Substitute the corresponding output path
* 3. Register the output info * 3. Register the output info
*/ */
class DrvOutputSubstitutionGoal : public Goal { class DrvOutputSubstitutionGoal : public Goal
{
/** /**
* The drv output we're trying to substitute * The drv output we're trying to substitute
@ -28,7 +29,11 @@ class DrvOutputSubstitutionGoal : public Goal {
DrvOutput id; DrvOutput id;
public: public:
DrvOutputSubstitutionGoal(const DrvOutput& id, Worker & worker, RepairFlag repair = NoRepair, std::optional<ContentAddress> ca = std::nullopt); DrvOutputSubstitutionGoal(
const DrvOutput & id,
Worker & worker,
RepairFlag repair = NoRepair,
std::optional<ContentAddress> ca = std::nullopt);
typedef void (DrvOutputSubstitutionGoal::*GoalState)(); typedef void (DrvOutputSubstitutionGoal::*GoalState)();
GoalState state; GoalState state;
@ -36,13 +41,17 @@ public:
Co init(); Co init();
Co realisationFetched(Goals waitees, std::shared_ptr<const Realisation> outputInfo, nix::ref<nix::Store> sub); Co realisationFetched(Goals waitees, std::shared_ptr<const Realisation> outputInfo, nix::ref<nix::Store> sub);
void timedOut(Error && ex) override { unreachable(); }; void timedOut(Error && ex) override
{
unreachable();
};
std::string key() override; std::string key() override;
void handleEOF(Descriptor fd) override; void handleEOF(Descriptor fd) override;
JobCategory jobCategory() const override { JobCategory jobCategory() const override
{
return JobCategory::Substitution; return JobCategory::Substitution;
}; };
}; };