aboutsummaryrefslogtreecommitdiff
path: root/mod/page.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-12-22 21:52:01 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-01-17 19:22:38 +0300
commit4a5ca6f9853938eec8b5e487dc6cb3728dfb6a15 (patch)
tree29963bae3dddd53f8d17b10e0e77761f62a78d25 /mod/page.cxx
parent36115f92a7fdebaf13cb968b1acfe3c9973c0df4 (diff)
Adapt to package manifest dependency classes change
Diffstat (limited to 'mod/page.cxx')
-rw-r--r--mod/page.cxx67
1 files changed, 45 insertions, 22 deletions
diff --git a/mod/page.cxx b/mod/page.cxx
index 8d315e9..a73e336 100644
--- a/mod/page.cxx
+++ b/mod/page.cxx
@@ -421,47 +421,67 @@ namespace brep
if (&das != &dependencies_[0])
s << ", ";
- if (das.conditional)
- s << "?";
-
if (das.buildtime)
s << "*";
- // Suppress package name duplicates.
+ // Suppress dependency alternative duplicates, like in
+ // `{foo bar} < 1.1 | {foo bar} > 1.5`.
//
- set<package_name> names;
- for (const dependency_alternative& da: das)
+ // Return the dependency package name space-separated list.
+ //
+ auto deps_list = [] (const dependency_alternative& da)
{
- assert (da.size () == 1); // @@ DEP
+ string r;
+ for (const dependency& d: da)
+ {
+ if (!r.empty ())
+ r += ' ';
- names.emplace (da[0].name);
- }
+ r += d.name.string ();
+ }
+
+ return r;
+ };
- bool mult (names.size () > 1);
+ set<string> alternatives;
+ for (const dependency_alternative& da: das)
+ alternatives.insert (deps_list (da));
+
+ // Note that we may end up with a single package name in parenthesis, if
+ // its duplicates were suppresses. This, however, may be helpful,
+ // indicating that there some alternatives for the package.
+ //
+ bool mult (das.size () > 1 ||
+ (das.size () == 1 && das[0].size () > 1));
if (mult)
- s << "(";
+ s << '(';
bool first (true);
for (const dependency_alternative& da: das)
{
- assert (da.size () == 1); // @@ DEP
+ auto i (alternatives.find (deps_list (da)));
- const dependency& d (da[0]);
+ if (i == alternatives.end ())
+ continue;
- const package_name& n (d.name);
- if (names.find (n) != names.end ())
- {
- names.erase (n);
+ alternatives.erase (i);
- if (first)
- first = false;
- else
- s << " | ";
+ if (!first)
+ s << " | ";
+ else
+ first = false;
+
+ for (const dependency& d: da)
+ {
+ if (&d != &da[0])
+ s << ' ';
// Try to display the dependency as a link if it is resolved.
// Otherwise display it as plain text.
//
+ const package_name& n (d.name);
+
if (d.package != nullptr)
{
shared_ptr<package> p (d.package.load ());
@@ -487,10 +507,13 @@ namespace brep
else
s << n;
}
+
+ if (da.enable)
+ s << " ?";
}
if (mult)
- s << ")";
+ s << ')';
}
s << ~SPAN