aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/build/script/parser.cxx5
-rw-r--r--libbuild2/build/script/parser.hxx3
-rw-r--r--libbuild2/build/script/script.hxx5
-rw-r--r--libbuild2/parser.cxx6
-rw-r--r--libbuild2/rule.cxx16
-rw-r--r--libbuild2/rule.hxx9
6 files changed, 27 insertions, 17 deletions
diff --git a/libbuild2/build/script/parser.cxx b/libbuild2/build/script/parser.cxx
index e64db91..81e78f3 100644
--- a/libbuild2/build/script/parser.cxx
+++ b/libbuild2/build/script/parser.cxx
@@ -21,7 +21,8 @@ namespace build2
//
script parser::
- pre_parse (istream& is, const path_name& pn, uint64_t line)
+ pre_parse (istream& is, const path_name& pn, uint64_t line,
+ optional<string> diag)
{
path_ = &pn;
@@ -31,6 +32,8 @@ namespace build2
set_lexer (&l);
script s;
+ s.diag = move (diag);
+
script_ = &s;
runner_ = nullptr;
environment_ = nullptr;
diff --git a/libbuild2/build/script/parser.hxx b/libbuild2/build/script/parser.hxx
index 27e7f49..5f08209 100644
--- a/libbuild2/build/script/parser.hxx
+++ b/libbuild2/build/script/parser.hxx
@@ -34,7 +34,8 @@ namespace build2
// name.
//
script
- pre_parse (istream&, const path_name&, uint64_t line);
+ pre_parse (istream&, const path_name&, uint64_t line,
+ optional<string> diag);
// Recursive descent parser.
//
diff --git a/libbuild2/build/script/script.hxx b/libbuild2/build/script/script.hxx
index 2118568..08cdbd2 100644
--- a/libbuild2/build/script/script.hxx
+++ b/libbuild2/build/script/script.hxx
@@ -37,6 +37,7 @@ namespace build2
class script
{
public:
+
// Note that the variables are not pre-entered into a pool during the
// parsing phase, so the line variable pointers are NULL.
//
@@ -58,6 +59,10 @@ namespace build2
//
bool temp_dir = false;
+ // Command name for low-verbosity diagnostics.
+ //
+ optional<string> diag;
+
location start_loc;
location end_loc;
};
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 920c633..72d189e 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -1169,15 +1169,15 @@ namespace build2
i = d.as.erase (i);
}
- auto* asr (new adhoc_script_rule (
- move (diag), loc, st.value.size ()));
+ auto* asr (new adhoc_script_rule (loc, st.value.size ()));
ar.reset (asr);
asr->checksum = sha256 (t.value).string ();
istringstream is (move (t.value));
build::script::parser p (ctx);
- asr->script = p.pre_parse (is, asr->loc.file, loc.line + 1);
+ asr->script = p.pre_parse (
+ is, asr->loc.file, loc.line + 1, move (diag));
}
//
// C++
diff --git a/libbuild2/rule.cxx b/libbuild2/rule.cxx
index 773d42e..2e5fe5d 100644
--- a/libbuild2/rule.cxx
+++ b/libbuild2/rule.cxx
@@ -365,14 +365,18 @@ namespace build2
{
// Do we need the header?
//
- if (diag)
+ // @@ 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)
{
os << ind << '%';
- if (diag)
+ if (script.diag)
{
os << " [";
- os << "diag="; to_stream (os, name (*diag), true /* quote */, '@');
+ os << "diag=";
+ to_stream (os, name (*script.diag), true /* quote */, '@');
os << ']';
}
@@ -612,7 +616,7 @@ namespace build2
if (verb == 1)
{
- // @@ TODO:
+ // @@ TODO (and below):
//
// - derive diag if absent (should probably do in match?)
//
@@ -624,7 +628,7 @@ namespace build2
// (including tools)?
//
- text << (diag ? diag->c_str () : "adhoc") << ' ' << t;
+ text << (script.diag ? script.diag->c_str () : "adhoc") << ' ' << t;
}
if (!ctx.dry_run || verb >= 2)
@@ -657,7 +661,7 @@ namespace build2
{
// @@ TODO: as above
- text << (diag ? diag->c_str () : "adhoc") << ' ' << t;
+ text << (script.diag ? script.diag->c_str () : "adhoc") << ' ' << t;
}
if (!ctx.dry_run || verb >= 2)
diff --git a/libbuild2/rule.hxx b/libbuild2/rule.hxx
index efa4ec3..36e4733 100644
--- a/libbuild2/rule.hxx
+++ b/libbuild2/rule.hxx
@@ -186,14 +186,11 @@ namespace build2
using script_type = build::script::script;
- adhoc_script_rule (optional<string> d, const location& l, size_t b)
- : adhoc_rule (l, b), diag (move (d)) {}
+ adhoc_script_rule (const location& l, size_t b): adhoc_rule (l, b) {}
public:
- const optional<string> diag; // Command name for low-verbosity diag.
- string checksum; // Script text hashsum.
- script_type script;
-
+ script_type script;
+ string checksum; // Script text hashsum.
};
// Ad hoc C++ rule.