2022-03-01 19:43:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "realisation.hh"
|
2022-04-04 14:49:39 +00:00
|
|
|
#include "derived-path.hh"
|
2022-03-01 19:43:07 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <chrono>
|
2022-11-18 12:40:59 +00:00
|
|
|
#include <optional>
|
2022-03-01 19:43:07 +00:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
struct BuildResult
|
|
|
|
{
|
|
|
|
/* Note: don't remove status codes, and only add new status codes
|
|
|
|
at the end of the list, to prevent client/server
|
|
|
|
incompatibilities in the nix-store --serve protocol. */
|
|
|
|
enum Status {
|
|
|
|
Built = 0,
|
|
|
|
Substituted,
|
|
|
|
AlreadyValid,
|
|
|
|
PermanentFailure,
|
|
|
|
InputRejected,
|
|
|
|
OutputRejected,
|
|
|
|
TransientFailure, // possibly transient
|
|
|
|
CachedFailure, // no longer used
|
|
|
|
TimedOut,
|
|
|
|
MiscFailure,
|
|
|
|
DependencyFailed,
|
|
|
|
LogLimitExceeded,
|
|
|
|
NotDeterministic,
|
|
|
|
ResolvesToAlreadyValid,
|
2022-03-08 18:50:46 +00:00
|
|
|
NoSubstituters,
|
2022-03-01 19:43:07 +00:00
|
|
|
} status = MiscFailure;
|
2022-04-08 09:48:30 +00:00
|
|
|
|
|
|
|
// FIXME: include entire ErrorInfo object.
|
2022-03-01 19:43:07 +00:00
|
|
|
std::string errorMsg;
|
|
|
|
|
|
|
|
std::string toString() const {
|
|
|
|
auto strStatus = [&]() {
|
|
|
|
switch (status) {
|
|
|
|
case Built: return "Built";
|
|
|
|
case Substituted: return "Substituted";
|
|
|
|
case AlreadyValid: return "AlreadyValid";
|
|
|
|
case PermanentFailure: return "PermanentFailure";
|
|
|
|
case InputRejected: return "InputRejected";
|
|
|
|
case OutputRejected: return "OutputRejected";
|
|
|
|
case TransientFailure: return "TransientFailure";
|
|
|
|
case CachedFailure: return "CachedFailure";
|
|
|
|
case TimedOut: return "TimedOut";
|
|
|
|
case MiscFailure: return "MiscFailure";
|
|
|
|
case DependencyFailed: return "DependencyFailed";
|
|
|
|
case LogLimitExceeded: return "LogLimitExceeded";
|
|
|
|
case NotDeterministic: return "NotDeterministic";
|
|
|
|
case ResolvesToAlreadyValid: return "ResolvesToAlreadyValid";
|
|
|
|
default: return "Unknown";
|
|
|
|
};
|
|
|
|
}();
|
|
|
|
return strStatus + ((errorMsg == "") ? "" : " : " + errorMsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* How many times this build was performed. */
|
|
|
|
unsigned int timesBuilt = 0;
|
|
|
|
|
|
|
|
/* If timesBuilt > 1, whether some builds did not produce the same
|
|
|
|
result. (Note that 'isNonDeterministic = false' does not mean
|
|
|
|
the build is deterministic, just that we don't have evidence of
|
|
|
|
non-determinism.) */
|
|
|
|
bool isNonDeterministic = false;
|
|
|
|
|
2022-03-09 11:25:35 +00:00
|
|
|
/* The derivation we built or the store path we substituted. */
|
|
|
|
DerivedPath path;
|
|
|
|
|
2022-03-09 19:31:50 +00:00
|
|
|
/* For derivations, a mapping from the names of the wanted outputs
|
|
|
|
to actual paths. */
|
2022-03-01 19:43:07 +00:00
|
|
|
DrvOutputs builtOutputs;
|
|
|
|
|
|
|
|
/* The start/stop times of the build (or one of the rounds, if it
|
|
|
|
was repeated). */
|
|
|
|
time_t startTime = 0, stopTime = 0;
|
|
|
|
|
2022-11-18 12:40:59 +00:00
|
|
|
/* User and system CPU time the build took. */
|
|
|
|
std::optional<std::chrono::microseconds> cpuUser, cpuSystem;
|
|
|
|
|
2022-03-08 18:50:46 +00:00
|
|
|
bool success()
|
|
|
|
{
|
2022-03-01 19:43:07 +00:00
|
|
|
return status == Built || status == Substituted || status == AlreadyValid || status == ResolvesToAlreadyValid;
|
|
|
|
}
|
2022-03-08 18:50:46 +00:00
|
|
|
|
|
|
|
void rethrow()
|
|
|
|
{
|
|
|
|
throw Error("%s", errorMsg);
|
|
|
|
}
|
2022-03-01 19:43:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|