aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/module.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-08-21 09:03:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-10-08 15:05:21 +0200
commit734bf117f0eb596fc40579810613a6e13c43d3c4 (patch)
tree57c7ffda0ae33287d5ba7a7c23a2a89ec3942b21 /libbuild2/module.cxx
parent2aeb84fd76f1f310022fe15f03efca78a2ccdd26 (diff)
Add context-wide pre/post operation callbacks
Diffstat (limited to 'libbuild2/module.cxx')
-rw-r--r--libbuild2/module.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/libbuild2/module.cxx b/libbuild2/module.cxx
index 1aaa38d..520b993 100644
--- a/libbuild2/module.cxx
+++ b/libbuild2/module.cxx
@@ -96,18 +96,28 @@ namespace build2
nullopt)); /* module_context */
// We use the same context for building any nested modules that might be
- // required while building modules.
+ // required while building modules. Note: this is also used to detect
+ // module building context. @@ Maybe we should invent special build.mode?
//
context& mctx (*(ctx.module_context = ctx.module_context_storage->get ()));
mctx.module_context = &mctx;
+ // Copy over any operation callbacks. If a callback implementation does
+ // not wish to see module context's calls, it can filter them out based on
+ // the passed context.
+ //
+ // Note also that only the callbacks registered before we need to build
+ // the first module will be in effect. Probably good enough for now.
+ //
+ mctx.operation_callbacks = ctx.operation_callbacks;
+
// Setup the context to perform update. In a sense we have a long-running
// perform meta-operation batch (indefinite, in fact, since we never call
// the meta-operation's *_post() callbacks) in which we periodically
// execute update operations.
//
// Note that we perform each build in a separate update operation. Failed
- // that, if the same target is update twice (which may happen with ad hoc
+ // that, if the same target is updated twice (which may happen with ad hoc
// recipes) we will see the old state.
//
if (mo_perform.meta_operation_pre != nullptr)