From 56e0a851185136dbdd6f1eaa75f44da774a61e51 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 23 Dec 2021 21:10:53 +0300 Subject: Add support for multiple dependencies in alternative --- bpkg/pkg-verify.cxx | 81 +++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 36 deletions(-) (limited to 'bpkg/pkg-verify.cxx') diff --git a/bpkg/pkg-verify.cxx b/bpkg/pkg-verify.cxx index a65eeef..f2d9881 100644 --- a/bpkg/pkg-verify.cxx +++ b/bpkg/pkg-verify.cxx @@ -68,58 +68,67 @@ namespace bpkg { for (const dependency_alternative& da: das) { - assert (da.size () == 1); // @@ DEP - - const dependency& d (da[0]); - const package_name& dn (d.name); - - if (dn != "build2" && dn != "bpkg") - continue; - - if (das.size () != 1) + for (const dependency& d: da) { - if (diag_level != 0) - error (p.name (), nv.value_line, nv.value_column) - << "alternatives in " << dn << " dependency"; + const package_name& dn (d.name); - throw failed (); - } + if (dn != "build2" && dn != "bpkg") + continue; - if (dn == "build2") - { - if (d.constraint && !satisfy_build2 (co, d)) + if (da.size () != 1) { if (diag_level != 0) - { - diag_record dr (error); - dr << "unable to satisfy constraint (" << d << ")"; + error (p.name (), nv.value_line, nv.value_column) + << "multiple names in " << dn << " dependency"; - if (!what.empty ()) - dr << " for package " << what; + throw failed (); + } - dr << info << "available build2 version is " - << build2_version; - } + if (das.size () != 1) + { + if (diag_level != 0) + error (p.name (), nv.value_line, nv.value_column) + << "alternatives in " << dn << " dependency"; throw failed (); } - } - else - { - if (d.constraint && !satisfy_bpkg (co, d)) + + if (dn == "build2") { - if (diag_level != 0) + if (d.constraint && !satisfy_build2 (co, d)) { - diag_record dr (error); - dr << "unable to satisfy constraint (" << d << ")"; + if (diag_level != 0) + { + diag_record dr (error); + dr << "unable to satisfy constraint (" << d << ")"; - if (!what.empty ()) - dr << " for package " << what; + if (!what.empty ()) + dr << " for package " << what; - dr << "available bpkg version is " << bpkg_version; + dr << info << "available build2 version is " + << build2_version; + } + + throw failed (); } + } + else + { + if (d.constraint && !satisfy_bpkg (co, d)) + { + if (diag_level != 0) + { + diag_record dr (error); + dr << "unable to satisfy constraint (" << d << ")"; - throw failed (); + if (!what.empty ()) + dr << " for package " << what; + + dr << "available bpkg version is " << bpkg_version; + } + + throw failed (); + } } } } -- cgit v1.1