cli: asyncify print{DotGraph,GraphML}
Change-Id: I0fc13a861acee55c53c4ae5f6ba77b4100fd8735
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "dotgraph.hh"
|
||||
#include "lix/libstore/store-api.hh"
|
||||
#include "lix/libutil/result.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -41,8 +42,8 @@ static std::string makeNode(std::string_view id, std::string_view label,
|
||||
}
|
||||
|
||||
|
||||
void printDotGraph(ref<Store> store, StorePathSet && roots)
|
||||
{
|
||||
kj::Promise<Result<void>> printDotGraph(ref<Store> store, StorePathSet && roots)
|
||||
try {
|
||||
StorePathSet workList(std::move(roots));
|
||||
StorePathSet doneSet;
|
||||
|
||||
@@ -64,6 +65,9 @@ void printDotGraph(ref<Store> store, StorePathSet && roots)
|
||||
}
|
||||
|
||||
cout << "}\n";
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
void printDotGraph(ref<Store> store, StorePathSet && roots);
|
||||
kj::Promise<Result<void>> printDotGraph(ref<Store> store, StorePathSet && roots);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "graphml.hh"
|
||||
#include "lix/libstore/store-api.hh"
|
||||
#include "lix/libstore/derivations.hh"
|
||||
#include "lix/libutil/result.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -46,8 +47,8 @@ static std::string makeNode(const ValidPathInfo & info)
|
||||
}
|
||||
|
||||
|
||||
void printGraphML(ref<Store> store, StorePathSet && roots)
|
||||
{
|
||||
kj::Promise<Result<void>> printGraphML(ref<Store> store, StorePathSet && roots)
|
||||
try {
|
||||
StorePathSet workList(std::move(roots));
|
||||
StorePathSet doneSet;
|
||||
std::pair<StorePathSet::iterator, bool> ret;
|
||||
@@ -81,6 +82,9 @@ void printGraphML(ref<Store> store, StorePathSet && roots)
|
||||
|
||||
cout << "</graph>\n";
|
||||
cout << "</graphml>\n";
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
void printGraphML(ref<Store> store, StorePathSet && roots);
|
||||
kj::Promise<Result<void>> printGraphML(ref<Store> store, StorePathSet && roots);
|
||||
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
for (auto & i : opArgs)
|
||||
for (auto & j : aio.blockOn(maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise)))
|
||||
roots.insert(j);
|
||||
printDotGraph(ref<Store>(store), std::move(roots));
|
||||
aio.blockOn(printDotGraph(ref<Store>(store), std::move(roots)));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
for (auto & i : opArgs)
|
||||
for (auto & j : aio.blockOn(maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise)))
|
||||
roots.insert(j);
|
||||
printGraphML(ref<Store>(store), std::move(roots));
|
||||
aio.blockOn(printGraphML(ref<Store>(store), std::move(roots)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user