diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-03-28 15:04:35 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-06-20 09:17:52 +0200 |
commit | def2c2dfaf5374f139b310c4f05b0614cb99359e (patch) | |
tree | 53035c3bb52b1f6d1f59992bab7df3e256f6be9b /bpkg/package.cxx | |
parent | 4c5fe206eff86e80a4c41977320db67e2779fc32 (diff) |
Implement dependency configuration negotiation
For the detailed history see the dep-config and dep-config-neg branches.
Diffstat (limited to 'bpkg/package.cxx')
-rw-r--r-- | bpkg/package.cxx | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/bpkg/package.cxx b/bpkg/package.cxx index 3a356f8..c02bdf4 100644 --- a/bpkg/package.cxx +++ b/bpkg/package.cxx @@ -53,17 +53,17 @@ namespace bpkg return path; } - // config_package + // package_key // - string config_package:: + string package_key:: string () const { - const std::string& s (db.string); + const std::string& s (db.get ().string); return !s.empty () ? name.string () + ' ' + s : name.string (); } - bool config_package:: - operator< (const config_package& v) const + bool package_key:: + operator< (const package_key& v) const { int r (name.compare (v.name)); return r != 0 ? (r < 0) : (db < v.db); @@ -827,7 +827,7 @@ namespace bpkg bool toolchain_buildtime_dependency (const common_options& o, const dependency_alternatives_ex& das, - const package_name& pkg) + const package_name* pkg) { if (das.buildtime) { @@ -839,10 +839,10 @@ namespace bpkg if (dn == "build2") { - if (d.constraint && !satisfy_build2 (o, d)) + if (pkg != nullptr && d.constraint && !satisfy_build2 (o, d)) { fail << "unable to satisfy constraint (" << d << ") for " - << "package " << pkg << + << "package " << *pkg << info << "available build2 version is " << build2_version; } @@ -850,10 +850,10 @@ namespace bpkg } else if (dn == "bpkg") { - if (d.constraint && !satisfy_bpkg (o, d)) + if (pkg != nullptr && d.constraint && !satisfy_bpkg (o, d)) { fail << "unable to satisfy constraint (" << d << ") for " - << "package " << pkg << + << "package " << *pkg << info << "available bpkg version is " << bpkg_version; } @@ -865,4 +865,18 @@ namespace bpkg return false; } + + bool + has_dependencies (const common_options& o, + const dependencies& deps, + const package_name* pkg) + { + for (const auto& das: deps) + { + if (!toolchain_buildtime_dependency (o, das, pkg)) + return true; + } + + return false; + } } |