aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-02 14:28:44 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-02 14:28:44 +0000
commit3a6e488ea25a2d71324f156c34eb6ec67040d139 (patch)
tree6cd6849ba19bc346288dd8cb6372405f0ff2882a
parent74881fdb43f351dd2967b9dd38cc3db6eef0c2a5 (diff)
downloadpaludis-3a6e488ea25a2d71324f156c34eb6ec67040d139.tar.gz
paludis-3a6e488ea25a2d71324f156c34eb6ec67040d139.tar.xz
Track labels classifications for deps
-rw-r--r--paludis/resolver/labels_classifier.cc45
-rw-r--r--paludis/resolver/labels_classifier.hh7
-rw-r--r--paludis/resolver/sanitised_dependencies.cc7
-rw-r--r--paludis/resolver/sanitised_dependencies.hh3
4 files changed, 62 insertions, 0 deletions
diff --git a/paludis/resolver/labels_classifier.cc b/paludis/resolver/labels_classifier.cc
index 0b67106..f6dd4ce 100644
--- a/paludis/resolver/labels_classifier.cc
+++ b/paludis/resolver/labels_classifier.cc
@@ -23,6 +23,7 @@
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/stringify.hh>
#include <paludis/dep_label.hh>
+#include <paludis/serialise-impl.hh>
#include <algorithm>
using namespace paludis;
@@ -34,6 +35,7 @@ LabelsClassifier::LabelsClassifier() :
includes_compile_against(false),
includes_fetch(false),
includes_non_post_runish(false),
+ includes_non_test_buildish(false),
includes_post(false),
includes_postish(false),
is_recommendation(false),
@@ -49,6 +51,7 @@ LabelsClassifier::visit(const DependenciesBuildLabel & l)
{
is_requirement = true;
includes_buildish = true;
+ includes_non_test_buildish = true;
any_enabled = true;
}
}
@@ -71,6 +74,7 @@ LabelsClassifier::visit(const DependenciesFetchLabel & l)
{
is_requirement = true;
includes_buildish = true;
+ includes_non_test_buildish = true;
includes_fetch = true;
any_enabled = true;
}
@@ -105,6 +109,7 @@ LabelsClassifier::visit(const DependenciesInstallLabel & l)
{
is_requirement = true;
includes_buildish = true;
+ includes_non_test_buildish = true;
any_enabled = true;
}
}
@@ -117,6 +122,7 @@ LabelsClassifier::visit(const DependenciesCompileAgainstLabel & l)
is_requirement = true;
includes_non_post_runish = true;
includes_buildish = true;
+ includes_non_test_buildish = true;
any_enabled = true;
}
}
@@ -143,6 +149,45 @@ LabelsClassifier::visit(const DependenciesSuggestionLabel & l)
}
}
+void
+LabelsClassifier::serialise(Serialiser & s) const
+{
+ s.object("LabelsClassifier")
+ .member(SerialiserFlags<>(), "any_enabled", any_enabled)
+ .member(SerialiserFlags<>(), "includes_buildish", includes_buildish)
+ .member(SerialiserFlags<>(), "includes_compile_against", includes_compile_against)
+ .member(SerialiserFlags<>(), "includes_fetch", includes_fetch)
+ .member(SerialiserFlags<>(), "includes_non_post_runish", includes_non_post_runish)
+ .member(SerialiserFlags<>(), "includes_non_test_buildish", includes_non_test_buildish)
+ .member(SerialiserFlags<>(), "includes_post", includes_post)
+ .member(SerialiserFlags<>(), "includes_postish", includes_postish)
+ .member(SerialiserFlags<>(), "is_recommendation", is_recommendation)
+ .member(SerialiserFlags<>(), "is_requirement", is_requirement)
+ .member(SerialiserFlags<>(), "is_suggestion", is_suggestion)
+ ;
+}
+
+const std::shared_ptr<LabelsClassifier>
+LabelsClassifier::deserialise(
+ Deserialisation & d)
+{
+ Deserialisator v(d, "LabelsClassifier");
+ auto result(std::make_shared<LabelsClassifier>());
+ result->any_enabled = v.member<bool>("any_enabled");
+ result->includes_buildish = v.member<bool>("includes_buildish");
+ result->includes_compile_against = v.member<bool>("includes_compile_against");
+ result->includes_fetch = v.member<bool>("includes_fetch");
+ result->includes_non_post_runish = v.member<bool>("includes_non_post_runish");
+ result->includes_non_test_buildish = v.member<bool>("includes_non_test_buildish");
+ result->includes_post = v.member<bool>("includes_post");
+ result->includes_postish = v.member<bool>("includes_postish");
+ result->is_recommendation = v.member<bool>("is_recommendation");
+ result->is_requirement = v.member<bool>("is_requirement");
+ result->is_suggestion = v.member<bool>("is_suggestion");
+
+ return result;
+}
+
bool
paludis::resolver::is_suggestion(const SanitisedDependency & dep)
{
diff --git a/paludis/resolver/labels_classifier.hh b/paludis/resolver/labels_classifier.hh
index 6bea330..fd2d990 100644
--- a/paludis/resolver/labels_classifier.hh
+++ b/paludis/resolver/labels_classifier.hh
@@ -22,6 +22,7 @@
#include <paludis/resolver/labels_classifier-fwd.hh>
#include <paludis/dep_label-fwd.hh>
+#include <paludis/serialise-fwd.hh>
namespace paludis
{
@@ -37,6 +38,7 @@ namespace paludis
bool includes_compile_against;
bool includes_fetch;
bool includes_non_post_runish;
+ bool includes_non_test_buildish;
bool includes_post;
bool includes_postish;
@@ -53,6 +55,11 @@ namespace paludis
void visit(const DependenciesRunLabel &);
void visit(const DependenciesSuggestionLabel &);
void visit(const DependenciesTestLabel &);
+
+ void serialise(Serialiser &) const;
+
+ static const std::shared_ptr<LabelsClassifier> deserialise(
+ Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
}
diff --git a/paludis/resolver/sanitised_dependencies.cc b/paludis/resolver/sanitised_dependencies.cc
index 877b969..5076220 100644
--- a/paludis/resolver/sanitised_dependencies.cc
+++ b/paludis/resolver/sanitised_dependencies.cc
@@ -353,14 +353,19 @@ namespace
SanitisedDependency make_sanitised(const PackageOrBlockDepSpec & spec)
{
std::stringstream adl;
+ auto classifier(std::make_shared<LabelsClassifier>());
for (DependenciesLabelSequence::ConstIterator i((*labels_stack.begin())->begin()),
i_end((*labels_stack.begin())->end()) ;
i != i_end ; ++i)
+ {
adl << (adl.str().empty() ? "" : ", ") << stringify(**i);
+ (*i)->accept(*classifier);
+ }
return make_named_values<SanitisedDependency>(
n::active_dependency_labels() = *labels_stack.begin(),
n::active_dependency_labels_as_string() = adl.str(),
+ n::active_dependency_labels_classifier() = classifier,
n::metadata_key_human_name() = human_name,
n::metadata_key_raw_name() = raw_name,
n::original_specs_as_string() = original_specs_as_string,
@@ -521,6 +526,7 @@ SanitisedDependency::serialise(Serialiser & s) const
{
s.object("SanitisedDependency")
.member(SerialiserFlags<>(), "active_dependency_labels_as_string", active_dependency_labels_as_string())
+ .member(SerialiserFlags<serialise::might_be_null>(), "active_dependency_labels_classifier", active_dependency_labels_classifier())
.member(SerialiserFlags<>(), "metadata_key_human_name", metadata_key_human_name())
.member(SerialiserFlags<>(), "metadata_key_raw_name", metadata_key_raw_name())
.member(SerialiserFlags<>(), "original_specs_as_string", original_specs_as_string())
@@ -538,6 +544,7 @@ SanitisedDependency::deserialise(Deserialisation & d, const std::shared_ptr<cons
return make_named_values<SanitisedDependency>(
n::active_dependency_labels() = make_null_shared_ptr(),
n::active_dependency_labels_as_string() = v.member<std::string>("active_dependency_labels_as_string"),
+ n::active_dependency_labels_classifier() = v.member<std::shared_ptr<LabelsClassifier> >("active_dependency_labels_classifier"),
n::metadata_key_human_name() = v.member<std::string>("metadata_key_human_name"),
n::metadata_key_raw_name() = v.member<std::string>("metadata_key_raw_name"),
n::original_specs_as_string() = v.member<std::string>("original_specs_as_string"),
diff --git a/paludis/resolver/sanitised_dependencies.hh b/paludis/resolver/sanitised_dependencies.hh
index a81ae62..6d77b54 100644
--- a/paludis/resolver/sanitised_dependencies.hh
+++ b/paludis/resolver/sanitised_dependencies.hh
@@ -24,6 +24,7 @@
#include <paludis/resolver/decider-fwd.hh>
#include <paludis/resolver/resolution-fwd.hh>
#include <paludis/resolver/package_or_block_dep_spec.hh>
+#include <paludis/resolver/labels_classifier.hh>
#include <paludis/util/named_value.hh>
#include <paludis/dep_label-fwd.hh>
#include <paludis/dep_spec.hh>
@@ -37,6 +38,7 @@ namespace paludis
{
typedef Name<struct active_dependency_labels_name> active_dependency_labels;
typedef Name<struct active_dependency_labels_as_string_name> active_dependency_labels_as_string;
+ typedef Name<struct active_dependency_labels_classifier_name> active_dependency_labels_classifier;
typedef Name<struct metadata_key_human_name_name> metadata_key_human_name;
typedef Name<struct metadata_key_raw_name_name> metadata_key_raw_name;
typedef Name<struct original_specs_as_string_name> original_specs_as_string;
@@ -49,6 +51,7 @@ namespace paludis
{
NamedValue<n::active_dependency_labels, std::shared_ptr<const DependenciesLabelSequence> > active_dependency_labels;
NamedValue<n::active_dependency_labels_as_string, std::string> active_dependency_labels_as_string;
+ NamedValue<n::active_dependency_labels_classifier, std::shared_ptr<const LabelsClassifier> > active_dependency_labels_classifier;
NamedValue<n::metadata_key_human_name, std::string> metadata_key_human_name;
NamedValue<n::metadata_key_raw_name, std::string> metadata_key_raw_name;
NamedValue<n::original_specs_as_string, std::string> original_specs_as_string;