aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build-result.cc
blob: de280c13ffc2ee415da606cdcee12dd87ea79a52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "build-result.hh"

namespace nix {

GENERATE_CMP_EXT(
    ,
    BuildResult,
    me->status,
    me->errorMsg,
    me->timesBuilt,
    me->isNonDeterministic,
    me->builtOutputs,
    me->startTime,
    me->stopTime,
    me->cpuUser,
    me->cpuSystem);

KeyedBuildResult BuildResult::restrictTo(DerivedPath path) const
{
    KeyedBuildResult res{*this, std::move(path)};

    if (auto pbp = std::get_if<DerivedPath::Built>(&res.path)) {
        auto & bp = *pbp;

        /* Because goals are in general shared between derived paths
           that share the same derivation, we need to filter their
           results to get back just the results we care about.
         */

        for (auto it = res.builtOutputs.begin(); it != res.builtOutputs.end();) {
            if (bp.outputs.contains(it->first))
                ++it;
            else
                it = res.builtOutputs.erase(it);
        }
    }

    return res;
}

}