From 18394bc05dc4cadb2dc193cfeb78598c70447869 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Oct 2022 10:26:22 +0200 Subject: Add support for post hoc prerequisites Unlike normal and ad hoc prerequisites, a post hoc prerequisite is built after the target, not before. It may also form a dependency cycle together with normal/ad hoc prerequisites. In other words, all this form of dependency guarantees is that a post hoc prerequisite will be built if its dependent target is built. See the NEWS file for details and an example. --- libbuild2/context.hxx | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'libbuild2/context.hxx') diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx index 1d46309..40a8bdd 100644 --- a/libbuild2/context.hxx +++ b/libbuild2/context.hxx @@ -388,12 +388,22 @@ namespace build2 const variable_overrides& var_overrides; // Project and relative scope. function_map& functions; - // Enter project-wide (as opposed to global) variable overrides. + // Current targets with post hoc prerequisites. // - void - enter_project_overrides (scope& rs, - const dir_path& out_base, - const variable_overrides&); + // Note that we don't expect many of these so a simple mutex should be + // sufficient. Note also that we may end up adding more entries as we + // match existing so use list for node and iterator stability. See + // match_poshoc() for details. + // + struct posthoc_target + { + build2::action action; + reference_wrapper target; + vector prerequisite_targets; + }; + + list current_posthoc_targets; + mutex current_posthoc_targets_mutex; // Global scope. // @@ -639,6 +649,13 @@ namespace build2 optional module_context = nullptr, const loaded_modules_lock* inherited_mudules_lock = nullptr); + // Enter project-wide (as opposed to global) variable overrides. + // + void + enter_project_overrides (scope& rs, + const dir_path& out_base, + const variable_overrides&); + // Set current meta-operation and operation. // void -- cgit v1.1