diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2022-03-01 19:43:07 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2022-03-01 19:43:07 +0000 |
commit | e862833ec662c1bffbe31b9a229147de391e801a (patch) | |
tree | f95fbf816b040c1c237d16cf83de31666f98e9b0 /src | |
parent | 0cb5af5000517ffd0f81a25df5b3f4c05fac53f6 (diff) |
Move `BuildResult` defintion to its own header
Just like we did for `ValidPathInfo` in
d92d4f85a5c8a2a2385c084500a8b6bd54b54e6c.
Diffstat (limited to 'src')
-rw-r--r-- | src/build-remote/build-remote.cc | 1 | ||||
-rw-r--r-- | src/libstore/build-result.hh | 77 | ||||
-rw-r--r-- | src/libstore/build/derivation-goal.hh | 1 | ||||
-rw-r--r-- | src/libstore/daemon.cc | 1 | ||||
-rw-r--r-- | src/libstore/legacy-ssh-store.cc | 1 | ||||
-rw-r--r-- | src/libstore/remote-store.cc | 1 | ||||
-rw-r--r-- | src/libstore/store-api.hh | 66 | ||||
-rw-r--r-- | src/nix-store/nix-store.cc | 1 |
8 files changed, 84 insertions, 65 deletions
diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc index 9d2eacb54..8c9133c17 100644 --- a/src/build-remote/build-remote.cc +++ b/src/build-remote/build-remote.cc @@ -14,6 +14,7 @@ #include "pathlocks.hh" #include "globals.hh" #include "serialise.hh" +#include "build-result.hh" #include "store-api.hh" #include "derivations.hh" #include "local-store.hh" diff --git a/src/libstore/build-result.hh b/src/libstore/build-result.hh new file mode 100644 index 000000000..018ba31b3 --- /dev/null +++ b/src/libstore/build-result.hh @@ -0,0 +1,77 @@ +#pragma once + +#include "realisation.hh" + +#include <string> +#include <chrono> + + +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, + } status = MiscFailure; + 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; + + DrvOutputs builtOutputs; + + /* The start/stop times of the build (or one of the rounds, if it + was repeated). */ + time_t startTime = 0, stopTime = 0; + + bool success() { + return status == Built || status == Substituted || status == AlreadyValid || status == ResolvesToAlreadyValid; + } +}; + +} diff --git a/src/libstore/build/derivation-goal.hh b/src/libstore/build/derivation-goal.hh index d947482ef..6f158bdbf 100644 --- a/src/libstore/build/derivation-goal.hh +++ b/src/libstore/build/derivation-goal.hh @@ -2,6 +2,7 @@ #include "parsed-derivations.hh" #include "lock.hh" +#include "build-result.hh" #include "store-api.hh" #include "pathlocks.hh" #include "goal.hh" diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index 2ba03f0dd..9d4f6b4a4 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -1,6 +1,7 @@ #include "daemon.hh" #include "monitor-fd.hh" #include "worker-protocol.hh" +#include "build-result.hh" #include "store-api.hh" #include "path-with-outputs.hh" #include "finally.hh" diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc index 6b3daae7f..16c2b90c6 100644 --- a/src/libstore/legacy-ssh-store.cc +++ b/src/libstore/legacy-ssh-store.cc @@ -2,6 +2,7 @@ #include "pool.hh" #include "remote-store.hh" #include "serve-protocol.hh" +#include "build-result.hh" #include "store-api.hh" #include "path-with-outputs.hh" #include "worker-protocol.hh" diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index e7ffa6595..cbcb75c00 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -2,6 +2,7 @@ #include "util.hh" #include "path-with-outputs.hh" #include "remote-fs-accessor.hh" +#include "build-result.hh" #include "remote-store.hh" #include "worker-protocol.hh" #include "archive.hh" diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index e4fb1f1fd..8c57596d0 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -131,72 +131,8 @@ struct GCResults enum BuildMode { bmNormal, bmRepair, bmCheck }; +struct BuildResult; -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, - } status = MiscFailure; - 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; - - DrvOutputs builtOutputs; - - /* The start/stop times of the build (or one of the rounds, if it - was repeated). */ - time_t startTime = 0, stopTime = 0; - - bool success() { - return status == Built || status == Substituted || status == AlreadyValid || status == ResolvesToAlreadyValid; - } -}; struct StoreConfig : public Config { diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index ecd7279e9..1ebc177f5 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -2,6 +2,7 @@ #include "derivations.hh" #include "dotgraph.hh" #include "globals.hh" +#include "build-result.hh" #include "local-store.hh" #include "monitor-fd.hh" #include "serve-protocol.hh" |