aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/context.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-10-19 10:26:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-10-19 10:26:22 +0200
commit18394bc05dc4cadb2dc193cfeb78598c70447869 (patch)
tree2b3d794305dc5d950f9c05094b80c89b93e5fd25 /libbuild2/context.hxx
parentb408d19f614b47670cd0a0def501266f0d7689b5 (diff)
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.
Diffstat (limited to 'libbuild2/context.hxx')
-rw-r--r--libbuild2/context.hxx27
1 files changed, 22 insertions, 5 deletions
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<const build2::target> target;
+ vector<const build2::target*> prerequisite_targets;
+ };
+
+ list<posthoc_target> current_posthoc_targets;
+ mutex current_posthoc_targets_mutex;
// Global scope.
//
@@ -639,6 +649,13 @@ namespace build2
optional<context*> 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