aboutsummaryrefslogtreecommitdiff
path: root/libbrep/build.cxx
blob: 9cbad8fdbb9830877fc9bc94cba733f960be96c4 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// file      : libbrep/build.cxx -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

#include <libbrep/build.hxx>

namespace brep
{
  // build_state
  //
  string
  to_string (build_state s)
  {
    switch (s)
    {
    case build_state::building: return "building";
    case build_state::built:    return "built";
    }

    return string (); // Should never reach.
  }

  build_state
  to_build_state (const string& s)
  {
         if (s == "building") return build_state::building;
    else if (s == "built")    return build_state::built;
    else throw invalid_argument ("invalid build state '" + s + "'");
  }

  // force_state
  //
  string
  to_string (force_state s)
  {
    switch (s)
    {
    case force_state::unforced: return "unforced";
    case force_state::forcing:  return "forcing";
    case force_state::forced:   return "forced";
    }

    return string (); // Should never reach.
  }

  force_state
  to_force_state (const string& s)
  {
         if (s == "unforced") return force_state::unforced;
    else if (s == "forcing")  return force_state::forcing;
    else if (s == "forced")   return force_state::forced;
    else throw invalid_argument ("invalid force state '" + s + "'");
  }

  // build
  //
  build::
  build (string tnt,
         package_name_type pnm,
         version pvr,
         string cfg,
         string tnm, version tvr,
         optional<string> inr,
         optional<string> afp, optional<string> ach,
         string mnm, string msm,
         butl::target_triplet trg,
         string ccs,
         string mcs)
      : id (package_id (move (tnt), move (pnm), pvr),
            move (cfg),
            move (tnm), tvr),
        tenant (id.package.tenant),
        package_name (id.package.name),
        package_version (move (pvr)),
        configuration (id.configuration),
        toolchain_name (id.toolchain_name),
        toolchain_version (move (tvr)),
        state (build_state::building),
        interactive (move (inr)),
        timestamp (timestamp_type::clock::now ()),
        force (force_state::unforced),
        agent_fingerprint (move (afp)), agent_challenge (move (ach)),
        machine (move (mnm)),
        machine_summary (move (msm)),
        target (move (trg)),
        controller_checksum (move (ccs)),
        machine_checksum (move (mcs))
  {
  }

  // build_delay
  //
  build_delay::
  build_delay (string tnt,
               package_name_type pnm, version pvr,
               string cfg,
               string tnm, version tvr,
               timestamp ptm)
      : id (package_id (move (tnt), move (pnm), pvr),
            move (cfg),
            move (tnm), tvr),
        tenant (id.package.tenant),
        package_name (id.package.name),
        package_version (move (pvr)),
        configuration (id.configuration),
        toolchain_name (id.toolchain_name),
        toolchain_version (move (tvr)),
        package_timestamp (ptm)
  {
  }
}