From df79f83187ecb91569b254ecbd90f46edabe8826 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 18 Mar 2022 21:01:55 +0300 Subject: Fix pkg-build to re-evaluate buildfile clauses in dependencies if configuration variables are specified for dependent --- bpkg/pkg-build.cxx | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'bpkg/pkg-build.cxx') diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index e77b21b..3d0c47f 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -1202,18 +1202,29 @@ namespace bpkg // Collect prerequisites of the package being built recursively. // // But first "prune" this process if the package we build is a system one - // or is already configured and is not a repointed dependent, since that - // would mean all its prerequisites are configured as well. Note that this - // is not merely an optimization: the package could be an orphan in which - // case the below logic will fail (no repository fragment in which to - // search for prerequisites). By skipping the prerequisite check we are - // able to gracefully handle configured orphans. - // - // For the repointed dependent, we still need to collect its prerequisite - // replacements to make sure its constraints over them are satisfied. Note - // that, as it was said above, we can potentially fail if the dependent is - // an orphan, but this is exactly what we need to do in that case, since - // we won't be able to be reconfigure it anyway. + // or is already configured, since that would mean all its prerequisites + // are configured as well. Note that this is not merely an optimization: + // the package could be an orphan in which case the below logic will fail + // (no repository fragment in which to search for prerequisites). By + // skipping the prerequisite check we are able to gracefully handle + // configured orphans. + // + // There are, however, some cases when we still need to re-collect + // prerequisites of a configured package: + // + // - For the repointed dependent we still need to collect its prerequisite + // replacements to make sure its dependency constraints are satisfied. + // + // - If configuration variables are specified for the dependent which has + // any buildfile clauses in the dependencies, then we need to + // re-evaluate them. This can result in a different set of dependencies + // required by this dependent (due to conditional dependencies, etc) + // and, potentially, for its reconfigured existing prerequisites, + // recursively. + // + // Note that for these cases, as it was said above, we can potentially + // fail if the dependent is an orphan, but this is exactly what we need to + // do in that case, since we won't be able to re-collect its dependencies. // // Only a single true dependency alternative can be selected per function // call. Such an alternative can only be selected if its index in the @@ -1259,6 +1270,8 @@ namespace bpkg // const map* rpt_prereq_flags (nullptr); + assert (ap != nullptr); + // Bail out if this is a configured non-system package and no // up/down-grade nor collecting prerequisite replacements are required. // @@ -1274,12 +1287,13 @@ namespace bpkg if (i != rpt_depts.end ()) rpt_prereq_flags = &i->second; - if (!ud && rpt_prereq_flags == nullptr) + if (!ud && + rpt_prereq_flags == nullptr && + (pkg.config_vars.empty () || + !has_buildfile_clause (ap->dependencies))) return; } - assert (ap != nullptr); - // Iterate over dependencies, trying to unambiguously select a // satisfactory dependency alternative for each of them. Fail or // postpone the collection if unable to do so. @@ -3269,7 +3283,10 @@ namespace bpkg // not as a system package, then that means we can use its // prerequisites list. Otherwise, we use the manifest data. // - if (src_conf && sp->version == p.available_version ()) + if (src_conf && + sp->version == p.available_version () && + (p.config_vars.empty () || + !has_buildfile_clause (ap->dependencies))) { for (const auto& p: sp->prerequisites) { -- cgit v1.1