aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-06-14 05:43:17 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-06-14 14:46:53 +0200
commit727531fc3d097413cfc9e972a83abadebed3f35d (patch)
tree1a08ce91db415c94f12316222ee73ef7207e03fd
parentf4bec0b31dfe117aca94c2d72d489460c1f51057 (diff)
Pass both depends and alternative indexes to evaluate_*() functions
-rw-r--r--bpkg/package-configuration.cxx4
-rw-r--r--bpkg/package-skeleton.cxx16
-rw-r--r--bpkg/package-skeleton.hxx13
-rw-r--r--bpkg/pkg-build.cxx7
-rw-r--r--bpkg/pkg-configure.cxx4
5 files changed, 26 insertions, 18 deletions
diff --git a/bpkg/package-configuration.cxx b/bpkg/package-configuration.cxx
index b6c153f..6d0c5c3 100644
--- a/bpkg/package-configuration.cxx
+++ b/bpkg/package-configuration.cxx
@@ -242,9 +242,9 @@ namespace bpkg
// Step 2: execute the prefer/accept or requires clauses.
//
if (!(da.require
- ? dept.evaluate_require (depc_cfgs, *da.require, pos.first)
+ ? dept.evaluate_require (depc_cfgs, *da.require, pos)
: dept.evaluate_prefer_accept (depc_cfgs,
- *da.prefer, *da.accept, pos.first)))
+ *da.prefer, *da.accept, pos)))
{
diag_record dr (fail);
diff --git a/bpkg/package-skeleton.cxx b/bpkg/package-skeleton.cxx
index fb76f67..3156fff 100644
--- a/bpkg/package-skeleton.cxx
+++ b/bpkg/package-skeleton.cxx
@@ -571,8 +571,10 @@ namespace bpkg
}
bool package_skeleton::
- evaluate_enable (const string& cond, size_t depends_index)
+ evaluate_enable (const string& cond, pair<size_t, size_t> indexes)
{
+ size_t depends_index (indexes.first);
+
try
{
using namespace build2;
@@ -630,8 +632,10 @@ namespace bpkg
}
void package_skeleton::
- evaluate_reflect (const string& refl, size_t depends_index)
+ evaluate_reflect (const string& refl, pair<size_t, size_t> indexes)
{
+ size_t depends_index (indexes.first);
+
// The reflect configuration variables are essentially overrides that will
// be passed on the command line when we configure the package. They could
// clash with configuration variables specified by the user (config_vars_)
@@ -955,8 +959,10 @@ namespace bpkg
evaluate_prefer_accept (const dependency_configurations& cfgs,
const string& prefer,
const string& accept,
- size_t depends_index)
+ pair<size_t, size_t> indexes)
{
+ size_t depends_index (indexes.first);
+
assert (dependency_reflect_index_ <= depends_index);
try
@@ -1219,8 +1225,10 @@ namespace bpkg
bool package_skeleton::
evaluate_require (const dependency_configurations& cfgs,
- const string& require, size_t depends_index)
+ const string& require, pair<size_t, size_t> indexes)
{
+ size_t depends_index (indexes.first);
+
assert (dependency_reflect_index_ <= depends_index);
try
diff --git a/bpkg/package-skeleton.hxx b/bpkg/package-skeleton.hxx
index 031c88d..75a8b23 100644
--- a/bpkg/package-skeleton.hxx
+++ b/bpkg/package-skeleton.hxx
@@ -105,19 +105,18 @@ namespace bpkg
dependent_config (const package_configuration&);
// For the following evaluate_*() functions assume that the clause belongs
- // to the specified (by index) depends value (used to print its location
- // on failure for an external package).
- //
+ // to the dependency alternative specified as a pair of indexes (depends
+ // value index and alternative index).
// Evaluate the enable clause.
//
bool
- evaluate_enable (const string&, size_t depends_index);
+ evaluate_enable (const string&, pair<size_t, size_t>);
// Evaluate the reflect clause.
//
void
- evaluate_reflect (const string&, size_t depends_index);
+ evaluate_reflect (const string&, pair<size_t, size_t>);
// Evaluate the prefer/accept or require clauses on the specified
// dependency configurations (serves as both input and output).
@@ -130,11 +129,11 @@ namespace bpkg
bool
evaluate_prefer_accept (const dependency_configurations&,
- const string&, const string&, size_t depends_index);
+ const string&, const string&, pair<size_t, size_t>);
bool
evaluate_require (const dependency_configurations&,
- const string&, size_t depends_index);
+ const string&, pair<size_t, size_t>);
// Reset the skeleton to the start of the call sequence.
//
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index ca3387f..9a92df7 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -3278,7 +3278,8 @@ namespace bpkg
{
const dependency_alternative& da (das[i]);
- if (!da.enable || skel.evaluate_enable (*da.enable, di))
+ if (!da.enable ||
+ skel.evaluate_enable (*da.enable, make_pair (di, i)))
edas.push_back (make_pair (ref (da), i));
}
}
@@ -4948,7 +4949,7 @@ namespace bpkg
salts.push_back (dai);
if (da.reflect)
- skel.evaluate_reflect (*da.reflect, di);
+ skel.evaluate_reflect (*da.reflect, make_pair (di, dai));
selected = true;
};
@@ -6349,7 +6350,7 @@ namespace bpkg
// Evaluate reflect, if present.
//
if (da.reflect)
- b->skeleton->evaluate_reflect (*da.reflect, di);
+ b->skeleton->evaluate_reflect (*da.reflect, make_pair (di, dai));
}
// Continue recursively collecting the dependent.
diff --git a/bpkg/pkg-configure.cxx b/bpkg/pkg-configure.cxx
index 32cace3..477ead0 100644
--- a/bpkg/pkg-configure.cxx
+++ b/bpkg/pkg-configure.cxx
@@ -97,7 +97,7 @@ namespace bpkg
{
const dependency_alternative& da (das[i]);
- if (!da.enable || ps.evaluate_enable (*da.enable, di))
+ if (!da.enable || ps.evaluate_enable (*da.enable, make_pair (di, i)))
{
if (da.prefer || da.require)
fail << "manual configuration of dependents with prefer or "
@@ -273,7 +273,7 @@ namespace bpkg
// Evaluate the dependency alternative reflect clause, if present.
//
if (da.reflect)
- ps.evaluate_reflect (*da.reflect, di);
+ ps.evaluate_reflect (*da.reflect, make_pair (di, dai));
satisfied = true;
break;