From 728b075cb5e0df9c386f8377e0f6961e5ccc5143 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 16 Jun 2020 17:08:39 +0300 Subject: Add env script pseudo-builtin Also disable C++ recipe tests when cross-testing. --- libbuild2/build/script/parser+diag.test.testscript | 36 ++++++++++++++++++++++ libbuild2/build/script/parser.cxx | 6 +++- libbuild2/build/script/parser.hxx | 9 ++++-- 3 files changed, 47 insertions(+), 4 deletions(-) (limited to 'libbuild2/build') diff --git a/libbuild2/build/script/parser+diag.test.testscript b/libbuild2/build/script/parser+diag.test.testscript index 60683bc..5b4e64a 100644 --- a/libbuild2/build/script/parser+diag.test.testscript +++ b/libbuild2/build/script/parser+diag.test.testscript @@ -55,3 +55,39 @@ $* <>~%EOO% buildfile:12:1: info: previous call is here EOE } + +: inside-if +: +$* <>EOE != 0 + if true + diag copy >= $> + fi + EOI + buildfile:12:3: error: 'diag' call inside flow control construct + EOE + +: inside-if-cond +: +$* <>EOE != 0 + if diag copy >= $> + true + fi + EOI + buildfile:11:4: error: 'diag' call inside flow control construct + EOE + +: second-command +: +$* <>EOE != 0 + true && diag copy >= $> + EOI + buildfile:11:9: error: 'diag' call must be the only command + EOE + +: via-env +: +$* <>EOE != 0 + env -- diag copy >= $> + EOI + buildfile:11:8: error: 'diag' call via 'env' builtin + EOE diff --git a/libbuild2/build/script/parser.cxx b/libbuild2/build/script/parser.cxx index 2c41ac1..8f2c46d 100644 --- a/libbuild2/build/script/parser.cxx +++ b/libbuild2/build/script/parser.cxx @@ -330,6 +330,7 @@ namespace build2 optional parser:: parse_program (token& t, build2::script::token_type& tt, bool first, + bool env, names& ns) { const location l (get_location (t)); @@ -369,13 +370,16 @@ namespace build2 // Verify that the special builtin is not called inside an improper // context (flow control construct or complex expression). // - auto verify = [first, &v, &l, this] () + auto verify = [first, env, &v, &l, this] () { if (level_ != 0) fail (l) << "'" << v << "' call inside flow control construct"; if (!first) fail (l) << "'" << v << "' call must be the only command"; + + if (env) + fail (l) << "'" << v << "' call via 'env' builtin"; }; if (v == "diag") diff --git a/libbuild2/build/script/parser.hxx b/libbuild2/build/script/parser.hxx index 73bcd09..5ada8be 100644 --- a/libbuild2/build/script/parser.hxx +++ b/libbuild2/build/script/parser.hxx @@ -98,13 +98,16 @@ namespace build2 // // During pre-parsing try to deduce the low-verbosity script // diagnostics name as a program/builtin name or obtain the custom - // low-verbosity diagnostics specified with the diag builtin. Note - // that the diag builtin can only appear at the beginning of the - // command line. + // low-verbosity diagnostics specified with the diag builtin. Also + // handle the depdb builtin calls. + // + // Note that the diag and depdb builtins can only appear at the + // beginning of the command line. // virtual optional parse_program (token&, build2::script::token_type&, bool first, + bool env, names&) override; protected: -- cgit v1.1