From 472d6d0e49c0114f46ff31267d09acdbf9fba421 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 24 Nov 2022 18:09:35 +0300 Subject: Use operation name as a buildscript name if unable to deduce --- libbuild2/build/script/parser+diag.test.testscript | 18 ++++++++---------- libbuild2/build/script/parser.cxx | 13 ++++++++++--- libbuild2/build/script/parser.hxx | 4 ++++ 3 files changed, 22 insertions(+), 13 deletions(-) (limited to 'libbuild2') 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 @@ $* <>EOO name: echo EOO +: name-operation +: +$* <>EOO + a = 'b' + EOI + name: update + EOO + : preamble : { @@ -141,16 +149,6 @@ $* <>EOO info: consider specifying it explicitly with the 'diag' recipe attribute info: or provide custom low-verbosity diagnostics with the 'diag' builtin EOE - - : none - : - $* <>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). // -- cgit v1.1