aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Stephen P. Bennett <spb@exherbo.org> 2007-09-07 20:53:51 +0000
committerAvatar Stephen P. Bennett <spb@exherbo.org> 2007-09-07 20:53:51 +0000
commit702c036aa4155f93007f628410ea612e946e0ef4 (patch)
treebd60f3f5ae5fb55f8b8bdb9ac5b065f31a449a45
parentcbd0cba9208c2712506d35b74974ba61bbe78d1d (diff)
downloadpaludis-702c036aa4155f93007f628410ea612e946e0ef4.tar.gz
paludis-702c036aa4155f93007f628410ea612e946e0ef4.tar.xz
Initial (parser) support for dependency labels
-rw-r--r--paludis/dep_label-fwd.hh20
-rw-r--r--paludis/dep_label.cc63
-rw-r--r--paludis/dep_label.hh49
-rw-r--r--paludis/dep_list/condition_tracker.cc7
-rw-r--r--paludis/dep_list/condition_tracker.hh1
-rw-r--r--paludis/dep_list/dep_list.cc8
-rw-r--r--paludis/dep_list/query_visitor.cc5
-rw-r--r--paludis/dep_list/query_visitor.hh2
-rw-r--r--paludis/dep_list/range_rewriter.cc5
-rw-r--r--paludis/dep_list/range_rewriter.hh2
-rw-r--r--paludis/dep_list/show_suggest_visitor.cc6
-rw-r--r--paludis/dep_list/show_suggest_visitor.hh2
-rw-r--r--paludis/dep_list/uninstall_list.cc4
-rw-r--r--paludis/dep_spec-fwd.hh11
-rw-r--r--paludis/dep_spec.cc8
-rw-r--r--paludis/dep_tag.cc9
-rw-r--r--paludis/repositories/e/dep_parser.cc72
-rw-r--r--paludis/repositories/e/dep_parser.hh6
-rw-r--r--paludis/repositories/e/dep_parser_TEST.cc19
-rw-r--r--paludis/repositories/e/dep_spec_pretty_printer.cc19
-rw-r--r--paludis/repositories/e/dep_spec_pretty_printer.hh2
-rw-r--r--paludis/repositories/e/eapi.cc7
-rw-r--r--paludis/repositories/e/eapi.sr1
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf11
-rw-r--r--src/clients/adjutrix/find_reverse_deps.cc4
25 files changed, 339 insertions, 4 deletions
diff --git a/paludis/dep_label-fwd.hh b/paludis/dep_label-fwd.hh
index 2c7e58b..7a1bae2 100644
--- a/paludis/dep_label-fwd.hh
+++ b/paludis/dep_label-fwd.hh
@@ -37,6 +37,26 @@ namespace paludis
typedef ConcreteURILabel<enum URIManualOnlyLabelTag { }> URIManualOnlyLabel;
std::ostream & operator<< (std::ostream &, const URILabel &) PALUDIS_VISIBLE;
+
+ struct DependencyLabelVisitorTypes;
+ struct DependencyLabel;
+
+ template <typename T_> struct ConcreteDependencyLabel;
+ typedef ConcreteDependencyLabel<enum DependencyHostLabelTag { }> DependencyHostLabel;
+ typedef ConcreteDependencyLabel<enum DependencyTargetLabelTag { }> DependencyTargetLabel;
+ typedef ConcreteDependencyLabel<enum DependencyBuildLabelTag { }> DependencyBuildLabel;
+ typedef ConcreteDependencyLabel<enum DependencyRunLabelTag { }> DependencyRunLabel;
+ typedef ConcreteDependencyLabel<enum DependencyInstallLabelTag { }> DependencyInstallLabel;
+ typedef ConcreteDependencyLabel<enum DependencyCompileLabelTag { }> DependencyCompileLabel;
+ typedef ConcreteDependencyLabel<enum DependencySuggestedLabelTag { }> DependencySuggestedLabel;
+ typedef ConcreteDependencyLabel<enum DependencyRecommendedLabelTag { }> DependencyRecommendedLabel;
+ typedef ConcreteDependencyLabel<enum DependencyRequiredLabelTag { }> DependencyRequiredLabel;
+ typedef ConcreteDependencyLabel<enum DependencyAnyLabelTag { }> DependencyAnyLabel;
+ typedef ConcreteDependencyLabel<enum DependencyMineLabelTag { }> DependencyMineLabel;
+ typedef ConcreteDependencyLabel<enum DependencyPrimaryLabelTag { }> DependencyPrimaryLabel;
+ typedef ConcreteDependencyLabel<enum DependencyABILabelTag { }> DependencyABILabel;
+
+ std::ostream & operator<< (std::ostream &, const DependencyLabel &) PALUDIS_VISIBLE;
}
#endif
diff --git a/paludis/dep_label.cc b/paludis/dep_label.cc
index 9f23364..c4b7e18 100644
--- a/paludis/dep_label.cc
+++ b/paludis/dep_label.cc
@@ -30,6 +30,13 @@ paludis::operator<< (std::ostream & s, const URILabel & l)
return s;
}
+std::ostream &
+paludis::operator<< (std::ostream & s, const DependencyLabel & l)
+{
+ s << l.text();
+ return s;
+}
+
URILabel::~URILabel()
{
}
@@ -74,3 +81,59 @@ template class ConcreteURILabel<URIListedThenMirrorsLabel::Tag>;
template class ConcreteURILabel<URILocalMirrorsOnlyLabel::Tag>;
template class ConcreteURILabel<URIManualOnlyLabel::Tag>;
+std::ostream & operator<<(std::ostream & s, const DependencyLabel & l)
+{
+ s << l.text();
+ return s;
+}
+
+DependencyLabel::~DependencyLabel()
+{
+}
+
+namespace paludis
+{
+ template <>
+ template <typename T_>
+ struct Implementation<ConcreteDependencyLabel<T_> >
+ {
+ const std::string text;
+
+ Implementation(const std::string & t) :
+ text(t)
+ {
+ }
+ };
+}
+
+template <typename T_>
+ConcreteDependencyLabel<T_>::ConcreteDependencyLabel(const std::string & t) :
+ PrivateImplementationPattern<ConcreteDependencyLabel<T_> >(new Implementation<ConcreteDependencyLabel<T_> >(t))
+{
+}
+
+template <typename T_>
+ConcreteDependencyLabel<T_>::~ConcreteDependencyLabel()
+{
+}
+
+template <typename T_>
+const std::string
+ConcreteDependencyLabel<T_>::text() const
+{
+ return _imp->text;
+}
+
+template class ConcreteDependencyLabel<DependencyHostLabel::Tag>;
+template class ConcreteDependencyLabel<DependencyTargetLabel::Tag>;
+template class ConcreteDependencyLabel<DependencyBuildLabel::Tag>;
+template class ConcreteDependencyLabel<DependencyRunLabel::Tag>;
+template class ConcreteDependencyLabel<DependencyInstallLabel::Tag>;
+template class ConcreteDependencyLabel<DependencyCompileLabel::Tag>;
+template class ConcreteDependencyLabel<DependencySuggestedLabel::Tag>;
+template class ConcreteDependencyLabel<DependencyRecommendedLabel::Tag>;
+template class ConcreteDependencyLabel<DependencyRequiredLabel::Tag>;
+template class ConcreteDependencyLabel<DependencyAnyLabel::Tag>;
+template class ConcreteDependencyLabel<DependencyMineLabel::Tag>;
+template class ConcreteDependencyLabel<DependencyPrimaryLabel::Tag>;
+template class ConcreteDependencyLabel<DependencyABILabel::Tag>;
diff --git a/paludis/dep_label.hh b/paludis/dep_label.hh
index 22ae201..b48f766 100644
--- a/paludis/dep_label.hh
+++ b/paludis/dep_label.hh
@@ -42,6 +42,27 @@ namespace paludis
{
};
+ struct DependencyLabelVisitorTypes :
+ VisitorTypes<
+ DependencyLabelVisitorTypes,
+ DependencyLabel,
+ DependencyHostLabel,
+ DependencyTargetLabel,
+ DependencyBuildLabel,
+ DependencyRunLabel,
+ DependencyInstallLabel,
+ DependencyCompileLabel,
+ DependencySuggestedLabel,
+ DependencyRecommendedLabel,
+ DependencyRequiredLabel,
+ DependencyAnyLabel,
+ DependencyMineLabel,
+ DependencyPrimaryLabel,
+ DependencyABILabel
+ >
+ {
+ };
+
class PALUDIS_VISIBLE URILabel :
private InstantiationPolicy<URILabel, instantiation_method::NonCopyableTag>,
public virtual ConstAcceptInterface<URILabelVisitorTypes>
@@ -69,6 +90,34 @@ namespace paludis
typedef T_ Tag;
};
+
+ class PALUDIS_VISIBLE DependencyLabel :
+ private InstantiationPolicy<DependencyLabel, instantiation_method::NonCopyableTag>,
+ public virtual ConstAcceptInterface<DependencyLabelVisitorTypes>
+ {
+ public:
+ virtual ~DependencyLabel() = 0;
+
+ virtual const std::string text() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ template <typename T_>
+ class PALUDIS_VISIBLE ConcreteDependencyLabel :
+ public DependencyLabel,
+ public ConstAcceptInterfaceVisitsThis<DependencyLabelVisitorTypes, ConcreteDependencyLabel<T_> >,
+ private PrivateImplementationPattern<ConcreteDependencyLabel<T_> >
+ {
+ private:
+ using PrivateImplementationPattern<ConcreteDependencyLabel<T_> >::_imp;
+
+ public:
+ ConcreteDependencyLabel(const std::string &);
+ ~ConcreteDependencyLabel();
+
+ virtual const std::string text() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ typedef T_ Tag;
+ };
}
#endif
diff --git a/paludis/dep_list/condition_tracker.cc b/paludis/dep_list/condition_tracker.cc
index 3201aba..2a95f18 100644
--- a/paludis/dep_list/condition_tracker.cc
+++ b/paludis/dep_list/condition_tracker.cc
@@ -21,6 +21,7 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/dep_label.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -131,3 +132,9 @@ ConditionTracker::visit_leaf(const BlockDepSpec &)
throw InternalError(PALUDIS_HERE, "ConditionTracker saw a BlockDepSpec");
}
+void
+ConditionTracker::visit_leaf(const DependencyLabelDepSpec &)
+{
+ throw InternalError(PALUDIS_HERE, "ConditionTracker saw a DependencyLabelDepSpec");
+}
+
diff --git a/paludis/dep_list/condition_tracker.hh b/paludis/dep_list/condition_tracker.hh
index cb02587..58b4065 100644
--- a/paludis/dep_list/condition_tracker.hh
+++ b/paludis/dep_list/condition_tracker.hh
@@ -62,6 +62,7 @@ namespace paludis
void visit_leaf(const PackageDepSpec &) PALUDIS_ATTRIBUTE((noreturn));
void visit_leaf(const BlockDepSpec &) PALUDIS_ATTRIBUTE((noreturn));
+ void visit_leaf(const LabelsDepSpec<DependencyLabelVisitorTypes> &) PALUDIS_ATTRIBUTE((noreturn));
};
}
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index 62fb54e..e090248 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -309,6 +309,8 @@ struct DepList::AddVisitor :
void visit_leaf(const PackageDepSpec &);
void visit_leaf(const BlockDepSpec &);
+
+ void visit_leaf(const DependencyLabelDepSpec &);
};
void
@@ -875,6 +877,12 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a)
}
}
+void
+DepList::AddVisitor::visit_leaf(const DependencyLabelDepSpec &)
+{
+ // XXX implement
+}
+
DepList::DepList(const Environment * const e, const DepListOptions & o) :
PrivateImplementationPattern<DepList>(new Implementation<DepList>(e, o))
{
diff --git a/paludis/dep_list/query_visitor.cc b/paludis/dep_list/query_visitor.cc
index d352fcc..b9d0875 100644
--- a/paludis/dep_list/query_visitor.cc
+++ b/paludis/dep_list/query_visitor.cc
@@ -166,3 +166,8 @@ QueryVisitor::visit_sequence(const AllDepSpec &,
}
}
+void
+QueryVisitor::visit_leaf(const DependencyLabelDepSpec &)
+{
+ // XXX implement
+}
diff --git a/paludis/dep_list/query_visitor.hh b/paludis/dep_list/query_visitor.hh
index 5d06261..fe4332b 100644
--- a/paludis/dep_list/query_visitor.hh
+++ b/paludis/dep_list/query_visitor.hh
@@ -66,6 +66,8 @@ namespace paludis
void visit_leaf(const BlockDepSpec &);
+ void visit_leaf(const DependencyLabelDepSpec &);
+
///\}
/**
diff --git a/paludis/dep_list/range_rewriter.cc b/paludis/dep_list/range_rewriter.cc
index 03b07b2..00a4a33 100644
--- a/paludis/dep_list/range_rewriter.cc
+++ b/paludis/dep_list/range_rewriter.cc
@@ -103,3 +103,8 @@ RangeRewriter::visit_leaf(const BlockDepSpec &)
_invalid = true;
}
+void
+RangeRewriter::visit_leaf(const DependencyLabelDepSpec &)
+{
+ _invalid = true;
+}
diff --git a/paludis/dep_list/range_rewriter.hh b/paludis/dep_list/range_rewriter.hh
index 96f6352..81d1d2f 100644
--- a/paludis/dep_list/range_rewriter.hh
+++ b/paludis/dep_list/range_rewriter.hh
@@ -79,6 +79,8 @@ namespace paludis
void visit_leaf(const BlockDepSpec &);
+ void visit_leaf(const LabelsDepSpec<DependencyLabelVisitorTypes> &);
+
///\}
};
}
diff --git a/paludis/dep_list/show_suggest_visitor.cc b/paludis/dep_list/show_suggest_visitor.cc
index f86c398..d919f6c 100644
--- a/paludis/dep_list/show_suggest_visitor.cc
+++ b/paludis/dep_list/show_suggest_visitor.cc
@@ -131,3 +131,9 @@ ShowSuggestVisitor::visit_leaf(const PackageDepSpec & a)
Log::get_instance()->message(ll_warning, lc_context, "Nothing visible found for '" + stringify(a) + "'");
}
+void
+ShowSuggestVisitor::visit_leaf(const DependencyLabelDepSpec &)
+{
+ // XXX implement
+}
+
diff --git a/paludis/dep_list/show_suggest_visitor.hh b/paludis/dep_list/show_suggest_visitor.hh
index f963ea0..a1cfb67 100644
--- a/paludis/dep_list/show_suggest_visitor.hh
+++ b/paludis/dep_list/show_suggest_visitor.hh
@@ -55,6 +55,8 @@ namespace paludis
void visit_leaf(const PackageDepSpec &);
+ void visit_leaf(const DependencyLabelDepSpec &);
+
void visit_sequence(const UseDepSpec &,
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator);
diff --git a/paludis/dep_list/uninstall_list.cc b/paludis/dep_list/uninstall_list.cc
index f01163c..1cff33d 100644
--- a/paludis/dep_list/uninstall_list.cc
+++ b/paludis/dep_list/uninstall_list.cc
@@ -304,6 +304,10 @@ namespace
void visit_leaf(const BlockDepSpec &)
{
}
+
+ void visit_leaf(const DependencyLabelDepSpec &)
+ {
+ }
};
}
diff --git a/paludis/dep_spec-fwd.hh b/paludis/dep_spec-fwd.hh
index 7d19611..3824d11 100644
--- a/paludis/dep_spec-fwd.hh
+++ b/paludis/dep_spec-fwd.hh
@@ -38,6 +38,8 @@ namespace paludis
class BlockDepSpec;
class StringDepSpec;
template <typename T_> class LabelsDepSpec;
+ typedef LabelsDepSpec<URILabelVisitorTypes> URILabelDepSpec;
+ typedef LabelsDepSpec<DependencyLabelVisitorTypes> DependencyLabelDepSpec;
#include <paludis/dep_spec-se.hh>
@@ -65,6 +67,13 @@ namespace paludis
std::ostream & operator<< (std::ostream &, const LabelsDepSpec<URILabelVisitorTypes> &) PALUDIS_VISIBLE;
/**
+ * A LabelsDepSpec<DependencyLabelVisitorTypes> can be written to an ostream.
+ *
+ * \ingroup grpdepspecs
+ */
+ std::ostream & operator<< (std::ostream &, const LabelsDepSpec<DependencyLabelVisitorTypes> &) PALUDIS_VISIBLE;
+
+ /**
* A generic DepSpec heirarchy.
*
* \ingroup grpdepspecs
@@ -78,6 +87,7 @@ namespace paludis
TreeLeaf<GenericSpecTree, PackageDepSpec>,
TreeLeaf<GenericSpecTree, BlockDepSpec>,
TreeLeaf<GenericSpecTree, LabelsDepSpec<URILabelVisitorTypes> >,
+ TreeLeaf<GenericSpecTree, LabelsDepSpec<DependencyLabelVisitorTypes> >,
ConstTreeSequence<GenericSpecTree, AllDepSpec>,
ConstTreeSequence<GenericSpecTree, AnyDepSpec>,
ConstTreeSequence<GenericSpecTree, UseDepSpec>
@@ -181,6 +191,7 @@ namespace paludis
DepSpec,
TreeLeaf<DependencySpecTree, PackageDepSpec>,
TreeLeaf<DependencySpecTree, BlockDepSpec>,
+ TreeLeaf<DependencySpecTree, LabelsDepSpec<DependencyLabelVisitorTypes> >,
ConstTreeSequence<DependencySpecTree, AllDepSpec>,
ConstTreeSequence<DependencySpecTree, AnyDepSpec>,
ConstTreeSequence<DependencySpecTree, UseDepSpec>
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index d427b4c..e5960b0 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -768,6 +768,13 @@ paludis::operator<< (std::ostream & s, const LabelsDepSpec<URILabelVisitorTypes>
return s;
}
+std::ostream &
+paludis::operator<< (std::ostream & s, const LabelsDepSpec<DependencyLabelVisitorTypes> & l)
+{
+ s << join(l.begin(), l.end(), ",") << ":";
+ return s;
+}
+
PackageDepSpecError::PackageDepSpecError(const std::string & msg) throw () :
Exception(msg)
{
@@ -1091,4 +1098,5 @@ LabelsDepSpec<T_>::add_label(const tr1::shared_ptr<const typename T_::BasicNode>
}
template class LabelsDepSpec<URILabelVisitorTypes>;
+template class LabelsDepSpec<DependencyLabelVisitorTypes>;
diff --git a/paludis/dep_tag.cc b/paludis/dep_tag.cc
index 23494ca..c36434f 100644
--- a/paludis/dep_tag.cc
+++ b/paludis/dep_tag.cc
@@ -231,9 +231,16 @@ namespace
}
void
- visit_leaf(const LabelsDepSpec<URILabelVisitorTypes> &)
+ visit_leaf(const URILabelDepSpec &)
{
}
+
+ void
+ visit_leaf(const DependencyLabelDepSpec & l)
+ {
+ std::copy(l.begin(), l.end(), std::ostream_iterator<DependencyLabelVisitorTypes::BasicNode>(s, ","));
+ s << ":";
+ }
};
struct DepTagComparator :
diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc
index afed12c..34649b0 100644
--- a/paludis/repositories/e/dep_parser.cc
+++ b/paludis/repositories/e/dep_parser.cc
@@ -23,12 +23,14 @@
#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/tokeniser.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <stack>
+#include <set>
/** \file
* Implementation for dep_parser.hh things.
@@ -55,6 +57,7 @@ DepStringNestingError::DepStringNestingError(const std::string & dep_string) thr
namespace
{
struct LabelsAreURI;
+ struct LabelsAreDependency;
enum DepParserState
{
@@ -259,6 +262,20 @@ namespace
}
};
+ template <typename H_>
+ struct HandleLabel<H_, LabelsAreDependency>
+ {
+ static void add(const std::string & s, tr1::function<void (tr1::shared_ptr<ConstAcceptInterface<H_> >)> & p,
+ const EAPI & e)
+ {
+ if (e.supported && e.supported->dependency_labels)
+ p(tr1::shared_ptr<TreeLeaf<H_, DependencyLabelDepSpec> >(
+ new TreeLeaf<H_, DependencyLabelDepSpec>(parse_dependency_label(s, e))));
+ else
+ throw DepStringParseError(s, "Dependency labels not allowed in this EAPI");
+ }
+ };
+
bool disallow_any_use(const DependencySpecTreeParseMode tree_mode)
{
switch (tree_mode)
@@ -630,7 +647,7 @@ paludis::erepository::parse_depend(const std::string & s, const EAPI & e)
if (! e.supported)
throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' dependencies");
- return parse<DependencySpecTree, ParsePackageOrBlockDepSpec, true, true, void>(s,
+ return parse<DependencySpecTree, ParsePackageOrBlockDepSpec, true, true, LabelsAreDependency>(s,
disallow_any_use(e.supported->dependency_spec_tree_parse_mode),
ParsePackageOrBlockDepSpec(e.supported->package_dep_spec_parse_mode), e);
}
@@ -715,3 +732,56 @@ paludis::erepository::parse_uri_label(const std::string & s, const EAPI & e)
return l;
}
+tr1::shared_ptr<DependencyLabelDepSpec>
+paludis::erepository::parse_dependency_label(const std::string & s, const EAPI & e)
+{
+ Context context("When parsing label string '" + s + "' using EAPI '" + e.name + "':");
+
+ if (s.empty())
+ throw DepStringParseError(s, "Empty label");
+
+ std::set<std::string> labels;
+ std::string label(s.substr(0, s.length() - 1));
+ Tokeniser<delim_kind::AnyOfTag, delim_mode::DelimiterTag>(",+").tokenise(label, std::inserter(labels, labels.end()));
+
+ tr1::shared_ptr<DependencyLabelDepSpec> l(new DependencyLabelDepSpec);
+
+ for (std::set<std::string>::iterator it = labels.begin(), it_e = labels.end(); it != it_e; ++it)
+ {
+ std::string c(e.supported->dependency_labels->class_for_label(*it));
+ if (c.empty())
+ throw DepStringParseError(s, "Unknown label '" + *it + "'");
+
+ if (c == "DependencyHostLabel")
+ l->add_label(make_shared_ptr(new DependencyHostLabel(*it)));
+ else if (c == "DependencyTargetLabel")
+ l->add_label(make_shared_ptr(new DependencyTargetLabel(*it)));
+ else if (c == "DependencyBuildLabel")
+ l->add_label(make_shared_ptr(new DependencyBuildLabel(*it)));
+ else if (c == "DependencyRunLabel")
+ l->add_label(make_shared_ptr(new DependencyRunLabel(*it)));
+ else if (c == "DependencyInstallLabel")
+ l->add_label(make_shared_ptr(new DependencyInstallLabel(*it)));
+ else if (c == "DependencyCompileLabel")
+ l->add_label(make_shared_ptr(new DependencyCompileLabel(*it)));
+ else if (c == "DependencySuggestedLabel")
+ l->add_label(make_shared_ptr(new DependencySuggestedLabel(*it)));
+ else if (c == "DependencyRecommendedLabel")
+ l->add_label(make_shared_ptr(new DependencyRecommendedLabel(*it)));
+ else if (c == "DependencyRequiredLabel")
+ l->add_label(make_shared_ptr(new DependencyRequiredLabel(*it)));
+ else if (c == "DependencyAnyLabel")
+ l->add_label(make_shared_ptr(new DependencyAnyLabel(*it)));
+ else if (c == "DependencyMineLabel")
+ l->add_label(make_shared_ptr(new DependencyMineLabel(*it)));
+ else if (c == "DependencyPrimaryLabel")
+ l->add_label(make_shared_ptr(new DependencyPrimaryLabel(*it)));
+ else if (c == "DependencyABILabel")
+ l->add_label(make_shared_ptr(new DependencyABILabel(*it)));
+ else
+ throw DepStringParseError(s, "Label '" + *it + "' maps to unknown class '" + c + "'");
+ }
+
+ return l;
+}
+
diff --git a/paludis/repositories/e/dep_parser.hh b/paludis/repositories/e/dep_parser.hh
index ab1237f..05d83be 100644
--- a/paludis/repositories/e/dep_parser.hh
+++ b/paludis/repositories/e/dep_parser.hh
@@ -78,6 +78,12 @@ namespace paludis
const EAPI &) PALUDIS_VISIBLE;
/**
+ * Parse a dep spec label.
+ */
+ tr1::shared_ptr<DependencyLabelDepSpec> parse_dependency_label(const std::string & s,
+ const EAPI &) PALUDIS_VISIBLE;
+
+ /**
* Parse a provide heirarchy.
*/
tr1::shared_ptr<ProvideSpecTree::ConstItem> parse_provide(const std::string & s,
diff --git a/paludis/repositories/e/dep_parser_TEST.cc b/paludis/repositories/e/dep_parser_TEST.cc
index c489bef..89be483 100644
--- a/paludis/repositories/e/dep_parser_TEST.cc
+++ b/paludis/repositories/e/dep_parser_TEST.cc
@@ -304,5 +304,22 @@ namespace test_cases
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
}
} test_dep_spec_parser_bad_values;
-}
+ /**
+ * \test Test DepParser label handling
+ */
+ struct DepParserLabelsTest : TestCase
+ {
+ DepParserLabelsTest() : TestCase("label handling") { }
+
+ void run()
+ {
+ DepSpecPrettyPrinter d(0, false);
+ parse_depend("build: one/one",
+ *EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(d);
+ TEST_CHECK_EQUAL(stringify(d), "build: one/one");
+ TEST_CHECK_THROWS(parse_depend("build: one/one",
+ *EAPIData::get_instance()->eapi_from_string("0"))->accept(d), DepStringParseError);
+ }
+ } test_dep_spec_parser_labels;
+}
diff --git a/paludis/repositories/e/dep_spec_pretty_printer.cc b/paludis/repositories/e/dep_spec_pretty_printer.cc
index 2d86367..9c1287d 100644
--- a/paludis/repositories/e/dep_spec_pretty_printer.cc
+++ b/paludis/repositories/e/dep_spec_pretty_printer.cc
@@ -187,6 +187,25 @@ DepSpecPrettyPrinter::visit_leaf(const LabelsDepSpec<URILabelVisitorTypes> & l)
}
}
+void
+DepSpecPrettyPrinter::visit_leaf(const DependencyLabelDepSpec & l)
+{
+ if (_imp->extra_label_indent)
+ {
+ _imp->extra_label_indent = false;
+ _imp->indent -= 4;
+ }
+
+ _imp->s << indent() << stringify(l);
+ _imp->s << newline();
+
+ if (!_imp->extra_label_indent)
+ {
+ _imp->extra_label_indent = true;
+ _imp->indent += 4;
+ }
+}
+
std::string
DepSpecPrettyPrinter::newline()
{
diff --git a/paludis/repositories/e/dep_spec_pretty_printer.hh b/paludis/repositories/e/dep_spec_pretty_printer.hh
index 87f364b..b997b05 100644
--- a/paludis/repositories/e/dep_spec_pretty_printer.hh
+++ b/paludis/repositories/e/dep_spec_pretty_printer.hh
@@ -83,6 +83,8 @@ namespace paludis
void visit_leaf(const LabelsDepSpec<URILabelVisitorTypes> &);
+ void visit_leaf(const DependencyLabelDepSpec &);
+
///}
};
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index 65fb8d1..413f6db 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -167,6 +167,8 @@ namespace paludis
.uri_labels(make_shared_ptr(new EAPILabels(k.get("uri_labels"))))
+ .dependency_labels(make_shared_ptr(new EAPILabels(k.get("dependency_labels"))))
+
))))));
}
@@ -245,8 +247,11 @@ EAPILabels::~EAPILabels()
}
const std::string
-EAPILabels::class_for_label(const std::string & s) const
+EAPILabels::class_for_label(const std::string & l) const
{
+ // XXX This could (should) be cleaner.
+ std::string s(l);
+ if (s[0] == '@') s.erase(1);
std::map<std::string, std::string>::const_iterator i(_imp->v.find(s));
if (_imp->v.end() == i)
return "";
diff --git a/paludis/repositories/e/eapi.sr b/paludis/repositories/e/eapi.sr
index 32ae626..f8df460 100644
--- a/paludis/repositories/e/eapi.sr
+++ b/paludis/repositories/e/eapi.sr
@@ -162,6 +162,7 @@ make_class_SupportedEAPI()
key ebuild_metadata_variables "tr1::shared_ptr<const EAPIEbuildMetadataVariables>"
key ebuild_environment_variables "tr1::shared_ptr<const EAPIEbuildEnvironmentVariables>"
key uri_labels "tr1::shared_ptr<const EAPILabels>"
+ key dependency_labels "tr1::shared_ptr<const EAPILabels>"
doxygen_comment << "END"
/**
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index 550a213..a420e5c 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -152,3 +152,14 @@ uri_labels = \
local-only = URILocalMirrorsOnlyLabel ; \
manual = URIManualOnlyLabel
+dependency_labels = \
+ host = DependencyHostLabel ; \
+ target = DependencyTargetLabel ; \
+ build = DependencyBuildLabel ; \
+ run = DependencyRunLabel ; \
+ install = DependencyInstallLabel ; \
+ compile-against = DependencyCompileLabel ; \
+ suggested = DependencySuggestedLabel ; \
+ recommended = DependencyRecommendedLabel ; \
+ required = DependencyRequiredLabel ; \
+ @ = DependencyABILabel
diff --git a/src/clients/adjutrix/find_reverse_deps.cc b/src/clients/adjutrix/find_reverse_deps.cc
index 76ff391..c4d8dcf 100644
--- a/src/clients/adjutrix/find_reverse_deps.cc
+++ b/src/clients/adjutrix/find_reverse_deps.cc
@@ -103,6 +103,10 @@ namespace
void visit_leaf(const BlockDepSpec &)
{
}
+
+ void visit_leaf(const DependencyLabelDepSpec &)
+ {
+ }
};
void