Optimize multiple module loads

This commit is contained in:
Boris Kolpackov 2023-04-21 13:02:35 +02:00
parent 19cd67c1fa
commit f18022d006

View File

@ -19,61 +19,64 @@ namespace build2
init (scope& rs,
scope& bs,
const location& l,
bool,
bool first,
bool,
module_init_extra&)
{
tracer trace ("autoconf::init");
l5 ([&]{trace << "for " << bs;});
// Load in.base (in.* variables, in{} target type).
//
load_module (rs, rs, "in.base", l);
// Enter variables.
//
if (first)
{
// All the variables we enter are qualified so go straight for the
// public variable pool.
// Load in.base (in.* variables, in{} target type).
//
auto& vp (rs.var_pool (true /* public */));
load_module (rs, rs, "in.base", l);
// Configuration file flavor. Valid values are `autoconf` (default),
// `cmake`, and `meson`.
// Enter variables.
//
vp.insert<string> ("autoconf.flavor");
{
// All the variables we enter are qualified so go straight for the
// public variable pool.
//
auto& vp (rs.var_pool (true /* public */));
// Built-in checks prefix.
//
vp.insert<string> ("autoconf.prefix");
// Configuration file flavor. Valid values are `autoconf` (default),
// `cmake`, and `meson`.
//
vp.insert<string> ("autoconf.flavor");
// Substitution map (an alias for in.substitutions).
//
vp.insert_alias (*vp.find ("in.substitutions"),
"autoconf.substitutions");
// Built-in checks prefix.
//
vp.insert<string> ("autoconf.prefix");
// Alias map. The key is the new name and the value is the aliased
// (old) name.
// Substitution map (an alias for in.substitutions).
//
vp.insert_alias (*vp.find ("in.substitutions"),
"autoconf.substitutions");
// Alias map. The key is the new name and the value is the aliased
// (old) name.
//
// Note that this map is only consulted when resolving build-in
// checks and the names should include the prefix, if any.
//
vp.insert<map<string, string>> ("autoconf.aliases");
}
// Register the rule.
//
// Note that this map is only consulted when resolving build-in checks
// and the names should include the prefix, if any.
// @@ TODO: this will be ambiguous, for example, version.in rule. Note
// also that if we register it for cc{}, then it will always take
// precedence over version.in, which is probably something we don't
// want. In fact, we would have liked it to be of lower precedence
// since version.in will only match if there is dependency on
// manifest.
//
vp.insert<map<string, string>> ("autoconf.aliases");
rs.insert_rule<file> (perform_update_id, "autoconf.in", rule_);
rs.insert_rule<file> (perform_clean_id, "autoconf.in", rule_);
rs.insert_rule<file> (configure_update_id, "autoconf.in", rule_);
}
// Register the rule.
//
// @@ TODO: this will be ambiguous, for example, version.in rule. Note
// also that if we register it for cc{}, then it will always take
// precedence over version.in, which is probably something we don't
// want. In fact, we would have liked it to be of lower precedence
// since version.in will only match if there is dependency on
// manifest.
//
rs.insert_rule<file> (perform_update_id, "autoconf.in", rule_);
rs.insert_rule<file> (perform_clean_id, "autoconf.in", rule_);
rs.insert_rule<file> (configure_update_id, "autoconf.in", rule_);
return true;
}