Adjust to new target auxiliary data storage interface and semantics

This commit is contained in:
Boris Kolpackov 2022-04-20 11:03:10 +02:00
parent ca7bedbbd3
commit c95f077194

View File

@ -19,11 +19,25 @@ namespace build2
{ {
enum class flavor {autoconf, cmake, meson}; enum class flavor {autoconf, cmake, meson};
// Wrap the in::rule's perform_update recipe into a data-carrying recipe.
//
// To optimize this a bit further we will call in::rule::perform_update()
// directly (after all it's virtual and thus part of the in_rule's
// interface).
//
struct match_data struct match_data
{ {
autoconf::flavor flavor; autoconf::flavor flavor;
string prefix; string prefix;
map<string, string> checks; // Checks already seen. map<string, string> checks; // Checks already seen.
const autoconf::rule& rule;
target_state
operator() (action a, const target& t)
{
return rule.perform_update (a, t);
}
}; };
rule:: rule::
@ -33,8 +47,6 @@ namespace build2
'@' /* symbol */, '@' /* symbol */,
false /* strict */) false /* strict */)
{ {
static_assert (sizeof (match_data) <= target::data_size,
"insufficient space");
} }
recipe rule:: recipe rule::
@ -42,6 +54,8 @@ namespace build2
{ {
recipe r (in::rule::apply (a, t)); recipe r (in::rule::apply (a, t));
if (a == perform_update_id)
{
// Determine and cache the configuration file flavor. // Determine and cache the configuration file flavor.
// //
flavor f (flavor::autoconf); flavor f (flavor::autoconf);
@ -79,17 +93,18 @@ namespace build2
// //
string p (cast_empty<string> (t["autoconf.prefix"])); string p (cast_empty<string> (t["autoconf.prefix"]));
t.data (match_data {f, move (p), {}}); return match_data {f, move (p), {}, *this};
}
return r; return r;
} }
void rule:: void rule::
perform_update_depdb (action, const target& t, depdb& dd) const perform_update_depdb (action a, const target& t, depdb& dd) const
{ {
tracer trace ("autoconf::rule::perform_update_depdb"); tracer trace ("autoconf::rule::perform_update_depdb");
const match_data& md (t.data<match_data> ()); const match_data& md (t.data<match_data> (a));
// Then the flavor. // Then the flavor.
// //
@ -111,12 +126,14 @@ namespace build2
} }
void rule:: void rule::
perform_update_pre (action, const target& t, ofdstream&, const char*) const perform_update_pre (action a, const target& t,
ofdstream&,
const char*) const
{ {
// Clear the checks set which may have already been partially populated // Clear the checks set which may have already been partially populated
// during depdb verification. // during depdb verification.
// //
t.data<match_data> ().checks.clear (); t.data<match_data> (a).checks.clear ();
} }
void rule:: void rule::
@ -153,7 +170,7 @@ namespace build2
size_t i (b); size_t i (b);
flavor f (t.data<match_data> ().flavor); flavor f (t.data<match_data> (a).flavor);
// Substitute special #undef/#cmakedfine/#mesondefine line. If value is // Substitute special #undef/#cmakedfine/#mesondefine line. If value is
// false, then do not append the value to #define. // false, then do not append the value to #define.
@ -467,7 +484,7 @@ namespace build2
{ {
assert (*flags == 1); assert (*flags == 1);
match_data& md (t.data<match_data> ()); match_data& md (t.data<match_data> (a));
// If this is a special substitution, then look in our catalog of // If this is a special substitution, then look in our catalog of
// built-in checks. Specifically, the plan is as follows: // built-in checks. Specifically, the plan is as follows: