diff options
author | 2011-01-27 17:38:05 +0000 | |
---|---|---|
committer | 2011-01-27 17:38:05 +0000 | |
commit | 9784b1a69caee4cd9d9f59ab00f11b1dbf23780e (patch) | |
tree | 03bdc638261a2840bdd3696a34db5f6724fb4981 | |
parent | 000a779c9a4619b90278624a345c573acce2c23a (diff) | |
download | paludis-9784b1a69caee4cd9d9f59ab00f11b1dbf23780e.tar.gz paludis-9784b1a69caee4cd9d9f59ab00f11b1dbf23780e.tar.xz |
Add ELikeSymbolsChoiceValue
-rw-r--r-- | paludis/elike_choices-fwd.hh | 7 | ||||
-rw-r--r-- | paludis/elike_choices.cc | 131 | ||||
-rw-r--r-- | paludis/elike_choices.hh | 26 | ||||
-rw-r--r-- | paludis/elike_choices.se | 15 | ||||
-rw-r--r-- | paludis/files.m4 | 2 |
5 files changed, 178 insertions, 3 deletions
diff --git a/paludis/elike_choices-fwd.hh b/paludis/elike_choices-fwd.hh index 0ed7ef8d7..1d69eaec0 100644 --- a/paludis/elike_choices-fwd.hh +++ b/paludis/elike_choices-fwd.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2009 Ciaran McCreesh + * Copyright (c) 2008, 2009, 2011 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -23,6 +23,7 @@ #include <paludis/util/attributes.hh> #include <paludis/choice-fwd.hh> #include <string> +#include <iosfwd> namespace paludis { @@ -33,10 +34,14 @@ namespace paludis struct ELikeExpensiveTestsChoiceValue; struct ELikeJobsChoiceValue; struct ELikePreserveWorkChoiceValue; + struct ELikeSymbolsChoiceValue; const ChoicePrefixName canonical_build_options_prefix() PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result)); const std::string canonical_build_options_raw_name() PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result)); const std::string canonical_build_options_human_name() PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result)); + +#include <paludis/elike_choices-se.hh> + } #endif diff --git a/paludis/elike_choices.cc b/paludis/elike_choices.cc index d7dea5def..14e970593 100644 --- a/paludis/elike_choices.cc +++ b/paludis/elike_choices.cc @@ -26,10 +26,16 @@ #include <paludis/util/log.hh> #include <paludis/util/singleton-impl.hh> #include <paludis/util/make_null_shared_ptr.hh> +#include <paludis/util/enum_iterator.hh> +#include <paludis/util/map.hh> #include <limits> +#include <istream> +#include <ostream> using namespace paludis; +#include <paludis/elike_choices-se.cc> + namespace { struct CommonValues : @@ -37,9 +43,37 @@ namespace { const std::shared_ptr<const PermittedChoiceValueParameterIntegerValue> permitted_jobs_values; + const std::shared_ptr<Map<std::string, std::string> > permitted_symbols; + const std::shared_ptr<const PermittedChoiceValueParameterEnumValue> permitted_symbols_values; + CommonValues() : - permitted_jobs_values(new PermittedChoiceValueParameterIntegerValue(1, std::numeric_limits<int>::max())) + permitted_jobs_values(std::make_shared<PermittedChoiceValueParameterIntegerValue>(1, std::numeric_limits<int>::max())), + permitted_symbols(std::make_shared<Map<std::string, std::string> >()), + permitted_symbols_values(std::make_shared<PermittedChoiceValueParameterEnumValue>(permitted_symbols)) { + for (EnumIterator<ELikeSymbolsChoiceValueParameter> e, e_end(last_escvp) ; + e != e_end ; ++e) + { + switch (*e) + { + case escvp_split: + permitted_symbols->insert("split", "Split debug symbols"); + continue; + case escvp_preserve: + permitted_symbols->insert("preserve", "Preserve debug symbols"); + continue; + case escvp_strip: + permitted_symbols->insert("strip", "Strip debug symbols"); + continue; + case escvp_compress: + permitted_symbols->insert("compress", "Split and compress debug symbols"); + continue; + case last_escvp: + break; + } + + throw InternalError(PALUDIS_HERE, "Unhandled ELikeSymbolsChoiceValueParameter"); + } } }; } @@ -677,3 +711,98 @@ ELikePreserveWorkChoiceValue::permitted_parameter_values() const return make_null_shared_ptr(); } +namespace +{ + ELikeSymbolsChoiceValueParameter get_symbols(const std::shared_ptr<const PackageID> & id, + const std::string & env_value) + { + if (env_value.empty()) + return escvp_split; + + try + { + return destringify<ELikeSymbolsChoiceValueParameter>(env_value); + } + catch (const DestringifyError &) + { + Context context("When getting value of the symbols option for '" + stringify(*id) + "':"); + Log::get_instance()->message("elike_symbols_choice_value.invalid", ll_warning, lc_context) + << "Value '" << env_value << "' is not a legal value, using \"split\" instead"; + return escvp_split; + } + } +} + +ELikeSymbolsChoiceValue::ELikeSymbolsChoiceValue(const std::shared_ptr<const PackageID> & id, + const Environment * const env, const std::shared_ptr<const Choice> & choice) : + _enabled(env->want_choice_enabled(id, choice, canonical_unprefixed_name()).is_true()), + _param(get_symbols(id, env->value_for_choice_parameter(id, choice, canonical_unprefixed_name()))) +{ +} + +const UnprefixedChoiceName +ELikeSymbolsChoiceValue::unprefixed_name() const +{ + return canonical_unprefixed_name(); +} + +const ChoiceNameWithPrefix +ELikeSymbolsChoiceValue::name_with_prefix() const +{ + return canonical_name_with_prefix(); +} + +bool +ELikeSymbolsChoiceValue::enabled() const +{ + return _enabled; +} + +bool +ELikeSymbolsChoiceValue::enabled_by_default() const +{ + return true; +} + +bool +ELikeSymbolsChoiceValue::locked() const +{ + return false; +} + +const std::string +ELikeSymbolsChoiceValue::description() const +{ + return "How to handle debug symbols in installed files"; +} + +bool +ELikeSymbolsChoiceValue::explicitly_listed() const +{ + return true; +} + +const std::string +ELikeSymbolsChoiceValue::parameter() const +{ + return stringify(_param); +} + +const std::shared_ptr<const PermittedChoiceValueParameterValues> +ELikeSymbolsChoiceValue::permitted_parameter_values() const +{ + return CommonValues::get_instance()->permitted_symbols_values; +} + +const UnprefixedChoiceName +ELikeSymbolsChoiceValue::canonical_unprefixed_name() +{ + return UnprefixedChoiceName("symbols"); +} + +const ChoiceNameWithPrefix +ELikeSymbolsChoiceValue::canonical_name_with_prefix() +{ + return ChoiceNameWithPrefix(stringify(canonical_build_options_prefix()) + ":" + stringify(canonical_unprefixed_name())); +} + diff --git a/paludis/elike_choices.hh b/paludis/elike_choices.hh index 44030bfe1..2ed206c19 100644 --- a/paludis/elike_choices.hh +++ b/paludis/elike_choices.hh @@ -244,6 +244,32 @@ namespace paludis static const UnprefixedChoiceName canonical_unprefixed_name() PALUDIS_ATTRIBUTE((warn_unused_result)); static const ChoiceNameWithPrefix canonical_name_with_prefix() PALUDIS_ATTRIBUTE((warn_unused_result)); }; + + class PALUDIS_VISIBLE ELikeSymbolsChoiceValue : + public ChoiceValue + { + private: + const bool _enabled; + const ELikeSymbolsChoiceValueParameter _param; + + public: + ELikeSymbolsChoiceValue(const std::shared_ptr<const PackageID> &, + const Environment * const env, const std::shared_ptr<const Choice> &); + + virtual const UnprefixedChoiceName unprefixed_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual const ChoiceNameWithPrefix name_with_prefix() const PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual bool enabled() const PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual bool enabled_by_default() const PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual bool locked() const PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual const std::string description() const PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual bool explicitly_listed() const PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual const std::string parameter() const PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual const std::shared_ptr<const PermittedChoiceValueParameterValues> permitted_parameter_values() const + PALUDIS_ATTRIBUTE((warn_unused_result)); + + static const UnprefixedChoiceName canonical_unprefixed_name() PALUDIS_ATTRIBUTE((warn_unused_result)); + static const ChoiceNameWithPrefix canonical_name_with_prefix() PALUDIS_ATTRIBUTE((warn_unused_result)); + }; } #endif diff --git a/paludis/elike_choices.se b/paludis/elike_choices.se new file mode 100644 index 000000000..1aefa5c0a --- /dev/null +++ b/paludis/elike_choices.se @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# vim: set sw=4 sts=4 et ft=sh : + +make_enum_ELikeSymbolsChoiceValueParameter() +{ + prefix escvp + + key escvp_preserve "Do not modify symbols" + key escvp_strip "Strip symbols" + key escvp_split "Split symbols into debug files" + key escvp_compress "Split symbols into compressed debug files" + + want_destringify +} + diff --git a/paludis/files.m4 b/paludis/files.m4 index dd29fe5f6..d6c897c7a 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -34,7 +34,7 @@ add(`dep_spec_flattener', `hh', `cc') add(`dep_tag', `hh', `cc', `fwd') add(`distribution', `hh', `cc', `impl', `fwd') add(`elf_linkage_checker', `hh', `cc') -add(`elike_choices', `hh', `cc', `fwd') +add(`elike_choices', `hh', `cc', `fwd', `se') add(`elike_dep_parser', `hh', `cc', `fwd', `test') add(`elike_conditional_dep_spec', `hh', `cc', `fwd') add(`elike_package_dep_spec', `hh', `cc', `fwd', `se') |