aboutsummaryrefslogtreecommitdiff
path: root/bpkg/rep-fetch.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-06-24 22:12:01 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-06-26 15:29:44 +0300
commit58357d79110a925dcb3cdc734d812f17b6465c17 (patch)
tree2b5f4714e038f1b0cefcca64b427e6ae9772833f /bpkg/rep-fetch.cxx
parent86700536f5ca500c4a837d03626f672dcfdbb97d (diff)
Fix build order for test and main packages
Diffstat (limited to 'bpkg/rep-fetch.cxx')
-rw-r--r--bpkg/rep-fetch.cxx69
1 files changed, 66 insertions, 3 deletions
diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx
index 1b8e00a..b58ef2c 100644
--- a/bpkg/rep-fetch.cxx
+++ b/bpkg/rep-fetch.cxx
@@ -5,7 +5,6 @@
#include <map>
#include <set>
-#include <algorithm> // equal()
#include <libbutl/manifest-parser.mxx>
@@ -1273,8 +1272,8 @@ namespace bpkg
}
}
- // Finally, make sure that the external packages are available from a
- // single directory-based repository.
+ // Make sure that the external packages are available from a single
+ // directory-based repository.
//
// Sort the packages by name and version. This way the external packages
// with the same upstream version and revision will be adjacent. Note
@@ -1324,6 +1323,70 @@ namespace bpkg
ap = id;
rf = f;
}
+
+ // Finally, invert the main packages external test dependencies into the
+ // the test packages special test dependencies.
+ //
+ // But first, remove the existing (and possibly outdated) special test
+ // dependencies from the test packages, unless all the available
+ // packages are (re)created from scratch.
+ //
+ if (!full_fetch)
+ {
+ for (const auto& at: db.query<available_test> ())
+ {
+ dependencies& ds (at.package->dependencies);
+
+ // Note that the special test dependencies entry is always the last
+ // one, if present.
+ //
+ assert (!ds.empty () && ds.back ().type);
+
+ ds.pop_back ();
+
+ db.update (at.package);
+ }
+ }
+
+ // Go through the available packages that have external tests and add
+ // them as the special test dependencies to these test packages.
+ //
+ for (const auto& am: db.query<available_main> ())
+ {
+ const shared_ptr<available_package>& p (am.package);
+
+ vector<shared_ptr<repository_fragment>> rfs;
+
+ for (const package_location& pl: p->locations)
+ rfs.push_back (pl.repository_fragment.load ());
+
+ for (const test_dependency& td: p->tests)
+ {
+ vector<pair<shared_ptr<available_package>,
+ shared_ptr<repository_fragment>>> tps (
+ filter (rfs,
+ query_available (db,
+ td.name,
+ td.constraint,
+ false /* order */),
+ false /* prereq */));
+
+ for (const auto& t: tps)
+ {
+ const shared_ptr<available_package>& tp (t.first);
+
+ dependencies& ds (tp->dependencies);
+
+ if (ds.empty () || !ds.back ().type)
+ ds.push_back (dependency_alternatives_ex (td.type));
+
+ ds.back ().push_back (
+ dependency {p->id.name, version_constraint (p->version)});
+
+ db.update (tp);
+ }
+ }
+ }
}
catch (const failed&)
{