Skip to content

Commit 5d308cc

Browse files
committed
printMissing(): Take a MissingPaths argument
1 parent af05ce0 commit 5d308cc

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

src/libmain/include/nix/main/shared.hh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@ void printVersion(const std::string & programName);
3535
void printGCWarning();
3636

3737
class Store;
38+
struct MissingPaths;
3839

3940
void printMissing(
4041
ref<Store> store,
4142
const std::vector<DerivedPath> & paths,
4243
Verbosity lvl = lvlInfo);
4344

44-
void printMissing(ref<Store> store, const StorePathSet & willBuild,
45-
const StorePathSet & willSubstitute, const StorePathSet & unknown,
46-
uint64_t downloadSize, uint64_t narSize, Verbosity lvl = lvlInfo);
45+
void printMissing(
46+
ref<Store> store,
47+
const MissingPaths & missing,
48+
Verbosity lvl = lvlInfo);
4749

4850
std::string getArg(const std::string & opt,
4951
Strings::iterator & i, const Strings::iterator & end);

src/libmain/shared.cc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,41 @@ void printGCWarning()
4646

4747
void printMissing(ref<Store> store, const std::vector<DerivedPath> & paths, Verbosity lvl)
4848
{
49-
auto missing = store->queryMissing(paths);
50-
printMissing(store, missing.willBuild, missing.willSubstitute, missing.unknown, missing.downloadSize, missing.narSize, lvl);
49+
printMissing(store, store->queryMissing(paths), lvl);
5150
}
5251

5352

54-
void printMissing(ref<Store> store, const StorePathSet & willBuild,
55-
const StorePathSet & willSubstitute, const StorePathSet & unknown,
56-
uint64_t downloadSize, uint64_t narSize, Verbosity lvl)
53+
void printMissing(
54+
ref<Store> store,
55+
const MissingPaths & missing,
56+
Verbosity lvl)
5757
{
58-
if (!willBuild.empty()) {
59-
if (willBuild.size() == 1)
58+
if (!missing.willBuild.empty()) {
59+
if (missing.willBuild.size() == 1)
6060
printMsg(lvl, "this derivation will be built:");
6161
else
62-
printMsg(lvl, "these %d derivations will be built:", willBuild.size());
63-
auto sorted = store->topoSortPaths(willBuild);
62+
printMsg(lvl, "these %d derivations will be built:", missing.willBuild.size());
63+
auto sorted = store->topoSortPaths(missing.willBuild);
6464
reverse(sorted.begin(), sorted.end());
6565
for (auto & i : sorted)
6666
printMsg(lvl, " %s", store->printStorePath(i));
6767
}
6868

69-
if (!willSubstitute.empty()) {
70-
const float downloadSizeMiB = downloadSize / (1024.f * 1024.f);
71-
const float narSizeMiB = narSize / (1024.f * 1024.f);
72-
if (willSubstitute.size() == 1) {
69+
if (!missing.willSubstitute.empty()) {
70+
const float downloadSizeMiB = missing.downloadSize / (1024.f * 1024.f);
71+
const float narSizeMiB = missing.narSize / (1024.f * 1024.f);
72+
if (missing.willSubstitute.size() == 1) {
7373
printMsg(lvl, "this path will be fetched (%.2f MiB download, %.2f MiB unpacked):",
7474
downloadSizeMiB,
7575
narSizeMiB);
7676
} else {
7777
printMsg(lvl, "these %d paths will be fetched (%.2f MiB download, %.2f MiB unpacked):",
78-
willSubstitute.size(),
78+
missing.willSubstitute.size(),
7979
downloadSizeMiB,
8080
narSizeMiB);
8181
}
8282
std::vector<const StorePath *> willSubstituteSorted = {};
83-
std::for_each(willSubstitute.begin(), willSubstitute.end(),
83+
std::for_each(missing.willSubstitute.begin(), missing.willSubstitute.end(),
8484
[&](const StorePath &p) { willSubstituteSorted.push_back(&p); });
8585
std::sort(willSubstituteSorted.begin(), willSubstituteSorted.end(),
8686
[](const StorePath *lhs, const StorePath *rhs) {
@@ -93,10 +93,10 @@ void printMissing(ref<Store> store, const StorePathSet & willBuild,
9393
printMsg(lvl, " %s", store->printStorePath(*p));
9494
}
9595

96-
if (!unknown.empty()) {
96+
if (!missing.unknown.empty()) {
9797
printMsg(lvl, "don't know how to build these paths%s:",
9898
(settings.readOnlyMode ? " (may be caused by read-only store access)" : ""));
99-
for (auto & i : unknown)
99+
for (auto & i : missing.unknown)
100100
printMsg(lvl, " %s", store->printStorePath(i));
101101
}
102102
}

src/nix-build/nix-build.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static void main_nix_build(int argc, char * * argv)
425425
auto missing = store->queryMissing(paths);
426426

427427
if (settings.printMissing)
428-
printMissing(ref<Store>(store), missing.willBuild, missing.willSubstitute, missing.unknown, missing.downloadSize, missing.narSize);
428+
printMissing(ref<Store>(store), missing);
429429

430430
if (!dryRun)
431431
store->buildPaths(paths, buildMode, evalStore);

src/nix-store/nix-store.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static void opRealise(Strings opFlags, Strings opArgs)
158158
}
159159

160160
if (settings.printMissing)
161-
printMissing(ref<Store>(store), missing.willBuild, missing.willSubstitute, missing.unknown, missing.downloadSize, missing.narSize);
161+
printMissing(ref<Store>(store), missing);
162162

163163
if (dryRun) return;
164164

0 commit comments

Comments
 (0)