diff options
author | 2010-08-07 16:39:47 +0100 | |
---|---|---|
committer | 2010-08-08 10:53:07 +0100 | |
commit | 490687fe881a3d2f9ba194a5675d522adff20e96 (patch) | |
tree | 0ad8a0ae1fa4d974c36965388da8286d73cf3f50 | |
parent | 2071e4f42961487f4a7e1c565790bc2647f344bf (diff) | |
download | paludis-490687fe881a3d2f9ba194a5675d522adff20e96.tar.gz paludis-490687fe881a3d2f9ba194a5675d522adff20e96.tar.xz |
MakeOriginFilteredGeneratorHelper
-rw-r--r-- | paludis/resolver/Makefile.am | 4 | ||||
-rw-r--r-- | paludis/resolver/always_via_binary_helper.cc | 11 | ||||
-rw-r--r-- | paludis/resolver/destination_utils-fwd.hh | 34 | ||||
-rw-r--r-- | paludis/resolver/destination_utils.cc | 34 | ||||
-rw-r--r-- | paludis/resolver/destination_utils.hh | 30 | ||||
-rw-r--r-- | paludis/resolver/make_origin_filtered_generator_helper-fwd.hh | 31 | ||||
-rw-r--r-- | paludis/resolver/make_origin_filtered_generator_helper.cc | 110 | ||||
-rw-r--r-- | paludis/resolver/make_origin_filtered_generator_helper.hh | 55 | ||||
-rw-r--r-- | paludis/resolver/resolver_test.cc | 10 | ||||
-rw-r--r-- | paludis/resolver/resolver_test.hh | 5 | ||||
-rw-r--r-- | src/clients/cave/resolve_common.cc | 51 |
11 files changed, 308 insertions, 67 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am index 770e19242..42336105e 100644 --- a/paludis/resolver/Makefile.am +++ b/paludis/resolver/Makefile.am @@ -43,6 +43,7 @@ noinst_HEADERS = \ decisions.hh decisions-fwd.hh \ destination.hh destination-fwd.hh \ destination_types.hh destination_types-fwd.hh destination_types-se.hh \ + destination_utils.hh destination_utils-fwd.hh \ find_repository_for_helper.hh find_repository_for_helper-fwd.hh \ get_constraints_for_dependent_helper.hh get_constraints_for_dependent_helper-fwd.hh \ get_constraints_for_purge_helper.hh get_constraints_for_dependent_helper-fwd.hh \ @@ -54,6 +55,7 @@ noinst_HEADERS = \ job_requirements.hh job_requirements-fwd.hh \ job_state.hh job_state-fwd.hh \ labels_classifier.hh labels_classifier-fwd.hh \ + make_origin_filtered_generator_helper.hh make_origin_filtered_generator_helper-fwd.hh \ make_unmaskable_filter_helper.hh make_unmaskable_filter_helper-fwd.hh \ nag.hh nag-fwd.hh \ order_early_helper.hh order_early_helper-fwd.hh \ @@ -94,6 +96,7 @@ libpaludisresolver_a_SOURCES = \ decisions.cc \ destination.cc \ destination_types.cc \ + destination_utils.cc \ find_repository_for_helper.cc \ get_constraints_for_dependent_helper.cc \ get_constraints_for_purge_helper.cc \ @@ -105,6 +108,7 @@ libpaludisresolver_a_SOURCES = \ job_requirements.cc \ job_state.cc \ labels_classifier.cc \ + make_origin_filtered_generator_helper.cc \ make_unmaskable_filter_helper.cc \ nag.cc \ order_early_helper.cc \ diff --git a/paludis/resolver/always_via_binary_helper.cc b/paludis/resolver/always_via_binary_helper.cc index f353142d0..147b58c93 100644 --- a/paludis/resolver/always_via_binary_helper.cc +++ b/paludis/resolver/always_via_binary_helper.cc @@ -23,6 +23,7 @@ #include <paludis/resolver/resolvent.hh> #include <paludis/resolver/resolution.hh> #include <paludis/resolver/decision.hh> +#include <paludis/resolver/destination_utils.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/simple_visitor_cast.hh> #include <paludis/dep_spec.hh> @@ -61,16 +62,6 @@ AlwaysViaBinaryHelper::add_always_via_binary_spec(const PackageDepSpec & spec) _imp->always_via_binary_specs.insert(spec); } -namespace -{ - bool can_make_binary_for(const std::shared_ptr<const PackageID> & id) - { - if (! id->behaviours_key()) - return true; - return id->behaviours_key()->value()->end() == id->behaviours_key()->value()->find("unbinaryable"); - } -} - bool AlwaysViaBinaryHelper::operator() (const std::shared_ptr<const Resolution> & resolution) const { diff --git a/paludis/resolver/destination_utils-fwd.hh b/paludis/resolver/destination_utils-fwd.hh new file mode 100644 index 000000000..459d80f5e --- /dev/null +++ b/paludis/resolver/destination_utils-fwd.hh @@ -0,0 +1,34 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2010 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 + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_DESTINATION_UTILS_FWD_HH +#define PALUDIS_GUARD_PALUDIS_RESOLVER_DESTINATION_UTILS_FWD_HH 1 + +#include <paludis/util/attributes.hh> +#include <paludis/package_id-fwd.hh> + +namespace paludis +{ + namespace resolver + { + bool can_make_binary_for(const std::shared_ptr<const PackageID> & id) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE; + } +} + +#endif diff --git a/paludis/resolver/destination_utils.cc b/paludis/resolver/destination_utils.cc new file mode 100644 index 000000000..506706213 --- /dev/null +++ b/paludis/resolver/destination_utils.cc @@ -0,0 +1,34 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2010 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 + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <paludis/resolver/destination_utils.hh> +#include <paludis/package_id.hh> +#include <paludis/metadata_key.hh> + +using namespace paludis; +using namespace paludis::resolver; + +bool +paludis::resolver::can_make_binary_for(const std::shared_ptr<const PackageID> & id) +{ + if (! id->behaviours_key()) + return true; + return id->behaviours_key()->value()->end() == id->behaviours_key()->value()->find("unbinaryable"); +} + diff --git a/paludis/resolver/destination_utils.hh b/paludis/resolver/destination_utils.hh new file mode 100644 index 000000000..65ba01080 --- /dev/null +++ b/paludis/resolver/destination_utils.hh @@ -0,0 +1,30 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2010 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 + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_DESTINATION_UTILS_HH +#define PALUDIS_GUARD_PALUDIS_RESOLVER_DESTINATION_UTILS_HH 1 + +#include <paludis/resolver/destination_utils-fwd.hh> + +namespace paludis +{ + +} + +#endif diff --git a/paludis/resolver/make_origin_filtered_generator_helper-fwd.hh b/paludis/resolver/make_origin_filtered_generator_helper-fwd.hh new file mode 100644 index 000000000..c073ec5ed --- /dev/null +++ b/paludis/resolver/make_origin_filtered_generator_helper-fwd.hh @@ -0,0 +1,31 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2010 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 + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_MAKE_ORIGIN_FILTERED_GENERATOR_HELPER_FWD_HH +#define PALUDIS_GUARD_PALUDIS_RESOLVER_MAKE_ORIGIN_FILTERED_GENERATOR_HELPER_FWD_HH 1 + +namespace paludis +{ + namespace resolver + { + struct MakeOriginFilteredGeneratorHelper; + } +} + +#endif diff --git a/paludis/resolver/make_origin_filtered_generator_helper.cc b/paludis/resolver/make_origin_filtered_generator_helper.cc new file mode 100644 index 000000000..1e18ed6d9 --- /dev/null +++ b/paludis/resolver/make_origin_filtered_generator_helper.cc @@ -0,0 +1,110 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2010 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 + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <paludis/resolver/make_origin_filtered_generator_helper.hh> +#include <paludis/resolver/destination_utils.hh> +#include <paludis/util/pimp-impl.hh> +#include <paludis/util/set.hh> +#include <paludis/filter.hh> +#include <paludis/filter_handler.hh> +#include <paludis/generator.hh> +#include <paludis/filtered_generator.hh> +#include <paludis/package_id.hh> +#include <paludis/metadata_key.hh> + +using namespace paludis; +using namespace paludis::resolver; + +namespace paludis +{ + template <> + struct Imp<MakeOriginFilteredGeneratorHelper> + { + const Environment * const env; + bool making_binaries; + + Imp(const Environment * const e) : + env(e), + making_binaries(false) + { + } + }; +} + +MakeOriginFilteredGeneratorHelper::MakeOriginFilteredGeneratorHelper(const Environment * const e) : + Pimp<MakeOriginFilteredGeneratorHelper>(e) +{ +} + +MakeOriginFilteredGeneratorHelper::~MakeOriginFilteredGeneratorHelper() = default; + +void +MakeOriginFilteredGeneratorHelper::set_making_binaries(const bool v) +{ + _imp->making_binaries = v; +} + +namespace +{ + struct BinaryableFilterHandler : + AllFilterHandlerBase + { + virtual std::shared_ptr<const PackageIDSet> ids( + const Environment * const, + const std::shared_ptr<const PackageIDSet> & id) const + { + std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>()); + + for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ; + i != i_end ; ++i) + if (can_make_binary_for(*i)) + result->insert(*i); + + return result; + } + + virtual std::string as_string() const + { + return "binaryable"; + } + }; + + struct BinaryableFilter : + Filter + { + BinaryableFilter() : + Filter(std::make_shared<BinaryableFilterHandler>()) + { + } + }; +} + +FilteredGenerator +MakeOriginFilteredGeneratorHelper::operator() ( + const Generator & g, + const std::shared_ptr<const Resolution> &) const +{ + if (_imp->making_binaries) + return g | BinaryableFilter(); + else + return g; +} + +template class Pimp<MakeOriginFilteredGeneratorHelper>; + diff --git a/paludis/resolver/make_origin_filtered_generator_helper.hh b/paludis/resolver/make_origin_filtered_generator_helper.hh new file mode 100644 index 000000000..2a124ee1c --- /dev/null +++ b/paludis/resolver/make_origin_filtered_generator_helper.hh @@ -0,0 +1,55 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2010 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 + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_MAKE_ORIGIN_FILTERED_GENERATOR_HELPER_HH +#define PALUDIS_GUARD_PALUDIS_RESOLVER_MAKE_ORIGIN_FILTERED_GENERATOR_HELPER_HH 1 + +#include <paludis/resolver/make_origin_filtered_generator_helper-fwd.hh> +#include <paludis/resolver/resolution-fwd.hh> +#include <paludis/util/pimp.hh> +#include <paludis/util/attributes.hh> +#include <paludis/environment-fwd.hh> +#include <paludis/filter-fwd.hh> +#include <paludis/generator-fwd.hh> +#include <paludis/filtered_generator-fwd.hh> +#include <memory> + +namespace paludis +{ + namespace resolver + { + class PALUDIS_VISIBLE MakeOriginFilteredGeneratorHelper : + private Pimp<MakeOriginFilteredGeneratorHelper> + { + public: + explicit MakeOriginFilteredGeneratorHelper(const Environment * const); + ~MakeOriginFilteredGeneratorHelper(); + + void set_making_binaries(const bool); + + FilteredGenerator operator() ( + const Generator &, + const std::shared_ptr<const Resolution> &) const; + }; + } + + extern template class Pimp<resolver::MakeOriginFilteredGeneratorHelper>; +} + +#endif diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc index 498e1cc96..76e4b9f53 100644 --- a/paludis/resolver/resolver_test.cc +++ b/paludis/resolver/resolver_test.cc @@ -130,13 +130,6 @@ paludis::resolver::resolver_test::make_destination_filtered_generator_fn(const G throw InternalError(PALUDIS_HERE, "unhandled dt"); } -FilteredGenerator -paludis::resolver::resolver_test::make_origin_filtered_generator_fn(const Generator & g, - const std::shared_ptr<const Resolution> &) -{ - return g; -} - namespace { #ifdef ENABLE_VIRTUALS_REPOSITORY @@ -194,6 +187,7 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s, get_constraints_for_purge_helper(&env), get_constraints_for_via_binary_helper(&env), get_destination_types_for_error_helper(&env), + make_origin_filtered_generator_helper(&env), make_unmaskable_filter_helper(&env), order_early_helper(&env), prefer_or_avoid_helper(&env), @@ -263,7 +257,7 @@ ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraint n::get_use_existing_nothing_fn() = &get_use_existing_nothing_fn, n::interest_in_spec_fn() = &interest_in_spec_fn, n::make_destination_filtered_generator_fn() = &make_destination_filtered_generator_fn, - n::make_origin_filtered_generator_fn() = &make_origin_filtered_generator_fn, + n::make_origin_filtered_generator_fn() = std::cref(make_origin_filtered_generator_helper), n::make_unmaskable_filter_fn() = std::cref(make_unmaskable_filter_helper), n::order_early_fn() = std::cref(order_early_helper), n::prefer_or_avoid_fn() = std::cref(prefer_or_avoid_helper), diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh index f78062069..f84203647 100644 --- a/paludis/resolver/resolver_test.hh +++ b/paludis/resolver/resolver_test.hh @@ -45,6 +45,7 @@ #include <paludis/resolver/get_constraints_for_purge_helper.hh> #include <paludis/resolver/get_constraints_for_via_binary_helper.hh> #include <paludis/resolver/get_destination_types_for_error_helper.hh> +#include <paludis/resolver/make_origin_filtered_generator_helper.hh> #include <paludis/resolver/make_unmaskable_filter_helper.hh> #include <paludis/resolver/order_early_helper.hh> #include <paludis/resolver/remove_if_dependent_helper.hh> @@ -101,9 +102,6 @@ namespace paludis FilteredGenerator make_destination_filtered_generator_fn(const Generator &, const std::shared_ptr<const Resolution> &); - FilteredGenerator make_origin_filtered_generator_fn(const Generator &, - const std::shared_ptr<const Resolution> &); - struct ResolverTestCase : test::TestCase { TestEnvironment env; @@ -120,6 +118,7 @@ namespace paludis GetConstraintsForPurgeHelper get_constraints_for_purge_helper; GetConstraintsForViaBinaryHelper get_constraints_for_via_binary_helper; GetDestinationTypesForErrorHelper get_destination_types_for_error_helper; + MakeOriginFilteredGeneratorHelper make_origin_filtered_generator_helper; MakeUnmaskableFilterHelper make_unmaskable_filter_helper; OrderEarlyHelper order_early_helper; PreferOrAvoidHelper prefer_or_avoid_helper; diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc index dc9d2cb8f..6fb3d04d1 100644 --- a/src/clients/cave/resolve_common.cc +++ b/src/clients/cave/resolve_common.cc @@ -74,6 +74,7 @@ #include <paludis/resolver/get_constraints_for_purge_helper.hh> #include <paludis/resolver/get_constraints_for_via_binary_helper.hh> #include <paludis/resolver/get_destination_types_for_error_helper.hh> +#include <paludis/resolver/make_origin_filtered_generator_helper.hh> #include <paludis/resolver/make_unmaskable_filter_helper.hh> #include <paludis/resolver/order_early_helper.hh> #include <paludis/resolver/remove_if_dependent_helper.hh> @@ -133,38 +134,6 @@ namespace return id->behaviours_key()->value()->end() == id->behaviours_key()->value()->find("unchrootable"); } - struct BinaryableFilterHandler : - AllFilterHandlerBase - { - virtual std::shared_ptr<const PackageIDSet> ids( - const Environment * const, - const std::shared_ptr<const PackageIDSet> & id) const - { - std::shared_ptr<PackageIDSet> result(std::make_shared<PackageIDSet>()); - - for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ; - i != i_end ; ++i) - if (can_make_binary_for(*i)) - result->insert(*i); - - return result; - } - - virtual std::string as_string() const - { - return "binaryable"; - } - }; - - struct BinaryableFilter : - Filter - { - BinaryableFilter() : - Filter(std::make_shared<BinaryableFilterHandler>()) - { - } - }; - struct DestinationTypesFinder { const Environment * const env; @@ -314,18 +283,6 @@ namespace return make_destination_filtered_generator(env, resolution_options, binary_destinations, g, r->resolvent()); } - FilteredGenerator make_origin_filtered_generator( - const Environment * const, - const ResolveCommandLineResolutionOptions & resolution_options, - const Generator & g, - const std::shared_ptr<const Resolution> &) - { - if (resolution_options.a_make.argument() == "binaries") - return g | BinaryableFilter(); - else - return g; - } - const std::shared_ptr<const Sequence<std::string> > add_resolver_targets( const std::shared_ptr<Environment> & env, const std::shared_ptr<Resolver> & resolver, @@ -1551,6 +1508,9 @@ paludis::cave::resolve_common( throw args::DoHelp("Don't understand argument '" + resolution_options.a_make.argument() + "' to '--" + resolution_options.a_make.long_name() + "'"); + MakeOriginFilteredGeneratorHelper make_origin_filtered_generator_helper(env.get()); + make_origin_filtered_generator_helper.set_making_binaries("binaries" == resolution_options.a_make.argument()); + MakeUnmaskableFilterHelper make_unmaskable_filter_helper(env.get()); make_unmaskable_filter_helper.set_override_masks(! resolution_options.a_no_override_masks.specified()); @@ -1605,8 +1565,7 @@ paludis::cave::resolve_common( std::cref(no_dependencies_from), _1, _2), n::make_destination_filtered_generator_fn() = std::bind(&make_destination_filtered_generator_with_resolution, env.get(), std::cref(resolution_options), binary_destinations, _1, _2), - n::make_origin_filtered_generator_fn() = std::bind(&make_origin_filtered_generator, - env.get(), std::cref(resolution_options), _1, _2), + n::make_origin_filtered_generator_fn() = std::cref(make_origin_filtered_generator_helper), n::make_unmaskable_filter_fn() = std::cref(make_unmaskable_filter_helper), n::order_early_fn() = std::cref(order_early_helper), n::prefer_or_avoid_fn() = std::cref(prefer_or_avoid_helper), |