aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/build/script
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-11-24 18:09:35 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-11-25 14:15:43 +0300
commit472d6d0e49c0114f46ff31267d09acdbf9fba421 (patch)
tree9edfc26e77edabee872c625eb5b96e845b7b4654 /libbuild2/build/script
parentf8408539216cc213fa780560b7396af8ba801e2e (diff)
Use operation name as a buildscript name if unable to deduce
Diffstat (limited to 'libbuild2/build/script')
-rw-r--r--libbuild2/build/script/parser+diag.test.testscript18
-rw-r--r--libbuild2/build/script/parser.cxx13
-rw-r--r--libbuild2/build/script/parser.hxx4
3 files changed, 22 insertions, 13 deletions
diff --git a/libbuild2/build/script/parser+diag.test.testscript b/libbuild2/build/script/parser+diag.test.testscript
index a720fe2..504c9a4 100644
--- a/libbuild2/build/script/parser+diag.test.testscript
+++ b/libbuild2/build/script/parser+diag.test.testscript
@@ -19,6 +19,14 @@ $* <<EOI >>EOO
name: echo
EOO
+: name-operation
+:
+$* <<EOI >>EOO
+ a = 'b'
+ EOI
+ name: update
+ EOO
+
: preamble
:
{
@@ -141,16 +149,6 @@ $* <<EOI >>EOO
info: consider specifying it explicitly with the 'diag' recipe attribute
info: or provide custom low-verbosity diagnostics with the 'diag' builtin
EOE
-
- : none
- :
- $* <<EOI 2>>EOE != 0
- a = 'b'
- EOI
- buildfile:11:1: error: unable to deduce low-verbosity script diagnostics name
- info: consider specifying it explicitly with the 'diag' recipe attribute
- info: or provide custom low-verbosity diagnostics with the 'diag' builtin
- EOE
}
: inside-if
diff --git a/libbuild2/build/script/parser.cxx b/libbuild2/build/script/parser.cxx
index 5dd9179..df0a419 100644
--- a/libbuild2/build/script/parser.cxx
+++ b/libbuild2/build/script/parser.cxx
@@ -102,15 +102,22 @@ namespace build2
info << "consider using 'depdb' builtin to track its value "
<< "changes";
- // Diagnose absent/ambigous script name.
+ // Diagnose absent/ambiguous script name. But try to deduce an absent
+ // name from the script operation first.
//
{
diag_record dr;
if (!diag_name_ && diag_preamble_.empty ())
{
- dr << fail (s.start_loc)
- << "unable to deduce low-verbosity script diagnostics name";
+ if (as.size () == 1)
+ {
+ diag_name_ = make_pair (ctx->operation_table[as[0].operation ()],
+ location ());
+ }
+ else
+ dr << fail (s.start_loc)
+ << "unable to deduce low-verbosity script diagnostics name";
}
else if (diag_name2_)
{
diff --git a/libbuild2/build/script/parser.hxx b/libbuild2/build/script/parser.hxx
index 3121320..70e24aa 100644
--- a/libbuild2/build/script/parser.hxx
+++ b/libbuild2/build/script/parser.hxx
@@ -311,6 +311,10 @@ namespace build2
// builtin after the script name or after another diag builtin) is
// reported as ambiguity.
//
+ // If no script name is deduced by the end of pre-parsing and the
+ // script is used for a single operation, then use this operation's
+ // name as a script name.
+ //
// At the end of pre-parsing either diag_name_ is present or
// diag_preamble_ is not empty (but not both).
//