From 2905180c48e4b8974d4dee1949a00fc8e7bcafc6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 5 Apr 2023 08:07:47 +0200 Subject: Allow creating context with bare minimum of initializations This is used by bpkg to detect forwarded configurations without incurring the full context creation overhead. --- libbuild2/context.hxx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'libbuild2/context.hxx') diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx index c040927..35ba11d 100644 --- a/libbuild2/context.hxx +++ b/libbuild2/context.hxx @@ -211,9 +211,11 @@ namespace build2 unique_ptr data_; public: - scheduler& sched; - global_mutexes& mutexes; - file_cache& fcache; + // These are only NULL for the "bare minimum" context (see below). + // + scheduler* sched; + global_mutexes* mutexes; + file_cache* fcache; // Match only flag (see --match-only but also dist). // @@ -677,7 +679,6 @@ namespace build2 reserves (size_t t, size_t v): targets (t), variables (v) {} }; - explicit context (scheduler&, global_mutexes&, file_cache&, @@ -691,6 +692,14 @@ namespace build2 optional module_context = nullptr, const loaded_modules_lock* inherited_mudules_lock = nullptr); + // Special context with bare minimum of initializations. It is only + // guaranteed to be sufficiently initialized to call extract_variable(). + // + // Note that for this purpose you may omit calls to init_diag() and + // init(). + // + context (); + // Reserve elements in containers to avoid re-allocation/re-hashing. Zero // values are ignored (that is, the corresponding container reserve() // function is not called). Can only be called in the load phase. -- cgit v1.1