blob: 9f60badb4ce61992c4bb97eb1c04a0f141a89714 (
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
|
// file : libbuild2/make-parser.test.cxx -*- C++ -*-
// license : MIT; see accompanying LICENSE file
#include <iostream>
#include <libbuild2/types.hxx>
#include <libbuild2/utility.hxx>
#include <libbuild2/make-parser.hxx>
#include <libbuild2/diagnostics.hxx>
#undef NDEBUG
#include <cassert>
using namespace std;
namespace build2
{
int
main (int, char* argv[])
{
bool strict (false);
// Fake build system driver, default verbosity.
//
init_diag (1);
init (nullptr, argv[0]);
path_name in ("<stdin>");
try
{
cin.exceptions (istream::badbit);
using make_state = make_parser;
using make_type = make_parser::type;
make_parser make;
location ll (in, 1);
for (string l; !eof (getline (cin, l)); ++ll.line)
{
if (make.state == make_state::end)
{
cout << endl;
make.state = make_state::begin;
}
// Skip leading blank lines to reduce output noise.
//
if (make.state == make_state::begin && l.empty ())
continue;
size_t pos (0);
do
{
pair<make_type, path> r (make.next (l, pos, ll, strict));
cout << (r.first == make_type::target ? 'T' : 'P');
if (!r.second.empty ())
cout << ' ' << r.second;
cout << endl;
}
while (pos != l.size ());
}
if (make.state != make_state::end && make.state != make_state::begin)
fail (ll) << "incomplete make dependency declaration";
}
catch (const io_error& e)
{
cerr << "unable to read stdin: " << e << endl;
return 1;
}
catch (const failed&)
{
return 1;
}
return 0;
}
}
int
main (int argc, char* argv[])
{
return build2::main (argc, argv);
}
|