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
|
// file : libbuild2/build/script/runner.cxx -*- C++ -*-
// license : MIT; see accompanying LICENSE file
#include <libbuild2/build/script/runner.hxx>
#include <libbuild2/script/run.hxx>
namespace build2
{
namespace build
{
namespace script
{
void default_runner::
enter (environment&, const location&)
{
// Noop.
}
void default_runner::
leave (environment& env, const location& ll)
{
clean (env, ll);
}
void default_runner::
run (environment& env,
const command_expr& expr,
size_t li,
const location& ll)
{
if (verb >= 3)
text << ": " << expr;
// Run the expression if we are not in the dry run mode or if it
// executes the set builtin and print the expression otherwise, unless
// it is already printed or the verbosity level is lower than 2.
//
// @@ Should we also run expressions that execute the exit builtin in
// the dry run mode?
//
if (!env.context.dry_run ||
find_if (expr.begin (), expr.end (),
[] (const expr_term& et)
{
return et.pipe.back ().program.string () == "set";
}) != expr.end ())
build2::script::run (env, expr, li, ll);
else if (verb == 2)
text << expr;
}
bool default_runner::
run_if (environment& env,
const command_expr& expr,
size_t li, const location& ll)
{
if (verb >= 3)
text << ": ?" << expr;
return build2::script::run_if (env, expr, li, ll);
}
}
}
}
|