aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-10-29 14:47:01 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-10-29 15:07:32 +0000
commit1a52c16f694b1c85b0dd056bbbc58f72acc1da1a (patch)
treee83fd3dc6dcbc3559f25407c053e8eb9d0b40197
parentce4df37e1592c889e7fe14b6e7a3e57b10749e89 (diff)
downloadpaludis-1a52c16f694b1c85b0dd056bbbc58f72acc1da1a.tar.gz
paludis-1a52c16f694b1c85b0dd056bbbc58f72acc1da1a.tar.xz
Add MYOPTIONS [[ description ]] support.
-rw-r--r--paludis/repositories/e/e_choice_value.cc7
-rw-r--r--paludis/repositories/e/e_choice_value.hh4
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc4
-rw-r--r--paludis/repositories/e/e_installed_repository_id.hh2
-rw-r--r--paludis/repositories/e/e_key.cc73
-rw-r--r--paludis/repositories/e/e_repository_id.hh2
-rw-r--r--paludis/repositories/e/eapi-fwd.hh1
-rw-r--r--paludis/repositories/e/eapi.cc8
-rw-r--r--paludis/repositories/e/eapi.hh8
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf2
-rw-r--r--paludis/repositories/e/ebuild_id.cc5
-rw-r--r--paludis/repositories/e/ebuild_id.hh2
12 files changed, 99 insertions, 19 deletions
diff --git a/paludis/repositories/e/e_choice_value.cc b/paludis/repositories/e/e_choice_value.cc
index 8d6c36c..3639c36 100644
--- a/paludis/repositories/e/e_choice_value.cc
+++ b/paludis/repositories/e/e_choice_value.cc
@@ -25,7 +25,7 @@ using namespace paludis::erepository;
EChoiceValue::EChoiceValue(const ChoicePrefixName & r, const UnprefixedChoiceName & v, const ChoiceNameWithPrefix & np, const QualifiedPackageName & p,
const std::tr1::shared_ptr<const UseDesc> & d,
- bool b, bool def, bool l, bool x) :
+ bool b, bool def, bool l, bool x, const std::string & o) :
_prefix(r),
_unprefixed_name(v),
_name_with_prefix(np),
@@ -34,7 +34,8 @@ EChoiceValue::EChoiceValue(const ChoicePrefixName & r, const UnprefixedChoiceNam
_enabled(b),
_enabled_by_default(def),
_locked(l),
- _explicitly_listed(x)
+ _explicitly_listed(x),
+ _override_description(o)
{
}
@@ -53,6 +54,8 @@ EChoiceValue::name_with_prefix() const
const std::string
EChoiceValue::description() const
{
+ if (! _override_description.empty())
+ return _override_description;
if (! _use_desc)
return "";
return _use_desc->describe(_package_name, _prefix, _unprefixed_name);
diff --git a/paludis/repositories/e/e_choice_value.hh b/paludis/repositories/e/e_choice_value.hh
index 05480a6..170fabe 100644
--- a/paludis/repositories/e/e_choice_value.hh
+++ b/paludis/repositories/e/e_choice_value.hh
@@ -46,6 +46,7 @@ namespace paludis
const bool _enabled_by_default;
const bool _locked;
const bool _explicitly_listed;
+ const std::string _override_description;
public:
EChoiceValue(const ChoicePrefixName & r,
@@ -54,7 +55,8 @@ namespace paludis
const QualifiedPackageName & p,
const std::tr1::shared_ptr<const UseDesc> & d,
bool b, bool def,
- bool l, bool x);
+ bool l, bool x,
+ const std::string & o);
const UnprefixedChoiceName unprefixed_name() const;
const ChoiceNameWithPrefix name_with_prefix() const;
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index d1ccb2f..58d4582 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -940,7 +940,7 @@ EInstalledRepositoryID::contained_in_key() const
std::tr1::shared_ptr<ChoiceValue>
EInstalledRepositoryID::make_choice_value(const std::tr1::shared_ptr<const Choice> & c, const UnprefixedChoiceName & v,
- const Tribool, const bool explicitly_listed) const
+ const Tribool, const bool explicitly_listed, const std::string & override_description) const
{
if (! eapi()->supported())
throw InternalError(PALUDIS_HERE, "Unsupported EAPI");
@@ -961,7 +961,7 @@ EInstalledRepositoryID::make_choice_value(const std::tr1::shared_ptr<const Choic
enabled = (raw_use_key()->value()->end() != raw_use_key()->value()->find(name_with_prefix));
return make_shared_ptr(new EChoiceValue(c->prefix(), v, ChoiceNameWithPrefix(name_with_prefix), name(), std::tr1::shared_ptr<const UseDesc>(),
- enabled, enabled, true, explicitly_listed));
+ enabled, enabled, true, explicitly_listed, override_description));
}
void
diff --git a/paludis/repositories/e/e_installed_repository_id.hh b/paludis/repositories/e/e_installed_repository_id.hh
index 8b22ea6..41b003a 100644
--- a/paludis/repositories/e/e_installed_repository_id.hh
+++ b/paludis/repositories/e/e_installed_repository_id.hh
@@ -105,7 +105,7 @@ namespace paludis
virtual std::tr1::shared_ptr<ChoiceValue> make_choice_value(
const std::tr1::shared_ptr<const Choice> &, const UnprefixedChoiceName &, const Tribool,
- const bool) const;
+ const bool, const std::string &) const;
virtual void add_build_options(const std::tr1::shared_ptr<Choices> &) const;
};
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index 40caed6..344ed1c 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -36,6 +36,7 @@
#include <paludis/util/set.hh>
#include <paludis/util/join.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/visitor_cast.hh>
#include <paludis/util/create_iterator-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/tribool.hh>
@@ -928,7 +929,8 @@ namespace
struct MyOptionsFinder :
ConstVisitor<PlainTextSpecTree>
{
- typedef std::list<std::tr1::shared_ptr<const PlainTextDepSpec> > Values;
+ typedef std::map<std::string, std::string> Annotations;
+ typedef std::map<UnprefixedChoiceName, Annotations> Values;
typedef std::map<ChoicePrefixName, Values> Prefixes;
Prefixes prefixes;
@@ -941,7 +943,40 @@ namespace
void visit_leaf(const PlainTextDepSpec & s)
{
- prefixes[*current_prefix_stack.begin()].push_back(std::tr1::static_pointer_cast<const PlainTextDepSpec>(s.clone()));
+ Context context("When handling item '" + stringify(s) + "':");
+
+ Prefixes::iterator p(prefixes.find(*current_prefix_stack.begin()));
+ if (p == prefixes.end())
+ p = prefixes.insert(std::make_pair(*current_prefix_stack.begin(), Values())).first;
+
+ UnprefixedChoiceName n(s.text());
+ Values::iterator v(p->second.find(n));
+ if (v == p->second.end())
+ v = p->second.insert(std::make_pair(n, Annotations())).first;
+
+ if (s.annotations_key())
+ {
+ for (MetadataSectionKey::MetadataConstIterator m(s.annotations_key()->begin_metadata()),
+ m_end(s.annotations_key()->end_metadata()) ;
+ m != m_end ; ++m)
+ {
+ const MetadataValueKey<std::string> * mm(visitor_cast<const MetadataValueKey<std::string> >(**m));
+ if (! mm)
+ {
+ Log::get_instance()->message("e_key.myoptions.strange_annotation", ll_warning, lc_context)
+ << "Don't know how to handle annotation '" << (*m)->raw_name() << "'";
+ continue;
+ }
+
+ Annotations::iterator a(v->second.find(mm->raw_name()));
+ if ((a != v->second.end()) && a->second != mm->value())
+ Log::get_instance()->message("e_key.myoptions.duplicate", ll_qa, lc_context)
+ << "Annotation '" << mm->raw_name() << "' set to both '" << a->second << "' and '"
+ << mm->value() << "'";
+ else
+ v->second.insert(make_pair(mm->raw_name(), mm->value()));
+ }
+ }
}
void visit_leaf(const PlainTextLabelDepSpec & s)
@@ -966,6 +1001,26 @@ namespace
current_prefix_stack.pop_front();
}
};
+
+ std::tr1::shared_ptr<ChoiceValue> make_myoption(
+ const std::tr1::shared_ptr<const ERepositoryID> & id,
+ std::tr1::shared_ptr<Choice> & choice,
+ MyOptionsFinder::Values::const_iterator & v,
+ const Tribool s,
+ const bool b)
+ {
+ std::string description;
+ for (MyOptionsFinder::Annotations::const_iterator a(v->second.begin()), a_end(v->second.end()) ;
+ a != a_end ; ++a)
+ {
+ if (a->first == id->eapi()->supported()->annotations()->myoptions_description())
+ description = a->second;
+ else
+ Log::get_instance()->message("e_key.myoptions.unknown", ll_qa, lc_context)
+ << "Unknown annotation '" << a->first << "' = '" << a->second << "'";
+ }
+ return id->make_choice_value(choice, v->first, s, b, description);
+ }
}
#include <iostream>
@@ -1024,7 +1079,7 @@ EChoicesKey::value() const
{
for (MyOptionsFinder::Values::const_iterator v(p->second.begin()), v_end(p->second.end()) ;
v != v_end ; ++v)
- exp->add(_imp->id->make_choice_value(exp, UnprefixedChoiceName((*v)->text()), indeterminate, true));
+ exp->add(make_myoption(_imp->id, exp, v, indeterminate, true));
myoptions.prefixes.erase(p);
}
}
@@ -1035,7 +1090,7 @@ EChoicesKey::value() const
Context local_local_context("When using empty prefix to populate choices:");
for (MyOptionsFinder::Values::const_iterator v(p->second.begin()), v_end(p->second.end()) ;
v != v_end ; ++v)
- use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName((*v)->text()), indeterminate, true));
+ use->add(make_myoption(_imp->id, use, v, indeterminate, true));
myoptions.prefixes.erase(p);
}
@@ -1067,7 +1122,7 @@ EChoicesKey::value() const
IsExpand(flag.first, delim)))
i_values.insert(flag);
else
- use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName(stringify(flag.first)), flag.second, true));
+ use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName(stringify(flag.first)), flag.second, true, ""));
}
/* pain in the ass: installed packages with DEPEND="x86? ( blah )" need to work,
@@ -1095,7 +1150,7 @@ EChoicesKey::value() const
/* don't need to worry */
}
else
- use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName(stringify(flag.first)), flag.second, false));
+ use->add(_imp->id->make_choice_value(use, UnprefixedChoiceName(stringify(flag.first)), flag.second, false, ""));
}
}
}
@@ -1108,7 +1163,7 @@ EChoicesKey::value() const
for (Set<UnprefixedChoiceName>::ConstIterator a(_imp->maybe_e_repository->arch_flags()->begin()), a_end(_imp->maybe_e_repository->arch_flags()->end()) ;
a != a_end ; ++a)
- arch->add(_imp->id->make_choice_value(arch, *a, indeterminate, false));
+ arch->add(_imp->id->make_choice_value(arch, *a, indeterminate, false, ""));
}
if (_imp->id->raw_use_expand_key())
@@ -1151,9 +1206,9 @@ EChoicesKey::value() const
{
std::map<ChoiceNameWithPrefix, Tribool>::const_iterator i(i_values.find(ChoiceNameWithPrefix(lower_u + delim + stringify(*v))));
if (i_values.end() != i)
- exp->add(_imp->id->make_choice_value(exp, *v, i->second, true));
+ exp->add(_imp->id->make_choice_value(exp, *v, i->second, true, ""));
else
- exp->add(_imp->id->make_choice_value(exp, *v, indeterminate, false));
+ exp->add(_imp->id->make_choice_value(exp, *v, indeterminate, false, ""));
}
}
}
diff --git a/paludis/repositories/e/e_repository_id.hh b/paludis/repositories/e/e_repository_id.hh
index 3b6b8b0..4c0e75b 100644
--- a/paludis/repositories/e/e_repository_id.hh
+++ b/paludis/repositories/e/e_repository_id.hh
@@ -47,7 +47,7 @@ namespace paludis
virtual std::tr1::shared_ptr<ChoiceValue> make_choice_value(
const std::tr1::shared_ptr<const Choice> &, const UnprefixedChoiceName &, const Tribool,
- const bool)
+ const bool, const std::string &)
const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
virtual void add_build_options(const std::tr1::shared_ptr<Choices> &) const = 0;
diff --git a/paludis/repositories/e/eapi-fwd.hh b/paludis/repositories/e/eapi-fwd.hh
index 5a48869..c4c6fe3 100644
--- a/paludis/repositories/e/eapi-fwd.hh
+++ b/paludis/repositories/e/eapi-fwd.hh
@@ -30,6 +30,7 @@ namespace paludis
{
namespace erepository
{
+ class EAPIAnnotations;
class EAPIData;
class EAPIConfigurationError;
class EAPIEbuildPhases;
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index f9e0fd7..4c66b40 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -210,6 +210,13 @@ namespace
)));
}
+ std::tr1::shared_ptr<const EAPIAnnotations> make_annotations(const KeyValueConfigFile & k)
+ {
+ return make_shared_ptr(new EAPIAnnotations(make_named_values<EAPIAnnotations>(
+ value_for<n::myoptions_description>(k.get("annotations_myoptions_description"))
+ )));
+ }
+
std::tr1::shared_ptr<const SupportedEAPI> make_supported_eapi(const KeyValueConfigFile & k)
{
ELikePackageDepSpecOptions package_dep_spec_parse_options;
@@ -253,6 +260,7 @@ namespace
}
return make_shared_ptr(new SupportedEAPI(make_named_values<SupportedEAPI>(
+ value_for<n::annotations>(make_annotations(k)),
value_for<n::breaks_portage>(destringify_key<bool>(k, "breaks_portage")),
value_for<n::can_be_pbin>(destringify_key<bool>(k, "can_be_pbin")),
value_for<n::dependency_labels>(make_shared_ptr(new const EAPILabels(check_get(k, "dependency_labels")))),
diff --git a/paludis/repositories/e/eapi.hh b/paludis/repositories/e/eapi.hh
index 8af5737..1270b99 100644
--- a/paludis/repositories/e/eapi.hh
+++ b/paludis/repositories/e/eapi.hh
@@ -38,6 +38,7 @@ namespace paludis
{
namespace n
{
+ struct annotations;
struct binary_from_env_variables;
struct bracket_merged_variables;
struct breaks_portage;
@@ -107,6 +108,7 @@ namespace paludis
struct metadata_key;
struct minimum_flat_list_size;
struct myoptions;
+ struct myoptions_description;
struct must_not_change_variables;
struct name;
struct no_slot_or_repo;
@@ -219,6 +221,7 @@ namespace paludis
struct SupportedEAPI
{
+ NamedValue<n::annotations, std::tr1::shared_ptr<const EAPIAnnotations> > annotations;
NamedValue<n::breaks_portage, bool> breaks_portage;
NamedValue<n::can_be_pbin, bool> can_be_pbin;
NamedValue<n::dependency_labels, std::tr1::shared_ptr<const EAPILabels> > dependency_labels;
@@ -358,6 +361,11 @@ namespace paludis
NamedValue<n::no_slot_or_repo, bool> no_slot_or_repo;
NamedValue<n::rewrite_virtuals, bool> rewrite_virtuals;
};
+
+ struct EAPIAnnotations
+ {
+ NamedValue<n::myoptions_description, std::string> myoptions_description;
+ };
}
#endif
}
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index 4795a98..05fb3b6 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -284,3 +284,5 @@ doman_lang_filenames = true
dosym_mkdir = false
failure_is_fatal = true
+annotations_myoptions_description = description
+
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index f939d8c..7cba9c1 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -1097,7 +1097,8 @@ EbuildID::make_choice_value(
const std::tr1::shared_ptr<const Choice> & choice,
const UnprefixedChoiceName & value_name,
const Tribool iuse_default,
- const bool explicitly_listed
+ const bool explicitly_listed,
+ const std::string & override_description
) const
{
if (! eapi()->supported())
@@ -1158,7 +1159,7 @@ EbuildID::make_choice_value(
return make_shared_ptr(new EChoiceValue(choice->prefix(), value_name, ChoiceNameWithPrefix(name_with_prefix), name(),
_imp->repository->use_desc(),
- enabled, enabled_by_default, locked, explicitly_listed));
+ enabled, enabled_by_default, locked, explicitly_listed, override_description));
}
void
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index 6f83570..47d99b0 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -144,7 +144,7 @@ namespace paludis
virtual std::tr1::shared_ptr<ChoiceValue> make_choice_value(
const std::tr1::shared_ptr<const Choice> &, const UnprefixedChoiceName &, const Tribool,
- const bool) const;
+ const bool, const std::string &) const;
virtual void add_build_options(const std::tr1::shared_ptr<Choices> &) const;
};