From 6f0f62a865a0bc04233388a049a2273e630bb840 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 28 Apr 2018 14:20:28 +0200 Subject: Expose meta-operation in build.meta_operation variable --- build2/b.cxx | 5 +++++ build2/context.cxx | 4 ++++ build2/context.hxx | 11 ++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/build2/b.cxx b/build2/b.cxx index 6921a97..b73a0d6 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -596,6 +596,11 @@ main (int argc, char* argv[]) } } + // Expose eraly so can be used during bootstrap (with the same + // limitations as for pre-processing). + // + global_scope->rw ().assign (var_build_meta_operation) = mname; + for (auto oit (opspecs.begin ()); oit != opspecs.end (); ++oit) { opspec& os (*oit); diff --git a/build2/context.cxx b/build2/context.cxx index 2ebe163..b4e5160 100644 --- a/build2/context.cxx +++ b/build2/context.cxx @@ -343,6 +343,8 @@ namespace build2 const char var_extension[10] = "extension"; + const variable* var_build_meta_operation; + string current_mname; string current_oname; @@ -703,6 +705,8 @@ namespace build2 // gs.target_vars[exe::static_type]["*"].assign (var_backlink) = true; gs.target_vars[doc::static_type]["*"].assign (var_backlink) = true; + + var_build_meta_operation = &vp.insert ("build.meta_operation"); } // Register builtin rules. diff --git a/build2/context.hxx b/build2/context.hxx index 378c6c0..68faa9b 100644 --- a/build2/context.hxx +++ b/build2/context.hxx @@ -281,6 +281,10 @@ namespace build2 extern const char var_extension[10]; // "extension" + // The build.* namespace. + // + extern const variable* var_build_meta_operation; // .meta_operation + // Current action (meta/operation). // // The names unlike info are available during boot but may not yet be @@ -324,7 +328,12 @@ namespace build2 inline void set_current_mif (const meta_operation_info& mif) { - current_mname = mif.name; + if (current_mname != mif.name) + { + current_mname = mif.name; + global_scope->rw ().assign (var_build_meta_operation) = mif.name; + } + current_mif = &mif; current_on = 0; // Reset. } -- cgit v1.1