aboutsummaryrefslogtreecommitdiff
path: root/libbrep/build.cxx
blob: 710c0b2f76e969f725342575bc0f9eaa91fab546 (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
// 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::untested: return "untested";
    case build_state::testing:  return "testing";
    case build_state::tested:   return "tested";
    }

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

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

  // build
  //
  build::
  build (string pnm, version pvr, string cfg, string mnm, string msm)
      : id (package_id (move (pnm), pvr), move (cfg)),
        package_name (id.package.name),
        package_version (move (pvr)),
        configuration (id.configuration),
        state (build_state::testing),
        timestamp (timestamp_type::clock::now ()),
        forced (false),
        machine (move (mnm)),
        machine_summary (move (msm))
  {
  }
}