From 2dbac9c6d08697e28af28178b2ce041140164842 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 7 Feb 2022 14:02:11 +0300 Subject: Introduce package_skeleton for evaluating dependency clauses --- bpkg/pkg-configure.cxx | 59 +++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'bpkg/pkg-configure.cxx') diff --git a/bpkg/pkg-configure.cxx b/bpkg/pkg-configure.cxx index 05073a7..23cd85c 100644 --- a/bpkg/pkg-configure.cxx +++ b/bpkg/pkg-configure.cxx @@ -24,27 +24,24 @@ namespace bpkg // 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. // - static pair> + static pair> pkg_configure_prerequisites (const common_options& o, database& db, transaction&, const dependencies& deps, - const string& bootstrap_build, - const optional& root_build, - const package_name& package, + package_skeleton& ps, bool simulate, const function& fdb) { package_prerequisites pps; - small_vector cvs; + vector cvs; for (const dependency_alternatives_ex& das: deps) { - if (das.empty () || toolchain_buildtime_dependency (o, das, package)) + if (das.empty () || toolchain_buildtime_dependency (o, das, ps.name ())) continue; // Pick the first alternative with dependencies that can all be resolved @@ -54,7 +51,7 @@ namespace bpkg bool enabled (false); // True if there is an enabled alternative. for (const dependency_alternative& da: das) { - if (!evaluate_enabled (da, bootstrap_build, root_build, package)) + if (da.enable && !ps.evaluate_enable (*da.enable)) continue; enabled = true; @@ -175,14 +172,10 @@ namespace bpkg } } - // Add the dependency alternative reflection configuration variable, - // if present. + // Evaluate the dependency alternative reflect clause, if present. // - // @@ DEP For now we assume that the reflection, if present, contains - // a single configuration variable that assigns a literal value. - // - if (!simulate && da.reflect) - cvs.push_back (*da.reflect); + if (da.reflect) + ps.evaluate_reflect (*da.reflect); satisfied = true; break; @@ -192,6 +185,15 @@ namespace bpkg fail << "unable to satisfy dependency on " << das; } + // Add the configuration variables collected from the reflect clauses, if + // any. + // + if (!simulate) + { + for (string& cv: ps.collect_reflect ()) + cvs.push_back (move (cv)); + } + return make_pair (move (pps), move (cvs)); } @@ -201,8 +203,7 @@ namespace bpkg transaction& t, const shared_ptr& p, const dependencies& deps, - const string& bootstrap_build, - const optional& root_build, + package_skeleton& ps, const strings& vars, bool simulate, const function& fdb) @@ -232,14 +233,12 @@ namespace bpkg // assert (p->prerequisites.empty ()); - pair> cpr ( + pair> cpr ( pkg_configure_prerequisites (o, db, t, deps, - bootstrap_build, - root_build, - p->name, + ps, simulate, fdb)); @@ -423,19 +422,21 @@ namespace bpkg l4 ([&]{trace << *p;}); - package_manifest m (pkg_verify (o, - p->effective_src_root (c), - true /* ignore_unknown */, - true /* load_buildfiles */, - [&p] (version& v) {v = p->version;})); + // Let's not bother trying to find an available package for this + // selected package, which may potentially not be present in this + // configuration (but instead be present in the configuration we are + // linked to, etc) and create a transient available package outright. + // + shared_ptr ap (make_available (o, db, p)); + + package_skeleton ps (db, *ap, vars); pkg_configure (o, db, t, p, - convert (move (m.dependencies)), - *m.bootstrap_build, - m.root_build, + ap->dependencies, + ps, vars, false /* simulate */); } -- cgit v1.1