From 0ff39fd77b3127c7a250e7f817e34dfaecbcc208 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 20 Nov 2020 22:07:37 +0300 Subject: Add support for buildscript depdb preamble --- libbuild2/build/script/parser.hxx | 41 +++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'libbuild2/build/script/parser.hxx') diff --git a/libbuild2/build/script/parser.hxx b/libbuild2/build/script/parser.hxx index 5ada8be..e96a806 100644 --- a/libbuild2/build/script/parser.hxx +++ b/libbuild2/build/script/parser.hxx @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -34,7 +35,7 @@ namespace build2 // name. // script - pre_parse (const target&, + pre_parse (const target&, const adhoc_actions& acts, istream&, const path_name&, uint64_t line, optional diag_name, const location& diag_loc); @@ -63,9 +64,26 @@ namespace build2 // Execute. Issue diagnostics and throw failed in case of an error. // public: + + // By default call the runner's enter() and leave() functions that + // initialize/clean up the environment before/after the script + // execution. + // + void + execute_body (const scope& root, const scope& base, + environment&, const script&, runner&, + bool enter = true, bool leave = true); + + + // Note that it's the caller's responsibility to make sure that the + // runner's enter() function is called before the first preamble/body + // command execution and leave() -- after the last command. + // void - execute (const scope& root, const scope& base, - environment&, const script&, runner&); + execute_depdb_preamble (const scope& root, const scope& base, + environment&, const script&, runner&, + depdb&); + // Parse a special builtin line into names, performing the variable // and pattern expansions. If omit_builtin is true, then omit the @@ -78,8 +96,18 @@ namespace build2 bool omit_builtin = true); protected: + // Setup the parser for subsequent exec_*() function calls. + // + void + pre_exec (const scope& root, const scope& base, + environment&, const script*, runner*); + void - exec_script (); + exec_lines (const lines&, const function&); + + names + exec_special (token& t, build2::script::token_type& tt, + bool omit_builtin = true); // Helpers. // @@ -112,6 +140,7 @@ namespace build2 protected: script* script_; + const adhoc_actions* actions_; // Non-NULL during pre-parsing. // Current low-verbosity script diagnostics and its weight. // @@ -165,8 +194,8 @@ namespace build2 // // depdb string - Track the argument (single) change as string. // - optional depdb_clear_; // 'depdb clear' location if any. - lines depdb_lines_; // Note: excludes 'depdb clear'. + optional depdb_clear_; // 'depdb clear' location if any. + lines depdb_preamble_; // Note: excludes 'depdb clear'. // True during pre-parsing when the pre-parse mode is temporarily // suspended to perform expansion. -- cgit v1.1