aboutsummaryrefslogtreecommitdiff
path: root/tests/buildtab/driver.cxx
blob: df23dbc34a05633b2ba72c4a4085c40fa8edc72e (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
// file      : tests/buildtab/driver.cxx -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

#include <ios>      // ios::failbit, ios::badbit
#include <iostream>

#include <libbutl/utility.hxx> // operator<<(ostream,exception)

#include <libbbot/build-config.hxx>

#undef NDEBUG
#include <cassert>

using namespace std;
using namespace butl;
using namespace bbot;

// Usage: argv[0]
//
// Read and parse buildtab from STDIN and serialize the resulted build
// configuration to STDOUT.
//
int
main ()
try
{
  cin.exceptions  (ios::failbit | ios::badbit);
  cout.exceptions (ios::failbit | ios::badbit);

  const build_configs& configs (parse_buildtab (cin, "cin"));

  for (const build_config& c: configs)
  {
    cout << c.machine_pattern << ' ' << c.name << ' ' << c.target;

    if (c.environment)
      cout << '/' << *c.environment;

    string classes;
    for (const string& cls: c.classes)
    {
      if (!classes.empty ())
        classes += ' ';

      classes += cls;

      auto i (configs.class_inheritance_map.find (cls));
      if (i != configs.class_inheritance_map.end ())
        classes += ':' + i->second;
    }

    if (c.classes.size () == 1)
      cout << ' ' << classes;
    else
      cout << " \"" << classes << '"';

    for (const string& a: c.args)
      cout << ' ' << a;

    for (const string& r: c.warning_regexes)
      cout << " ~" << r;

    cout << '\n';
  }

  return 0;
}
catch (const tab_parsing& e)
{
  cerr << e << endl;
  return 1;
}