aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/diagnostics.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/diagnostics.cxx')
-rw-r--r--libbuild2/diagnostics.cxx67
1 files changed, 44 insertions, 23 deletions
diff --git a/libbuild2/diagnostics.cxx b/libbuild2/diagnostics.cxx
index c795e44..091d6e5 100644
--- a/libbuild2/diagnostics.cxx
+++ b/libbuild2/diagnostics.cxx
@@ -559,7 +559,10 @@ namespace build2
const process_env& pe, const char* const* args, size_t n)
{
if (pe.env ())
- dr << pe << ' ';
+ {
+ to_stream (dr.os, pe, process_env_format::cwd | process_env_format::vars);
+ dr << ' ';
+ }
dr << butl::process_args {args, n};
}
@@ -836,7 +839,7 @@ namespace build2
// is inseparable from any buffered diagnostics. So we prepare the record
// first and then write both while holding the diagnostics stream lock.
//
- diag_record dr;
+ maybe_diag_record dr;
if (!pe)
{
// Note: see similar code in run_finish_impl().
@@ -852,7 +855,7 @@ namespace build2
if (verb >= 1 && verb <= v)
{
dr << info << "command line: ";
- print_process (dr, args);
+ print_process (*dr, args);
}
}
}
@@ -861,7 +864,7 @@ namespace build2
}
void diag_buffer::
- close (diag_record&& dr)
+ close (maybe_diag_record&& dr)
{
assert (state_ != state::closed);
@@ -901,7 +904,7 @@ namespace build2
args0 = nullptr;
state_ = state::closed;
- if (!buf.empty () || !dr.empty ())
+ if (!buf.empty () || dr)
{
diag_stream_lock l;
@@ -911,14 +914,14 @@ namespace build2
buf.clear ();
}
- if (!dr.empty ())
- dr.flush ([] (const butl::diag_record& r)
- {
- // Similar to default_writer().
- //
- *diag_stream << r.os.str () << '\n';
- diag_stream->flush ();
- });
+ if (dr)
+ (*dr).flush ([] (const butl::diag_record& r)
+ {
+ // Similar to default_writer().
+ //
+ *diag_stream << r.os.str () << '\n';
+ diag_stream->flush ();
+ });
else
diag_stream->flush ();
}
@@ -927,11 +930,15 @@ namespace build2
// diag_do(), etc.
//
string
- diag_do (context& ctx, const action&)
+ diag_do (context& ctx, const action& a)
{
const meta_operation_info& m (*ctx.current_mif);
const operation_info& io (*ctx.current_inner_oif);
- const operation_info* oo (ctx.current_outer_oif);
+ const operation_info* oo (a.outer () ? ctx.current_outer_oif : nullptr);
+
+ assert (m.id == a.meta_operation () &&
+ io.id == a.operation () &&
+ (a.inner () || (oo != nullptr && oo->id == a.outer_operation ())));
string r;
@@ -968,11 +975,15 @@ namespace build2
}
string
- diag_doing (context& ctx, const action&)
+ diag_doing (context& ctx, const action& a)
{
const meta_operation_info& m (*ctx.current_mif);
const operation_info& io (*ctx.current_inner_oif);
- const operation_info* oo (ctx.current_outer_oif);
+ const operation_info* oo (a.outer () ? ctx.current_outer_oif : nullptr);
+
+ assert (m.id == a.meta_operation () &&
+ io.id == a.operation () &&
+ (a.inner () || (oo != nullptr && oo->id == a.outer_operation ())));
string r;
@@ -1005,11 +1016,15 @@ namespace build2
}
string
- diag_did (context& ctx, const action&)
+ diag_did (context& ctx, const action& a)
{
const meta_operation_info& m (*ctx.current_mif);
const operation_info& io (*ctx.current_inner_oif);
- const operation_info* oo (ctx.current_outer_oif);
+ const operation_info* oo (a.outer () ? ctx.current_outer_oif : nullptr);
+
+ assert (m.id == a.meta_operation () &&
+ io.id == a.operation () &&
+ (a.inner () || (oo != nullptr && oo->id == a.outer_operation ())));
string r;
@@ -1046,11 +1061,17 @@ namespace build2
}
void
- diag_done (ostream& os, const action&, const target& t)
+ diag_done (ostream& os, const action& a, const target& t)
{
- const meta_operation_info& m (*t.ctx.current_mif);
- const operation_info& io (*t.ctx.current_inner_oif);
- const operation_info* oo (t.ctx.current_outer_oif);
+ context& ctx (t.ctx);
+
+ const meta_operation_info& m (*ctx.current_mif);
+ const operation_info& io (*ctx.current_inner_oif);
+ const operation_info* oo (a.outer () ? ctx.current_outer_oif : nullptr);
+
+ assert (m.id == a.meta_operation () &&
+ io.id == a.operation () &&
+ (a.inner () || (oo != nullptr && oo->id == a.outer_operation ())));
// perform(update(x)) -> "x is up to date"
// configure(update(x)) -> "updating x is configured"