aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-19 18:39:34 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-19 18:39:34 +0100
commit569f1766e8fe4a2a16f20894b6530cb1b86f4d48 (patch)
treebe26e4d5bfde735c5bcb3abaed6ce0bb845373df
parenta3e36c8d731798e9ca930b9fdd4e99cda155dbd5 (diff)
downloadpaludis-569f1766e8fe4a2a16f20894b6530cb1b86f4d48.tar.gz
paludis-569f1766e8fe4a2a16f20894b6530cb1b86f4d48.tar.xz
Track active dependency labels
-rw-r--r--paludis/resolver/collect_depped_upon.cc64
-rw-r--r--paludis/resolver/collect_depped_upon.hh2
2 files changed, 50 insertions, 16 deletions
diff --git a/paludis/resolver/collect_depped_upon.cc b/paludis/resolver/collect_depped_upon.cc
index 49dbd6f..645ece8 100644
--- a/paludis/resolver/collect_depped_upon.cc
+++ b/paludis/resolver/collect_depped_upon.cc
@@ -42,6 +42,7 @@
#include <paludis/serialise-impl.hh>
#include <algorithm>
+#include <sstream>
using namespace paludis;
using namespace paludis::resolver;
@@ -64,7 +65,9 @@ namespace
template <>
struct ResultValueMaker<std::shared_ptr<const PackageID> >
{
- static const std::shared_ptr<const PackageID> create(const std::shared_ptr<const PackageID> & i)
+ static const std::shared_ptr<const PackageID> create(
+ const std::shared_ptr<const PackageID> & i,
+ const std::shared_ptr<const DependenciesLabelSequence> &)
{
return i;
}
@@ -73,9 +76,16 @@ namespace
template <>
struct ResultValueMaker<DependentPackageID>
{
- static DependentPackageID create(const ChangeByResolvent & r)
+ static DependentPackageID create(
+ const ChangeByResolvent & r,
+ const std::shared_ptr<const DependenciesLabelSequence> & s)
{
+ std::stringstream adl;
+ for (auto l(s->begin()), l_end(s->end()) ; l != l_end ; ++l)
+ adl << (adl.str().empty() ? "" : ", ") << stringify(**l);
+
return make_named_values<DependentPackageID>(
+ n::active_dependency_labels_as_string() = adl.str(),
n::package_id() = r.package_id(),
n::resolvent() = r.resolvent()
);
@@ -112,6 +122,8 @@ namespace
const std::shared_ptr<const PackageIDSequence> not_changing_slots;
const std::shared_ptr<R_> result;
+ std::list<std::shared_ptr<const DependenciesLabelSequence> > labels_stack;
+
DependentChecker(
const Environment * const e,
const std::shared_ptr<const PackageID> & i,
@@ -125,6 +137,7 @@ namespace
not_changing_slots(s),
result(std::make_shared<R_>())
{
+ labels_stack.push_front(std::make_shared<DependenciesLabelSequence>());
}
void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & s)
@@ -169,7 +182,7 @@ namespace
}
if (! any)
- result->push_back(ResultValueMaker<typename R_::value_type>::create(*g));
+ result->push_back(ResultValueMaker<typename R_::value_type>::create(*g, *labels_stack.begin()));
}
}
@@ -180,24 +193,32 @@ namespace
void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & s)
{
if (s.spec()->condition_met(env, id_for_specs))
- std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
- accept_visitor(*this));
+ {
+ labels_stack.push_front(*labels_stack.begin());
+ std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()), accept_visitor(*this));
+ labels_stack.pop_front();
+ }
}
void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & s)
{
- std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
- accept_visitor(*this));
+ labels_stack.push_front(*labels_stack.begin());
+ std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()), accept_visitor(*this));
+ labels_stack.pop_front();
}
void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & s)
{
- std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
- accept_visitor(*this));
+ labels_stack.push_front(*labels_stack.begin());
+ std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()), accept_visitor(*this));
+ labels_stack.pop_front();
}
- void visit(const DependencySpecTree::NodeType<DependenciesLabelsDepSpec>::Type &)
+ void visit(const DependencySpecTree::NodeType<DependenciesLabelsDepSpec>::Type & node)
{
+ std::shared_ptr<DependenciesLabelSequence> labels(std::make_shared<DependenciesLabelSequence>());
+ std::copy(node.spec()->begin(), node.spec()->end(), labels->back_inserter());
+ *labels_stack.begin() = labels;
}
};
}
@@ -212,15 +233,24 @@ paludis::resolver::dependent_upon(
{
DependentChecker<ChangeByResolventSequence, DependentPackageIDSequence> c(env, id, going_away, staying, not_changing_slots);
if (id->dependencies_key())
+ {
+ c.labels_stack.push_front(id->dependencies_key()->initial_labels());
id->dependencies_key()->parse_value()->top()->accept(c);
+ c.labels_stack.pop_front();
+ }
else
{
- if (id->build_dependencies_key())
- id->build_dependencies_key()->parse_value()->top()->accept(c);
- if (id->run_dependencies_key())
- id->run_dependencies_key()->parse_value()->top()->accept(c);
- if (id->post_dependencies_key())
- id->post_dependencies_key()->parse_value()->top()->accept(c);
+ auto k({ &PackageID::build_dependencies_key, &PackageID::run_dependencies_key, &PackageID::post_dependencies_key });
+ for (auto i(k.begin()), i_end(k.end()) ; i != i_end ; ++i)
+ {
+ auto key(((*id).*(*i))());
+ if (key)
+ {
+ c.labels_stack.push_front(key->initial_labels());
+ key->parse_value()->top()->accept(c);
+ c.labels_stack.pop_front();
+ }
+ }
}
return c.result;
@@ -291,6 +321,7 @@ void
DependentPackageID::serialise(Serialiser & s) const
{
s.object("DependentPackageID")
+ .member(SerialiserFlags<>(), "active_dependency_labels_as_string", active_dependency_labels_as_string())
.member(SerialiserFlags<serialise::might_be_null>(), "package_id", package_id())
.member(SerialiserFlags<>(), "resolvent", resolvent())
;
@@ -301,6 +332,7 @@ DependentPackageID::deserialise(Deserialisation & d)
{
Deserialisator v(d, "DependentPackageID");
return make_named_values<DependentPackageID>(
+ n::active_dependency_labels_as_string() = v.member<std::string>("active_dependency_labels_as_string"),
n::package_id() = v.member<std::shared_ptr<const PackageID> >("package_id"),
n::resolvent() = v.member<Resolvent>("resolvent")
);
diff --git a/paludis/resolver/collect_depped_upon.hh b/paludis/resolver/collect_depped_upon.hh
index 78dd500..5424f94 100644
--- a/paludis/resolver/collect_depped_upon.hh
+++ b/paludis/resolver/collect_depped_upon.hh
@@ -34,6 +34,7 @@ namespace paludis
{
namespace n
{
+ typedef Name<struct name_active_dependency_labels_as_string> active_dependency_labels_as_string;
typedef Name<struct name_package_id> package_id;
typedef Name<struct name_resolvent> resolvent;
}
@@ -42,6 +43,7 @@ namespace paludis
{
struct DependentPackageID
{
+ NamedValue<n::active_dependency_labels_as_string, std::string> active_dependency_labels_as_string;
NamedValue<n::package_id, std::shared_ptr<const PackageID> > package_id;
NamedValue<n::resolvent, Resolvent> resolvent;