aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/config/init.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-08-16 16:21:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-08-16 16:21:35 +0200
commit534ca7619a62a74bce8e4b30931aaf99f9c3beb6 (patch)
tree2e4ffc0b8aa6651f5003009df0f372529754b1f5 /libbuild2/config/init.cxx
parentd91e48ea57b83f7018a25d3f54bba96cf889d66d (diff)
Add support for post-configure and pre-disfigure hooks
Diffstat (limited to 'libbuild2/config/init.cxx')
-rw-r--r--libbuild2/config/init.cxx45
1 files changed, 25 insertions, 20 deletions
diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx
index df71fae..1513a47 100644
--- a/libbuild2/config/init.cxx
+++ b/libbuild2/config/init.cxx
@@ -96,35 +96,38 @@ namespace build2
auto& c_p (vp.insert<vector<pair<string, string>>> (
"config.config.persist", true /* ovr */, v_p));
- // Only create the module if we are configuring or creating or if it was
- // requested with config.config.module (useful if we need to call
- // $config.save() during other meta-operations).
+ // Only create the module if we are configuring, creating, or
+ // disfiguring or if it was requested with config.config.module (useful
+ // if we need to call $config.save() during other meta-operations).
//
- // Detecting the former (configuring/creating) is a bit tricky since the
- // build2 core may not yet know if this is the case. But we know.
+ // Detecting the former (configure/disfigure/creating) is a bit tricky
+ // since the build2 core may not yet know if this is the case. But we
+ // know.
//
auto& c_m (vp.insert<bool> ("config.config.module", false /*ovr*/, v_p));
- const string& mname (ctx.current_mname);
- const string& oname (ctx.current_oname);
-
- if (( mname == "configure" || mname == "create") ||
- (mname.empty () && (oname == "configure" || oname == "create")) ||
+ bool d;
+ if ((d = ctx.bootstrap_meta_operation ("disfigure")) ||
+ ctx.bootstrap_meta_operation ("configure") ||
+ ctx.bootstrap_meta_operation ("create") ||
cast_false<bool> (rs.vars[c_m]))
{
- // Used as a variable prefix by configure_execute().
- //
- vp.insert ("config");
-
auto& m (extra.set_module (new module));
- // Adjust priority for the config module and import pseudo-module so
- // that their variables come first in config.build.
- //
- m.save_module ("config", INT32_MIN);
- m.save_module ("import", INT32_MIN);
+ if (!d)
+ {
+ // Used as a variable prefix by configure_execute().
+ //
+ vp.insert ("config");
+
+ // Adjust priority for the config module and import pseudo-module so
+ // that their variables come first in config.build.
+ //
+ m.save_module ("config", INT32_MIN);
+ m.save_module ("import", INT32_MIN);
- m.save_variable (c_p, save_null_omitted);
+ m.save_variable (c_p, save_null_omitted);
+ }
}
// Register the config function family if this is the first instance of
@@ -319,6 +322,8 @@ namespace build2
config_save_variable = &module::save_variable;
config_save_module = &module::save_module;
config_preprocess_create = &preprocess_create;
+ config_configure_post = &module::configure_post;
+ config_disfigure_pre = &module::disfigure_pre;
return mod_functions;
}