aboutsummaryrefslogtreecommitdiff
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
parent36115f92a7fdebaf13cb968b1acfe3c9973c0df4 (diff)
Adapt to package manifest dependency classes change
-rw-r--r--libbrep/package.hxx25
-rw-r--r--libbrep/package.xml12
-rw-r--r--load/load.cxx50
-rw-r--r--mod/mod-package-version-details.cxx28
-rw-r--r--mod/page.cxx67
5 files changed, 124 insertions, 58 deletions
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 46e5292..d0ac23f 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -20,7 +20,7 @@
//
#define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 21
-#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 23, closed)
+#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 24, closed)
namespace brep
{
@@ -159,23 +159,38 @@ namespace brep
class dependency_alternative: public small_vector<dependency, 1>
{
public:
+ // While we currently don't use the reflect, prefer, accept, and require
+ // values, let's save them for completeness.
+ //
optional<string> enable;
+ optional<string> reflect;
+ optional<string> prefer;
+ optional<string> accept;
+ optional<string> require;
dependency_alternative () = default;
- dependency_alternative (optional<string> e): enable (move (e)) {}
+ dependency_alternative (optional<string> e,
+ butl::optional<std::string> r,
+ butl::optional<std::string> p,
+ butl::optional<std::string> a,
+ butl::optional<std::string> q)
+ : enable (std::move (e)),
+ reflect (std::move (r)),
+ prefer (std::move (p)),
+ accept (std::move (a)),
+ require (std::move (q)) {}
};
#pragma db value
class dependency_alternatives: public small_vector<dependency_alternative, 1>
{
public:
- bool conditional;
bool buildtime;
string comment;
dependency_alternatives () = default;
- dependency_alternatives (bool d, bool b, string c)
- : conditional (d), buildtime (b), comment (move (c)) {}
+ dependency_alternatives (bool b, string c)
+ : buildtime (b), comment (move (c)) {}
};
using dependencies = vector<dependency_alternatives>;
diff --git a/libbrep/package.xml b/libbrep/package.xml
index 72e9c83..ee177a8 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -1,4 +1,16 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="package" version="1">
+ <changeset version="24">
+ <alter-table name="package_dependencies">
+ <drop-column name="conditional"/>
+ </alter-table>
+ <alter-table name="package_dependency_alternatives">
+ <add-column name="reflect" type="TEXT" null="true"/>
+ <add-column name="prefer" type="TEXT" null="true"/>
+ <add-column name="accept" type="TEXT" null="true"/>
+ <add-column name="require" type="TEXT" null="true"/>
+ </alter-table>
+ </changeset>
+
<changeset version="23">
<alter-table name="package_requirements">
<drop-column name="conditional"/>
diff --git a/load/load.cxx b/load/load.cxx
index 34e59a7..ad5379e 100644
--- a/load/load.cxx
+++ b/load/load.cxx
@@ -499,43 +499,41 @@ load_packages (const shared_ptr<repository>& rp,
for (auto& das: pm.dependencies)
{
- // Ignore special build2 and bpkg dependencies. We may not have
- // packages for them and also showing them for every package is
- // probably not very helpful.
- //
- if (das.buildtime && !das.empty ())
- {
- const auto& da (das.front ());
-
- assert (da.size () == 1); // @@ DEP
-
- const package_name& n (da[0].name);
- if (n == "build2" || n == "bpkg")
- continue;
- }
-
- tds.emplace_back (das.conditional,
- das.buildtime,
- move (das.comment));
-
- dependency_alternatives& tdas (tds.back ());
+ dependency_alternatives tdas (das.buildtime, move (das.comment));
for (auto& da: das)
{
- tdas.push_back (dependency_alternative (move (da.enable)));
- dependency_alternative& tda (tdas.back ());
+ dependency_alternative tda (move (da.enable),
+ move (da.reflect),
+ move (da.prefer),
+ move (da.accept),
+ move (da.require));
for (auto& d: da)
{
+ package_name& n (d.name);
+
+ // Ignore special build2 and bpkg dependencies. We may not have
+ // packages for them and also showing them for every package is
+ // probably not very helpful.
+ //
+ if (das.buildtime && (n == "build2" || n == "bpkg"))
+ continue;
+
// The package member will be assigned during dependency
// resolution procedure.
//
- tda.push_back (
- dependency {move (d.name),
- move (d.constraint),
- nullptr /* package */});
+ tda.push_back (dependency {move (n),
+ move (d.constraint),
+ nullptr /* package */});
}
+
+ if (!tda.empty ())
+ tdas.push_back (move (tda));
}
+
+ if (!tdas.empty ())
+ tds.push_back (move (tdas));
}
small_vector<brep::test_dependency, 1> ts;
diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx
index f1a641b..4a1f0c1 100644
--- a/mod/mod-package-version-details.cxx
+++ b/mod/mod-package-version-details.cxx
@@ -325,9 +325,6 @@ handle (request& rq, response& rs)
s << TR(CLASS="depends")
<< TH;
- if (das.conditional)
- s << '?';
-
if (das.buildtime)
s << '*';
@@ -340,9 +337,30 @@ handle (request& rq, response& rs)
if (&da != &das[0])
s << " | ";
- assert (da.size () == 1); // @@ DEP
+ // Should we enclose multiple dependencies into curly braces as in the
+ // manifest? Somehow feels redundant here, since there can't be any
+ // ambiguity (dependency group version constraint is already punched
+ // into the specific dependencies without constraints).
+ //
+ for (const dependency& d: da)
+ {
+ if (&d != &da[0])
+ s << ' ';
+
+ print_dependency (d);
+ }
+
+ if (da.enable)
+ {
+ s << " ? (";
- print_dependency (da[0]);
+ if (full)
+ s << *da.enable;
+ else
+ s << "...";
+
+ s << ')';
+ }
}
s << ~SPAN
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