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/database.cxx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'bpkg/database.cxx') diff --git a/bpkg/database.cxx b/bpkg/database.cxx index dd6790a..4f3b102 100644 --- a/bpkg/database.cxx +++ b/bpkg/database.cxx @@ -936,6 +936,39 @@ namespace bpkg empty_string /* type */); } + linked_databases database:: + cluster_configs (bool sys_rep) + { + linked_databases r; + + // If the database is not in the resulting list, then add it and its + // dependent and dependency configurations, recursively. + // + auto add = [&r, sys_rep] (database& db, const auto& add) + { + if (std::find (r.begin (), r.end (), db) != r.end ()) + return; + + r.push_back (db); + + { + linked_databases cs (db.dependency_configs ()); + for (auto i (cs.begin_linked ()); i != cs.end (); ++i) + add (*i, add); + } + + { + linked_databases cs (db.dependent_configs (sys_rep)); + for (auto i (cs.begin_linked ()); i != cs.end (); ++i) + add (*i, add); + } + }; + + add (*this, add); + + return r; + } + database& database:: find_attached (uint64_t id, bool s) { -- cgit v1.1