From c9d13dff940ab16e28f2440a819a0151a3a7543f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 2 Dec 2021 15:27:42 +0300 Subject: Prepare for supporting multiple dependencies in dependency alternative --- bpkg/rep-fetch.cxx | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'bpkg/rep-fetch.cxx') diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx index 675dad0..d7e626c 100644 --- a/bpkg/rep-fetch.cxx +++ b/bpkg/rep-fetch.cxx @@ -1496,7 +1496,7 @@ namespace bpkg ds.push_back (dependency_alternatives_ex (td.type, td.buildtime)); - dependency_alternatives_ex& da (ds.back ()); + dependency_alternatives_ex& das (ds.back ()); // Note that since we store all the primary packages as // alternative dependencies (which must be all of the same @@ -1507,18 +1507,36 @@ namespace bpkg // `== ` constraints (see below), so we can use min // version of such a constraint as the primary package version. // - if (da.buildtime != td.buildtime) + if (das.buildtime != td.buildtime) + { + // Could only be empty if we just added it, which cannot be the + // case since the build-time flag differs. + // + assert (!das.empty ()); + + const dependency_alternative& da (das[0]); + + // We always add the primary package to the test package as a + // single-dependency alternative (see below). + // + assert (da.size () == 1); + fail << to_string (td.type) << " package " << td.name << " is a " << "build-time dependency for one primary package and a " << "run-time for another" << - info << (da.buildtime ? "build-time for " : "run-time for ") + info << (das.buildtime ? "build-time for " : "run-time for ") << package_string (da[0].name, *da[0].constraint->min_version) << info << (td.buildtime ? "build-time for " : "run-time for ") << package_string (p->id.name, p->version); + } + + dependency_alternative da; + + da.push_back ( + dependency {p->id.name, version_constraint (p->version)}); - da.push_back (dependency {p->id.name, - version_constraint (p->version)}); + das.push_back (move (da)); db.update (tp); } -- cgit v1.1