From d82719606408de169097715d673745a96d9b1d56 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 24 Nov 2021 10:01:29 +0200 Subject: Allow calling cc module functions during match An ad hoc recipe with dynamic dependency extraction (depdb-dyndep) executes its depdb preamble during match (but after matching all the prerequisites). --- libbuild2/cc/functions.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/cc/functions.cxx b/libbuild2/cc/functions.cxx index cafb7f0..9c06f87 100644 --- a/libbuild2/cc/functions.cxx +++ b/libbuild2/cc/functions.cxx @@ -47,7 +47,12 @@ namespace build2 if (rs == nullptr) fail << f.name << " called out of project"; - if (bs->ctx.phase != run_phase::execute) + // Note that we also allow calling this during match since an ad hoc + // recipe with dynamic dependency extraction (depdb-dyndep) executes its + // depdb preamble during match (after matching all the prerequisites). + // + if (bs->ctx.phase != run_phase::match || + bs->ctx.phase != run_phase::execute) fail << f.name << " can only be called during execution"; const module* m (rs->find_module (d.x)); @@ -102,7 +107,8 @@ namespace build2 if (rs == nullptr) fail << f.name << " called out of project"; - if (bs->ctx.phase != run_phase::execute) + if (bs->ctx.phase != run_phase::match || // See above. + bs->ctx.phase != run_phase::execute) fail << f.name << " can only be called during execution"; const module* m (rs->find_module (d.x)); -- cgit v1.1