aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/context.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-04-05 08:07:47 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-04-05 08:07:47 +0200
commit2905180c48e4b8974d4dee1949a00fc8e7bcafc6 (patch)
tree0dde0185bcbe36da05200c64ab12bb3b9af528c6 /libbuild2/context.hxx
parent8b9701d2ad76a9a571c445b318557261a4922758 (diff)
Allow creating context with bare minimum of initializations
This is used by bpkg to detect forwarded configurations without incurring the full context creation overhead.
Diffstat (limited to 'libbuild2/context.hxx')
-rw-r--r--libbuild2/context.hxx17
1 files changed, 13 insertions, 4 deletions
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> 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<context*> 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.