From 4f5b6cb7ed4e05e98cce7e692462f49e24b7a39a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 22 Aug 2019 14:38:57 +0200 Subject: Targets, scopes, vars --- libbuild2/context.hxx | 78 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 17 deletions(-) (limited to 'libbuild2/context.hxx') diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx index ce9a996..f51645e 100644 --- a/libbuild2/context.hxx +++ b/libbuild2/context.hxx @@ -8,8 +8,11 @@ #include #include -#include -#include +// NOTE: this file is included by pretty much every other "data model" header +// (scope, target, variable, etc) so including any of them here is +// probably a non-starter. +// +#include #include #include @@ -17,11 +20,66 @@ namespace build2 { class scope; + class scope_map; + class target_set; + + class variable; + class variable_pool; + struct variable_override; + using variable_overrides = vector; + class value; + using values = small_vector; + + struct meta_operation_info; + struct operation_info; + + struct opspec; // Main scheduler. Started up and shut down in main(). // + // @@ CTX: move to main(). + // LIBBUILD2_SYMEXPORT extern scheduler sched; + // @@ CTX: document (backlinks, non-overlap etc). RW story. + // + class LIBBUILD2_SYMEXPORT context + { + struct data; + unique_ptr data_; + + public: + scheduler& sched; + + const scope_map& scopes; + const scope& global_scope; + + target_set& targets; + + const variable_pool& var_pool; + const variable_overrides& var_overrides; // Project and relative scope. + + public: + explicit + context (scheduler&, const strings& cmd_vars = {}); + + void + current_mif (const meta_operation_info&); + + void + current_oif (const operation_info& inner, + const operation_info* outer = nullptr, + bool diag_noise = true); + + context (context&&) = delete; + context& operator= (context&&) = delete; + + context (const context&) = delete; + context& operator= (const context&) = delete; + + ~context (); + }; + // In order to perform each operation the build system goes through the // following phases: // @@ -303,14 +361,6 @@ namespace build2 LIBBUILD2_SYMEXPORT extern atomic_count target_count; LIBBUILD2_SYMEXPORT extern atomic_count skip_count; - LIBBUILD2_SYMEXPORT void - set_current_mif (const meta_operation_info&); - - LIBBUILD2_SYMEXPORT void - set_current_oif (const operation_info& inner, - const operation_info* outer = nullptr, - bool diag_noise = true); - // Keep going flag. // // Note that setting it to false is not of much help unless we are running @@ -352,19 +402,13 @@ namespace build2 // LIBBUILD2_SYMEXPORT extern bool dry_run; - // Reset the build state. In particular, this removes all the targets, - // scopes, and variables. - // - LIBBUILD2_SYMEXPORT variable_overrides - reset (const strings& cmd_vars); - // Config module entry points. // LIBBUILD2_SYMEXPORT extern void (*config_save_variable) ( scope&, const variable&, uint64_t flags); LIBBUILD2_SYMEXPORT extern const string& (*config_preprocess_create) ( - const variable_overrides&, + context&, values&, vector_view&, bool lifted, -- cgit v1.1