aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbuild2/file.cxx16
-rw-r--r--libbuild2/file.hxx8
2 files changed, 22 insertions, 2 deletions
diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx
index d91bf73..d789d20 100644
--- a/libbuild2/file.cxx
+++ b/libbuild2/file.cxx
@@ -1506,7 +1506,9 @@ namespace build2
}
void
- load_root (scope& root)
+ load_root (scope& root,
+ const function<void (parser&)>& pre,
+ const function<void (parser&)>& post)
{
tracer trace ("load_root");
@@ -1576,10 +1578,22 @@ namespace build2
//
parser p (ctx, load_stage::root);
+ if (pre != nullptr)
+ {
+ pre (p);
+ p.reset ();
+ }
+
if (he) {source_hooks (p, root, hd, true /* pre */); p.reset ();}
if (fe) {source_once (p, root, root, f, root);}
if (he) {p.reset (); source_hooks (p, root, hd, false /* pre */);}
+ if (post != nullptr)
+ {
+ p.reset ();
+ post (p);
+ }
+
// Finish off initializing bootstrapped modules (after mode).
//
{
diff --git a/libbuild2/file.hxx b/libbuild2/file.hxx
index 5a25475..43cd1ff 100644
--- a/libbuild2/file.hxx
+++ b/libbuild2/file.hxx
@@ -17,6 +17,7 @@
namespace build2
{
class lexer;
+ class parser;
LIBBUILD2_SYMEXPORT extern const dir_path std_build_dir; // build/
@@ -231,8 +232,13 @@ namespace build2
// loaded. Also make sure all outer root scopes are loaded prior to loading
// this root scope.
//
+ // If pre/post functions are specified, they are called before/after
+ // pre/post hooks, respectively.
+ //
LIBBUILD2_SYMEXPORT void
- load_root (scope& root);
+ load_root (scope& root,
+ const function<void (parser&)>& pre = nullptr,
+ const function<void (parser&)>& post = nullptr);
// Extract the specified variable value from a buildfile. It is expected to
// be the first non-blank/comment line and not to rely on any variable