From 9b6086440aa261fc376c8293df2345050658dd2b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 7 Oct 2021 22:36:01 +0300 Subject: Allow building build module in multiple configurations if they belong to different configuration clusters --- bpkg/pkg-build.cxx | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'bpkg/pkg-build.cxx') diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index 51bd224..dd48440 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -6218,15 +6218,18 @@ namespace bpkg verify_dependencies); // Now, verify that none of the build2 modules may simultaneously be - // built in multiple configurations, accross all (potentially - // unrelated) dependency trees. + // built in multiple configurations which belong to the same linked + // configuration cluster. // // For that we use the `package_prereqs` map: its key set refers to // all the packages potentially involved into the build (explicitly // or implicitly). // { - map build2_mods; + // List of module packages together with the linked configuration + // clusters they belong to. + // + vector> build2_mods; for (const auto& pp: package_prereqs) { @@ -6249,22 +6252,33 @@ namespace bpkg continue; } - auto i (build2_mods.emplace (cp.name, cp.db)); - - if (!i.second) + // Make sure the module's database doesn't belong to any other + // cluster this module is also configured in. + // + for (const auto& m: build2_mods) { - database& db (i.first->second); + if (m.first.name != cp.name) + continue; // The `package_prereqs` map can only contain the same package // twice if databases differ. // - assert (db != cp.db); + assert (m.first.db != cp.db); + + const linked_databases& lcc (m.second); - fail << "building build system module " << cp.name << " in " - << "multiple configurations" << - info << db.config_orig << - info << cp.db.config_orig; + if (find (lcc.begin (), lcc.end (), cp.db) != lcc.end ()) + { + fail << "building build system module " << cp.name + << " in multiple configurations" << + info << m.first.db.config_orig << + info << cp.db.config_orig; + } } + + // Add the module and its cluster to the list. + // + build2_mods.emplace_back (cp, cp.db.cluster_configs ()); } } } -- cgit v1.1