aboutsummaryrefslogtreecommitdiff
path: root/libbrep/build.cxx
blob: 0941c5f563587e64ccc155a6a08d783ef4c5670f (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
// file      : libbrep/build.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2017 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::unbuilt:  return "unbuilt";
    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 == "unbuilt")  return build_state::unbuilt;
    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 pnm, version pvr,
         string cfg,
         string tnm, version tvr,
         optional<string> afp, optional<string> ach,
         string mnm, string msm,
         optional<butl::target_triplet> trg)
      : id (package_id (move (pnm), pvr), move (cfg), tvr),
        package_name (id.package.name),
        package_version (move (pvr)),
        configuration (id.configuration),
        toolchain_name (move (tnm)),
        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))
  {
  }
}