libmain: asyncify printMissing

Change-Id: Iac87ecbbab4c65ddd6e3a32bdb64107ed7f9b3c0
This commit is contained in:
eldritch horrors
2025-02-24 15:09:02 +00:00
parent 4042d9c167
commit e6fee559f7
7 changed files with 31 additions and 16 deletions
+5 -2
View File
@@ -315,8 +315,11 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
store->queryMissing(paths,
willBuild, willSubstitute, unknown, downloadSize, narSize);
if (settings.printMissing)
printMissing(ref<Store>(store), willBuild, willSubstitute, unknown, downloadSize, narSize);
if (settings.printMissing) {
aio.blockOn(printMissing(
ref<Store>(store), willBuild, willSubstitute, unknown, downloadSize, narSize
));
}
if (!dryRun)
aio.blockOn(store->buildPaths(paths, buildMode, evalStore));
+2 -2
View File
@@ -503,7 +503,7 @@ static void printMissing(EvalState & state, DrvInfos & elems)
.path = i.queryOutPath(state),
});
printMissing(state.ctx.store, targets);
state.aio.blockOn(printMissing(state.ctx.store, targets));
}
@@ -788,7 +788,7 @@ static void opSet(Globals & globals, Strings opFlags, Strings opArgs)
.path = drv.queryOutPath(*state),
}),
};
printMissing(globals.state->store, paths);
globals.aio.blockOn(printMissing(globals.state->store, paths));
if (globals.dryRun) return;
globals.aio.blockOn(
globals.state->store->buildPaths(paths, globals.state->repair ? bmRepair : bmNormal)
+5 -2
View File
@@ -154,8 +154,11 @@ static void opRealise(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
unknown = StorePathSet();
}
if (settings.printMissing)
printMissing(ref<Store>(store), willBuild, willSubstitute, unknown, downloadSize, narSize);
if (settings.printMissing) {
aio.blockOn(printMissing(
ref<Store>(store), willBuild, willSubstitute, unknown, downloadSize, narSize
));
}
if (dryRun) return;
+2 -2
View File
@@ -632,7 +632,7 @@ std::vector<std::pair<ref<Installable>, BuiltPathWithResult>> Installable::build
case Realise::Nothing:
case Realise::Derivation:
printMissing(store, pathsToBuild, lvlError);
state.aio.blockOn(printMissing(store, pathsToBuild, lvlError));
for (auto & path : pathsToBuild) {
for (auto & aux : backmap[path]) {
@@ -660,7 +660,7 @@ std::vector<std::pair<ref<Installable>, BuiltPathWithResult>> Installable::build
case Realise::Outputs: {
if (settings.printMissing)
printMissing(store, pathsToBuild, lvlInfo);
state.aio.blockOn(printMissing(store, pathsToBuild, lvlInfo));
auto buildResults =
state.aio.blockOn(store->buildPathsWithResults(pathsToBuild, bMode, evalStore));
+14 -5
View File
@@ -3,6 +3,7 @@
#include "lix/libmain/shared.hh"
#include "lix/libstore/store-api.hh"
#include "lix/libstore/gc-store.hh"
#include "lix/libutil/result.hh"
#include "lix/libutil/signals.hh"
#include "lix/libmain/loggers.hh"
#include "lix/libutil/current-process.hh"
@@ -46,19 +47,23 @@ void printGCWarning()
}
void printMissing(ref<Store> store, const std::vector<DerivedPath> & paths, Verbosity lvl)
{
kj::Promise<Result<void>>
printMissing(ref<Store> store, const std::vector<DerivedPath> & paths, Verbosity lvl)
try {
uint64_t downloadSize, narSize;
StorePathSet willBuild, willSubstitute, unknown;
store->queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize, narSize);
printMissing(store, willBuild, willSubstitute, unknown, downloadSize, narSize, lvl);
TRY_AWAIT(printMissing(store, willBuild, willSubstitute, unknown, downloadSize, narSize, lvl));
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
void printMissing(ref<Store> store, const StorePathSet & willBuild,
kj::Promise<Result<void>> printMissing(ref<Store> store, const StorePathSet & willBuild,
const StorePathSet & willSubstitute, const StorePathSet & unknown,
uint64_t downloadSize, uint64_t narSize, Verbosity lvl)
{
try {
if (!willBuild.empty()) {
if (willBuild.size() == 1)
printMsg(lvl, "this derivation will be built:");
@@ -103,6 +108,10 @@ void printMissing(ref<Store> store, const StorePathSet & willBuild,
for (auto & i : unknown)
printMsg(lvl, " %s", store->printStorePath(i));
}
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
+2 -2
View File
@@ -30,12 +30,12 @@ void printGCWarning();
class Store;
void printMissing(
kj::Promise<Result<void>> printMissing(
ref<Store> store,
const std::vector<DerivedPath> & paths,
Verbosity lvl = lvlInfo);
void printMissing(ref<Store> store, const StorePathSet & willBuild,
kj::Promise<Result<void>> printMissing(ref<Store> store, const StorePathSet & willBuild,
const StorePathSet & willSubstitute, const StorePathSet & unknown,
uint64_t downloadSize, uint64_t narSize, Verbosity lvl = lvlInfo);
+1 -1
View File
@@ -131,7 +131,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile
for (auto & b : i->toDerivedPaths(*state))
pathsToBuild.push_back(b.path);
printMissing(store, pathsToBuild, lvlError);
aio().blockOn(printMissing(store, pathsToBuild, lvlError));
if (json)
logger->cout("%s", derivedPathsToJSON(aio(), pathsToBuild, *store).dump());