From 987bf4a6522e642a1e4dfe276d4fc1efbb2b52b5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 19 Aug 2021 21:23:50 +0300 Subject: Add support for build-time mark (*) in tests, examples, and benchmarks package manifest values --- bpkg/rep-fetch.cxx | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'bpkg/rep-fetch.cxx') diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx index de6e3b7..7e0d3da 100644 --- a/bpkg/rep-fetch.cxx +++ b/bpkg/rep-fetch.cxx @@ -1448,10 +1448,32 @@ namespace bpkg dependencies& ds (tp->dependencies); if (ds.empty () || !ds.back ().type) - ds.push_back (dependency_alternatives_ex (td.type)); + ds.push_back (dependency_alternatives_ex (td.type, + td.buildtime)); - ds.back ().push_back ( - dependency {p->id.name, version_constraint (p->version)}); + dependency_alternatives_ex& da (ds.back ()); + + // Note that since we store all the primary packages as + // alternative dependencies (which must be all of the same + // dependency type) for the test package, it must either be a + // runtime or build-time dependency for all of them. + // + // Note that the test package alternative dependencies contain the + // `== ` constraints (see below), so we can use min + // version of such a constraint as the primary package version. + // + if (da.buildtime != td.buildtime) + 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 ") + << 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); + + da.push_back (dependency {p->id.name, + version_constraint (p->version)}); db.update (tp); } -- cgit v1.1