diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2022-01-12 14:28:43 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2022-01-28 12:21:33 +0300 |
commit | b90cbd6de11442500bbb6e0cdfe0bdcb286d67ec (patch) | |
tree | 22c89ff84779c8e4ccbae2b953b4110063fc52f6 /bpkg/pkg-configure.cxx | |
parent | f02e6f0bd299fc3b1dafb8c5b9bac78b78858e89 (diff) |
Add support for multiple dependency alternatives
Diffstat (limited to 'bpkg/pkg-configure.cxx')
-rw-r--r-- | bpkg/pkg-configure.cxx | 52 |
1 files changed, 17 insertions, 35 deletions
diff --git a/bpkg/pkg-configure.cxx b/bpkg/pkg-configure.cxx index 136bf50..8e53d62 100644 --- a/bpkg/pkg-configure.cxx +++ b/bpkg/pkg-configure.cxx @@ -20,10 +20,11 @@ namespace bpkg { // Given dependencies of a package, return its prerequisite packages and // configuration variables that resulted from selection of these - // prerequisites (import, reflection, etc). Fail if for some of the - // dependency alternative lists there is no satisfactory alternative (all - // its dependencies are configured and satisfy the respective constraints, - // etc). Note that the package argument is used for diagnostics only. + // prerequisites (import, reflection, etc). See pkg_configure() for the + // semantics of the dependency list. Fail if for some of the dependency + // alternative lists there is no satisfactory alternative (all its + // dependencies are configured, satisfy the respective constraints, etc). + // Note that the package argument is used for diagnostics only. // // Note: loads selected packages. // @@ -41,16 +42,21 @@ namespace bpkg for (const dependency_alternatives_ex& das: deps) { - // @@ DEP Currently we just pick the first alternative with dependencies - // that can all be resolved to the configured packages, satisfying - // the respective constraints. Later, we should also evaluate the - // alternative enable conditions. - // - assert (!das.conditional ()); + if (das.empty () || toolchain_buildtime_dependency (o, das, package)) + continue; + // Pick the first alternative with dependencies that can all be resolved + // to the configured packages, satisfying the respective constraints. + // bool satisfied (false); + bool enabled (false); // True if there is an enabled alternative. for (const dependency_alternative& da: das) { + if (!evaluate_enabled (da, package)) + continue; + + enabled = true; + // Cache the selected packages which correspond to the alternative // dependencies, pairing them with the respective constraints. If the // alternative turns out to be fully resolvable, we will add the @@ -71,30 +77,6 @@ namespace bpkg const dependency& d (*i); const package_name& n (d.name); - if (das.buildtime) - { - // Handle special names. - // - if (n == "build2") - { - if (d.constraint && !satisfy_build2 (o, d)) - fail << "unable to satisfy constraint (" << d - << ") for package " << package << - info << "available build2 version is " << build2_version; - - continue; - } - else if (n == "bpkg") - { - if (d.constraint && !satisfy_bpkg (o, d)) - fail << "unable to satisfy constraint (" << d - << ") for package " << package << - info << "available bpkg version is " << bpkg_version; - - continue; - } - } - database* ddb (fdb ? fdb (db, n, das.buildtime) : nullptr); pair<shared_ptr<selected_package>, database*> spd ( @@ -204,7 +186,7 @@ namespace bpkg break; } - if (!satisfied) + if (enabled && !satisfied) fail << "unable to satisfy dependency on " << das; } |