aboutsummaryrefslogtreecommitdiff
path: root/libbrep/build.cxx
blob: 45ef6788a326b2a96446c07f20ccfa9f0b5bcae3 (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
// file      : libbrep/build.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
// 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> afp, optional<string> ach,
         string mnm, string msm,
         butl::target_triplet trg)
      : 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),
        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))
  {
  }
}