chore(tvix): Thread a std::ostream through Store::buildPaths
This part of the store API needs to carry a handle to the log sink from now on, so that it can be passed in as appropriate from the gRPC handlers. In all places where there is no such handler available at the moment, the discarding log sink has been inserted. This can be used as a convenient grep target in the future. Change-Id: I26628e30b4c6437dccdf8f722ca2e8ed827dfc19 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1797 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com> Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
parent
f7fa77f14d
commit
33e8b0f975
15 changed files with 63 additions and 43 deletions
10
third_party/nix/src/libstore/build.cc
vendored
10
third_party/nix/src/libstore/build.cc
vendored
|
|
@ -7,6 +7,7 @@
|
|||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <queue>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
|
|
@ -4687,8 +4688,9 @@ static void primeCache(Store& store, const PathSet& paths) {
|
|||
}
|
||||
}
|
||||
|
||||
absl::Status LocalStore::buildPaths(const PathSet& drvPaths,
|
||||
BuildMode buildMode) {
|
||||
absl::Status LocalStore::buildPaths(std::ostream& /* log_sink */,
|
||||
const PathSet& drvPaths,
|
||||
BuildMode build_mode) {
|
||||
Worker worker(*this);
|
||||
|
||||
primeCache(*this, drvPaths);
|
||||
|
|
@ -4697,10 +4699,10 @@ absl::Status LocalStore::buildPaths(const PathSet& drvPaths,
|
|||
for (auto& i : drvPaths) {
|
||||
DrvPathWithOutputs i2 = parseDrvPathWithOutputs(i);
|
||||
if (isDerivation(i2.first)) {
|
||||
goals.insert(worker.makeDerivationGoal(i2.first, i2.second, buildMode));
|
||||
goals.insert(worker.makeDerivationGoal(i2.first, i2.second, build_mode));
|
||||
} else {
|
||||
goals.insert(worker.makeSubstitutionGoal(
|
||||
i, buildMode == bmRepair ? Repair : NoRepair));
|
||||
i, build_mode == bmRepair ? Repair : NoRepair));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
3
third_party/nix/src/libstore/local-store.hh
vendored
3
third_party/nix/src/libstore/local-store.hh
vendored
|
|
@ -156,7 +156,8 @@ class LocalStore : public LocalFSStore {
|
|||
Path addTextToStore(const std::string& name, const std::string& s,
|
||||
const PathSet& references, RepairFlag repair) override;
|
||||
|
||||
absl::Status buildPaths(const PathSet& paths, BuildMode buildMode) override;
|
||||
absl::Status buildPaths(std::ostream& log_sink, const PathSet& paths,
|
||||
BuildMode build_mode) override;
|
||||
|
||||
BuildResult buildDerivation(const Path& drvPath, const BasicDerivation& drv,
|
||||
BuildMode buildMode) override;
|
||||
|
|
|
|||
9
third_party/nix/src/libstore/remote-store.cc
vendored
9
third_party/nix/src/libstore/remote-store.cc
vendored
|
|
@ -460,18 +460,19 @@ Path RemoteStore::addTextToStore(const std::string& name, const std::string& s,
|
|||
return readStorePath(*this, conn->from);
|
||||
}
|
||||
|
||||
absl::Status RemoteStore::buildPaths(const PathSet& drvPaths,
|
||||
BuildMode buildMode) {
|
||||
absl::Status RemoteStore::buildPaths(std::ostream& /* log_sink */,
|
||||
const PathSet& drvPaths,
|
||||
BuildMode build_mode) {
|
||||
auto conn(getConnection());
|
||||
conn->to << wopBuildPaths;
|
||||
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 13) {
|
||||
conn->to << drvPaths;
|
||||
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 15) {
|
||||
conn->to << buildMode;
|
||||
conn->to << build_mode;
|
||||
} else
|
||||
/* Old daemons did not take a 'buildMode' parameter, so we
|
||||
need to validate it here on the client side. */
|
||||
if (buildMode != bmNormal) {
|
||||
if (build_mode != bmNormal) {
|
||||
return absl::Status(
|
||||
absl::StatusCode::kInvalidArgument,
|
||||
"repairing or checking is not supported when building through the "
|
||||
|
|
|
|||
3
third_party/nix/src/libstore/remote-store.hh
vendored
3
third_party/nix/src/libstore/remote-store.hh
vendored
|
|
@ -71,7 +71,8 @@ class RemoteStore : public virtual Store {
|
|||
Path addTextToStore(const std::string& name, const std::string& s,
|
||||
const PathSet& references, RepairFlag repair) override;
|
||||
|
||||
absl::Status buildPaths(const PathSet& paths, BuildMode buildMode) override;
|
||||
absl::Status buildPaths(std::ostream& log_sink, const PathSet& paths,
|
||||
BuildMode build_mode) override;
|
||||
|
||||
BuildResult buildDerivation(const Path& drvPath, const BasicDerivation& drv,
|
||||
BuildMode buildMode) override;
|
||||
|
|
|
|||
21
third_party/nix/src/libstore/rpc-store.cc
vendored
21
third_party/nix/src/libstore/rpc-store.cc
vendored
|
|
@ -4,6 +4,7 @@
|
|||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
|
||||
#include <absl/status/status.h>
|
||||
#include <absl/strings/str_cat.h>
|
||||
|
|
@ -318,7 +319,8 @@ Path RpcStore::addTextToStore(const std::string& name,
|
|||
return result.path();
|
||||
}
|
||||
|
||||
absl::Status RpcStore::buildPaths(const PathSet& paths, BuildMode buildMode) {
|
||||
absl::Status RpcStore::buildPaths(std::ostream& log_sink, const PathSet& paths,
|
||||
BuildMode build_mode) {
|
||||
ClientContext ctx;
|
||||
proto::BuildPathsRequest request;
|
||||
for (const auto& path : paths) {
|
||||
|
|
@ -326,14 +328,7 @@ absl::Status RpcStore::buildPaths(const PathSet& paths, BuildMode buildMode) {
|
|||
}
|
||||
|
||||
google::protobuf::Empty response;
|
||||
request.set_mode(nix::BuildModeToProto(buildMode));
|
||||
|
||||
// TODO(tazjin): Temporary no-op sink used to discard build output,
|
||||
// but satisfy the compiler. A real one is needed.
|
||||
//
|
||||
// Maybe this should just be stderr, considering that this is the
|
||||
// *client*, but I'm not sure.
|
||||
std::ostream discard_logs = DiscardLogsSink();
|
||||
request.set_mode(nix::BuildModeToProto(build_mode));
|
||||
|
||||
std::unique_ptr<grpc::ClientReader<proto::BuildEvent>> reader =
|
||||
stub_->BuildPaths(&ctx, request);
|
||||
|
|
@ -342,11 +337,11 @@ absl::Status RpcStore::buildPaths(const PathSet& paths, BuildMode buildMode) {
|
|||
while (reader->Read(&event)) {
|
||||
if (event.has_build_log()) {
|
||||
// TODO(tazjin): Include .path()?
|
||||
discard_logs << event.build_log().line();
|
||||
log_sink << event.build_log().line();
|
||||
} else {
|
||||
discard_logs << std::endl
|
||||
<< "Building path: " << event.building_path().path()
|
||||
<< std::endl;
|
||||
log_sink << std::endl
|
||||
<< "Building path: " << event.building_path().path()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
// has_result() is not in use in this call (for now)
|
||||
|
|
|
|||
4
third_party/nix/src/libstore/rpc-store.hh
vendored
4
third_party/nix/src/libstore/rpc-store.hh
vendored
|
|
@ -67,8 +67,8 @@ class RpcStore : public LocalFSStore, public virtual Store {
|
|||
const PathSet& references,
|
||||
RepairFlag repair = NoRepair) override;
|
||||
|
||||
virtual absl::Status buildPaths(const PathSet& paths,
|
||||
BuildMode buildMode) override;
|
||||
absl::Status buildPaths(std::ostream& log_sink, const PathSet& paths,
|
||||
BuildMode build_mode) override;
|
||||
|
||||
virtual BuildResult buildDerivation(const Path& drvPath,
|
||||
const BasicDerivation& drv,
|
||||
|
|
|
|||
3
third_party/nix/src/libstore/store-api.cc
vendored
3
third_party/nix/src/libstore/store-api.cc
vendored
|
|
@ -714,7 +714,8 @@ const Store::Stats& Store::getStats() {
|
|||
return stats;
|
||||
}
|
||||
|
||||
absl::Status Store::buildPaths(const PathSet& paths, BuildMode) {
|
||||
absl::Status Store::buildPaths(std::ostream& /* log_sink */,
|
||||
const PathSet& paths, BuildMode) {
|
||||
for (auto& path : paths) {
|
||||
if (isDerivation(path)) {
|
||||
return absl::Status(absl::StatusCode::kUnimplemented,
|
||||
|
|
|
|||
10
third_party/nix/src/libstore/store-api.hh
vendored
10
third_party/nix/src/libstore/store-api.hh
vendored
|
|
@ -455,11 +455,13 @@ class Store : public std::enable_shared_from_this<Store>, public Config {
|
|||
output paths can be created by running the builder, after
|
||||
recursively building any sub-derivations. For inputs that are
|
||||
not derivations, substitute them. */
|
||||
[[nodiscard]] virtual absl::Status buildPaths(const PathSet& paths,
|
||||
BuildMode buildMode);
|
||||
[[nodiscard]] virtual absl::Status buildPaths(std::ostream& log_sink,
|
||||
const PathSet& paths,
|
||||
BuildMode build_mode);
|
||||
|
||||
[[nodiscard]] absl::Status buildPaths(const PathSet& paths) {
|
||||
return buildPaths(paths, bmNormal);
|
||||
[[nodiscard]] absl::Status buildPaths(std::ostream& log_sink,
|
||||
const PathSet& paths) {
|
||||
return buildPaths(log_sink, paths, bmNormal);
|
||||
}
|
||||
|
||||
/* Build a single non-materialized derivation (i.e. not from an
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue