aboutsummaryrefslogtreecommitdiff
path: root/libbrep/build.cxx
blob: 8fadfa394106c84f4f0ab719f892898a7055c193 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// 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::queued:   return "queued";
    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 == "queued")   return build_state::queued;
    else 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,
         target_triplet trg,
         string tcf,
         string pcf,
         string tnm, version tvr,
         optional<string> inr,
         optional<string> afp, optional<string> ach,
         string mnm, string msm,
         string ccs,
         string mcs)
      : id (package_id (move (tnt), move (pnm), pvr),
            move (trg),
            move (tcf),
            move (pcf),
            move (tnm), tvr),
        tenant (id.package.tenant),
        package_name (id.package.name),
        package_version (move (pvr)),
        target (id.target),
        target_config_name (id.target_config_name),
        package_config_name (id.package_config_name),
        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)),
        controller_checksum (move (ccs)),
        machine_checksum (move (mcs))
  {
  }

  build::
  build (string tnt,
         package_name_type pnm,
         version pvr,
         target_triplet trg,
         string tcf,
         string pcf,
         string tnm, version tvr)
      : id (package_id (move (tnt), move (pnm), pvr),
            move (trg),
            move (tcf),
            move (pcf),
            move (tnm), tvr),
        tenant (id.package.tenant),
        package_name (id.package.name),
        package_version (move (pvr)),
        target (id.target),
        target_config_name (id.target_config_name),
        package_config_name (id.package_config_name),
        toolchain_name (id.toolchain_name),
        toolchain_version (move (tvr)),
        state (build_state::queued),
        timestamp (timestamp_type::clock::now ()),
        force (force_state::unforced)
  {
  }

  build::
  build (build&& b)
      : id (move (b.id)),
        tenant (id.package.tenant),
        package_name (id.package.name),
        package_version (move (b.package_version)),
        target (id.target),
        target_config_name (id.target_config_name),
        package_config_name (id.package_config_name),
        toolchain_name (id.toolchain_name),
        toolchain_version (move (b.toolchain_version)),
        state (b.state),
        interactive (move (b.interactive)),
        timestamp (b.timestamp),
        force (b.force),
        status (b.status),
        soft_timestamp (b.soft_timestamp),
        hard_timestamp (b.hard_timestamp),
        agent_fingerprint (move (b.agent_fingerprint)),
        agent_challenge (move (b.agent_challenge)),
        machine (move (b.machine)),
        machine_summary (move (b.machine_summary)),
        results (move (b.results)),
        results_section (move (b.results_section)),
        controller_checksum (move (b.controller_checksum)),
        machine_checksum (move (b.machine_checksum)),
        agent_checksum (move (b.agent_checksum)),
        worker_checksum (move (b.worker_checksum)),
        dependency_checksum (move (b.dependency_checksum))
  {
  }

  build& build::
  operator= (build&& b)
  {
    if (this != &b)
    {
      id = move (b.id);
      package_version = move (b.package_version);
      toolchain_version = move (b.toolchain_version);
      state = b.state;
      interactive = move (b.interactive);
      timestamp = b.timestamp;
      force = b.force;
      status = b.status;
      soft_timestamp = b.soft_timestamp;
      hard_timestamp = b.hard_timestamp;
      agent_fingerprint = move (b.agent_fingerprint);
      agent_challenge = move (b.agent_challenge);
      machine = move (b.machine);
      machine_summary = move (b.machine_summary);
      results = move (b.results);
      results_section = move (b.results_section);
      controller_checksum = move (b.controller_checksum);
      machine_checksum = move (b.machine_checksum);
      agent_checksum = move (b.agent_checksum);
      worker_checksum = move (b.worker_checksum);
      dependency_checksum = move (b.dependency_checksum);
    }

    return *this;
  }

  // build_delay
  //
  build_delay::
  build_delay (string tnt,
               package_name_type pnm, version pvr,
               target_triplet trg,
               string tcf,
               string pcf,
               string tnm, version tvr,
               timestamp ptm)
      : id (package_id (move (tnt), move (pnm), pvr),
            move (trg),
            move (tcf),
            move (pcf),
            move (tnm), tvr),
        tenant (id.package.tenant),
        package_name (id.package.name),
        package_version (move (pvr)),
        target (id.target),
        target_config_name (id.target_config_name),
        package_config_name (id.package_config_name),
        toolchain_name (id.toolchain_name),
        toolchain_version (move (tvr)),
        package_timestamp (ptm)
  {
  }
}