aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/rule.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-06-03 16:38:23 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-06-04 14:20:33 +0300
commitd280946474568925016359be742b59fd6c000c52 (patch)
tree5b48a599c33f442867dfa32690e141883af0322d /libbuild2/rule.cxx
parentf50d0d58c8eb659e803282e19cf15398e3a8e373 (diff)
Properly handle diag directive in build script parser
Diffstat (limited to 'libbuild2/rule.cxx')
-rw-r--r--libbuild2/rule.cxx91
1 files changed, 56 insertions, 35 deletions
diff --git a/libbuild2/rule.cxx b/libbuild2/rule.cxx
index a5d51ca..7ea6e68 100644
--- a/libbuild2/rule.cxx
+++ b/libbuild2/rule.cxx
@@ -413,15 +413,15 @@ namespace build2
// @@ TODO: for now we dump it as an attribute whether it was specified or
// derived from the script. Maybe that's ok?
//
- if (script.diag)
+ if (script.diag_name)
{
os << ind << '%';
- if (script.diag)
+ if (script.diag_name)
{
os << " [";
os << "diag=";
- to_stream (os, name (*script.diag), true /* quote */, '@');
+ to_stream (os, name (*script.diag_name), true /* quote */, '@');
os << ']';
}
@@ -691,34 +691,43 @@ namespace build2
if (!update)
return *ps;
- if (verb == 1)
- {
- // @@ TODO (and below):
- //
- // - derive diag if absent (should probably do in match?)
- //
- // - we are printing target, not source (like in most other places)
- //
- // - printing of ad hoc target group (the {hxx cxx}{foo} idea)
- //
- // - if we are printing prerequisites, should we print all of them
- // (including tools)?
- //
-
- text << (script.diag ? script.diag->c_str () : "adhoc") << ' ' << t;
- }
-
- if (!ctx.dry_run || verb >= 2)
+ if (!ctx.dry_run || verb != 0)
{
const scope& bs (t.base_scope ());
+ const scope& rs (*bs.root_scope ());
build::script::environment e (a, t, script.temp_dir);
build::script::parser p (ctx);
- build::script::default_runner r;
- p.execute (*bs.root_scope (), bs, e, script, r);
- if (!ctx.dry_run)
- dd.check_mtime (tp);
+ if (verb == 1)
+ {
+ if (script.diag_line)
+ {
+ text << p.execute_special (rs, bs, e, *script.diag_line);
+ }
+ else
+ {
+ // @@ TODO (and below):
+ //
+ // - we are printing target, not source (like in most other places)
+ //
+ // - printing of ad hoc target group (the {hxx cxx}{foo} idea)
+ //
+ // - if we are printing prerequisites, should we print all of them
+ // (including tools)?
+ //
+ text << *script.diag_name << ' ' << t;
+ }
+ }
+
+ if (!ctx.dry_run || verb >= 2)
+ {
+ build::script::default_runner r;
+ p.execute (rs, bs, e, script, r);
+
+ if (!ctx.dry_run)
+ dd.check_mtime (tp);
+ }
}
t.mtime (system_clock::now ());
@@ -734,21 +743,33 @@ namespace build2
execute_prerequisites (a, t);
- if (verb == 1)
- {
- // @@ TODO: as above
-
- text << (script.diag ? script.diag->c_str () : "adhoc") << ' ' << t;
- }
-
- if (!ctx.dry_run || verb >= 2)
+ if (!ctx.dry_run || verb != 0)
{
const scope& bs (t.base_scope ());
+ const scope& rs (*bs.root_scope ());
build::script::environment e (a, t, script.temp_dir);
build::script::parser p (ctx);
- build::script::default_runner r;
- p.execute (*bs.root_scope (), bs, e, script, r);
+
+ if (verb == 1)
+ {
+ if (script.diag_line)
+ {
+ text << p.execute_special (rs, bs, e, *script.diag_line);
+ }
+ else
+ {
+ // @@ TODO: as above
+ //
+ text << *script.diag_name << ' ' << t;
+ }
+ }
+
+ if (!ctx.dry_run || verb >= 2)
+ {
+ build::script::default_runner r;
+ p.execute (rs, bs, e, script, r);
+ }
}
return target_state::changed;