aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-04 09:44:53 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-04 01:09:44 +0100
commite4697102bde762497dc0f38d889df6d7fc1da466 (patch)
tree933783746f1496ef1069152d76037832341a275e
parentc85427bcaa98cc45b25f23fd8bd71906a6f90a32 (diff)
downloadpaludis-e4697102bde762497dc0f38d889df6d7fc1da466.tar.gz
paludis-e4697102bde762497dc0f38d889df6d7fc1da466.tar.xz
move suggestion handling into the client
-rw-r--r--paludis/resolver/Makefile.am11
-rw-r--r--paludis/resolver/constraint.cc1
-rw-r--r--paludis/resolver/constraint.hh3
-rw-r--r--paludis/resolver/desire_strength-fwd.hh34
-rw-r--r--paludis/resolver/desire_strength.cc29
-rw-r--r--paludis/resolver/desire_strength.hh25
-rw-r--r--paludis/resolver/desire_strength.se17
-rw-r--r--paludis/resolver/resolver.cc47
-rw-r--r--paludis/resolver/resolver.hh4
-rw-r--r--paludis/resolver/resolver_functions.hh8
-rw-r--r--src/clients/cave/cmd_resolve.cc48
11 files changed, 57 insertions, 170 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index eb1e946..33b18e7 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -1,14 +1,11 @@
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda *.loT *.epicfail
MAINTAINERCLEANFILES = Makefile.in
DISTCLEANFILES = \
- desire_strength-se.hh desire_strength-se.cc \
use_installed-se.hh use_installed-se.cc
AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
EXTRA_DIST = \
- desire_strength-se.hh desire_strength-se.cc desire_strength.se \
use_installed-se.hh use_installed-se.cc use_installed.se
BUILT_SOURCES = \
- desire_strength-se.hh desire_strength-se.cc \
use_installed-se.hh use_installed-se.cc
TESTS =
@@ -17,7 +14,6 @@ noinst_HEADERS = \
arrow.hh arrow-fwd.hh \
constraint.hh constraint-fwd.hh \
decision.hh decision-fwd.hh \
- desire_strength.hh desire_strength-fwd.hh desire_strength-se.hh \
destinations.hh destinations-fwd.hh \
qpn_s.hh qpn_s-fwd.hh \
reason.hh reason-fwd.hh \
@@ -32,7 +28,6 @@ libpaludisresolver_a_SOURCES = \
arrow.cc \
constraint.cc \
decision.cc \
- desire_strength.cc \
destinations.cc \
qpn_s.cc \
reason.cc \
@@ -67,12 +62,6 @@ distcheck-deps-subdirs :
for s in $(SUBDIRS) . ; do if test x$$s = x. ; then $(MAKE) distcheck-deps-local || exit 1 ; \
else $(MAKE) -C $$s distcheck-deps || exit 1 ; fi ; done
-desire_strength-se.hh : desire_strength.se $(top_srcdir)/misc/make_se.bash
- if ! $(top_srcdir)/misc/make_se.bash --header $(srcdir)/desire_strength.se > $@ ; then rm -f $@ ; exit 1 ; fi
-
-desire_strength-se.cc : desire_strength.se $(top_srcdir)/misc/make_se.bash
- if ! $(top_srcdir)/misc/make_se.bash --source $(srcdir)/desire_strength.se > $@ ; then rm -f $@ ; exit 1 ; fi
-
use_installed-se.hh : use_installed.se $(top_srcdir)/misc/make_se.bash
if ! $(top_srcdir)/misc/make_se.bash --header $(srcdir)/use_installed.se > $@ ; then rm -f $@ ; exit 1 ; fi
diff --git a/paludis/resolver/constraint.cc b/paludis/resolver/constraint.cc
index 6cb740c..e1150a8 100644
--- a/paludis/resolver/constraint.cc
+++ b/paludis/resolver/constraint.cc
@@ -33,7 +33,6 @@ paludis::resolver::operator<< (std::ostream & s, const Constraint & c)
{
std::stringstream ss;
ss << "Constraint(spec: " << c.spec()
- << "; desire_strength: " << stringify(c.desire_strength())
<< "; use_installed: " << stringify(c.use_installed())
<< "; reason: " << (c.reason() ? stringify(*c.reason()) : "none")
<< ")";
diff --git a/paludis/resolver/constraint.hh b/paludis/resolver/constraint.hh
index 6b3d33c..97f8b16 100644
--- a/paludis/resolver/constraint.hh
+++ b/paludis/resolver/constraint.hh
@@ -23,7 +23,6 @@
#include <paludis/resolver/constraint-fwd.hh>
#include <paludis/resolver/reason-fwd.hh>
#include <paludis/resolver/use_installed-fwd.hh>
-#include <paludis/resolver/desire_strength-fwd.hh>
#include <paludis/util/named_value.hh>
#include <paludis/dep_spec.hh>
#include <tr1/memory>
@@ -32,7 +31,6 @@ namespace paludis
{
namespace n
{
- struct desire_strength;
struct reason;
struct spec;
struct to_destination_slash;
@@ -43,7 +41,6 @@ namespace paludis
{
struct Constraint
{
- NamedValue<n::desire_strength, DesireStrength> desire_strength;
NamedValue<n::reason, std::tr1::shared_ptr<const Reason> > reason;
NamedValue<n::spec, PackageDepSpec> spec;
NamedValue<n::to_destination_slash, bool> to_destination_slash;
diff --git a/paludis/resolver/desire_strength-fwd.hh b/paludis/resolver/desire_strength-fwd.hh
deleted file mode 100644
index 6c3a515..0000000
--- a/paludis/resolver/desire_strength-fwd.hh
+++ /dev/null
@@ -1,34 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2009 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_DESIRE_STRENGTH_FWD_HH
-#define PALUDIS_GUARD_PALUDIS_RESOLVER_DESIRE_STRENGTH_FWD_HH 1
-
-#include <paludis/util/attributes.hh>
-#include <iosfwd>
-
-namespace paludis
-{
- namespace resolver
- {
-#include <paludis/resolver/desire_strength-se.hh>
- }
-}
-
-#endif
diff --git a/paludis/resolver/desire_strength.cc b/paludis/resolver/desire_strength.cc
deleted file mode 100644
index 49c0003..0000000
--- a/paludis/resolver/desire_strength.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2009 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/desire_strength.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/exception.hh>
-#include <ostream>
-
-using namespace paludis;
-using namespace paludis::resolver;
-
-#include <paludis/resolver/desire_strength-se.cc>
-
diff --git a/paludis/resolver/desire_strength.hh b/paludis/resolver/desire_strength.hh
deleted file mode 100644
index fe3b9f0..0000000
--- a/paludis/resolver/desire_strength.hh
+++ /dev/null
@@ -1,25 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2009 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_DESIRE_STRENGTH_HH
-#define PALUDIS_GUARD_PALUDIS_RESOLVER_DESIRE_STRENGTH_HH 1
-
-#include <paludis/resolver/desire_strength-fwd.hh>
-
-#endif
diff --git a/paludis/resolver/desire_strength.se b/paludis/resolver/desire_strength.se
deleted file mode 100644
index d194854..0000000
--- a/paludis/resolver/desire_strength.se
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/env bash
-# vim: set sw=4 sts=4 et ft=sh :
-
-make_enum_DesireStrength()
-{
- prefix ds
- namespace paludis::resolver
-
- # must be kept in strictness order
- key ds_none "Not desired"
- key ds_suggestion "A suggestion"
- key ds_recommendation "A recommended dependency"
- key ds_requirement "A required dependency"
- key ds_target "Was a target"
-}
-
-
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 9bab45a..d343d27 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -354,7 +354,6 @@ Resolver::_make_constraint_from_target(
const std::tr1::shared_ptr<const Reason> & reason) const
{
return make_shared_ptr(new Constraint(make_named_values<Constraint>(
- value_for<n::desire_strength>(ds_target),
value_for<n::reason>(reason),
value_for<n::spec>(spec),
value_for<n::to_destination_slash>(true),
@@ -367,7 +366,6 @@ Resolver::_make_constraint_from_dependency(const QPN_S & qpn_s, const SanitisedD
const std::tr1::shared_ptr<const Reason> & reason) const
{
return make_shared_ptr(new Constraint(make_named_values<Constraint>(
- value_for<n::desire_strength>(_desire_strength_from_sanitised_dependency(qpn_s, dep)),
value_for<n::reason>(reason),
value_for<n::spec>(dep.spec()),
value_for<n::to_destination_slash>(_dependency_to_destination_slash(qpn_s, dep)),
@@ -561,9 +559,9 @@ Resolver::_add_dependencies(const QPN_S & our_qpn_s, const std::tr1::shared_ptr<
bool
Resolver::_care_about_dependency_spec(const QPN_S & qpn_s,
- const std::tr1::shared_ptr<const Resolution> &, const SanitisedDependency & dep) const
+ const std::tr1::shared_ptr<const Resolution> & resolution, const SanitisedDependency & dep) const
{
- return _desire_strength_from_sanitised_dependency(qpn_s, dep) >= ds_recommendation;
+ return _imp->fns.care_about_dep_fn()(qpn_s, resolution, dep);
}
namespace
@@ -879,7 +877,6 @@ Resolver::_make_constraint_for_preloading(
const std::tr1::shared_ptr<PresetReason> reason(new PresetReason);
return make_shared_ptr(new Constraint(make_named_values<Constraint>(
- value_for<n::desire_strength>(ds_none),
value_for<n::reason>(reason),
value_for<n::spec>(d->package_id()->uniquely_identifying_spec()),
value_for<n::to_destination_slash>(false),
@@ -887,46 +884,6 @@ Resolver::_make_constraint_for_preloading(
)));
}
-namespace
-{
- struct DesireStrengthFinder
- {
- DesireStrength visit(const DependencyRequiredLabel &) const
- {
- return ds_requirement;
- }
-
- DesireStrength visit(const DependencySuggestedLabel &) const
- {
- return ds_suggestion;
- }
-
- DesireStrength visit(const DependencyRecommendedLabel &) const
- {
- return ds_recommendation;
- }
- };
-}
-
-DesireStrength
-Resolver::_desire_strength_from_sanitised_dependency(const QPN_S &, const SanitisedDependency & dep) const
-{
- DesireStrength result(ds_none);
-
- if (dep.active_dependency_labels()->suggest_labels()->empty())
- result = ds_requirement;
- else
- {
- DesireStrengthFinder f;
- for (DependencySuggestLabelSequence::ConstIterator l(dep.active_dependency_labels()->suggest_labels()->begin()),
- l_end(dep.active_dependency_labels()->suggest_labels()->end()) ;
- l != l_end ; ++l)
- result = std::max(result, (*l)->accept_returning<DesireStrength>(f));
- }
-
- return result;
-}
-
bool
Resolver::_dependency_to_destination_slash(const QPN_S &, const SanitisedDependency &) const
{
diff --git a/paludis/resolver/resolver.hh b/paludis/resolver/resolver.hh
index b73e3cb..219eaab 100644
--- a/paludis/resolver/resolver.hh
+++ b/paludis/resolver/resolver.hh
@@ -28,7 +28,6 @@
#include <paludis/resolver/decision-fwd.hh>
#include <paludis/resolver/reason-fwd.hh>
#include <paludis/resolver/use_installed-fwd.hh>
-#include <paludis/resolver/desire_strength-fwd.hh>
#include <paludis/resolver/destinations-fwd.hh>
#include <paludis/resolver/resolver_functions-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
@@ -139,9 +138,6 @@ namespace paludis
const QPN_S &,
const std::tr1::shared_ptr<const Decision> &) const;
- DesireStrength _desire_strength_from_sanitised_dependency(
- const QPN_S &, const SanitisedDependency &) const;
-
bool _dependency_to_destination_slash(
const QPN_S &, const SanitisedDependency &) const;
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index 45a6ecc..177349f 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -32,6 +32,7 @@ namespace paludis
{
namespace n
{
+ struct care_about_dep_fn;
struct get_initial_constraints_for_fn;
struct get_qpn_s_s_for_fn;
struct get_use_installed_fn;
@@ -39,6 +40,12 @@ namespace paludis
namespace resolver
{
+ typedef std::tr1::function<bool (
+ const QPN_S &,
+ const std::tr1::shared_ptr<const Resolution> &,
+ const SanitisedDependency &
+ )> CareAboutDepFunction;
+
typedef std::tr1::function<std::tr1::shared_ptr<Constraints> (
const QPN_S &
)> GetInitialConstraintsFunction;
@@ -56,6 +63,7 @@ namespace paludis
struct ResolverFunctions
{
+ NamedValue<n::care_about_dep_fn, CareAboutDepFunction> care_about_dep_fn;
NamedValue<n::get_initial_constraints_for_fn, GetInitialConstraintsFunction> get_initial_constraints_for_fn;
NamedValue<n::get_qpn_s_s_for_fn, GetQPNSSForFunction> get_qpn_s_s_for_fn;
NamedValue<n::get_use_installed_fn, GetUseInstalledFunction> get_use_installed_fn;
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index 573b8e6..8c35a46 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -35,6 +35,7 @@
#include <paludis/resolver/suggest_restart.hh>
#include <paludis/resolver/qpn_s.hh>
#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/sanitised_dependencies.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
#include <paludis/generator.hh>
@@ -637,7 +638,6 @@ namespace
if ((-1 != n) && installed_is_scm_older_than(env, qpn_s, n))
{
result->add(make_shared_ptr(new Constraint(make_named_values<Constraint>(
- value_for<n::desire_strength>(ds_target),
value_for<n::reason>(make_shared_ptr(new PresetReason)),
value_for<n::spec>(make_package_dep_spec(PartiallyMadePackageDepSpecOptions()).package(qpn_s.package())),
value_for<n::to_destination_slash>(false),
@@ -780,6 +780,49 @@ namespace
return result;
}
+
+ struct IsSuggestionVisitor
+ {
+ bool is_suggestion;
+
+ IsSuggestionVisitor() :
+ is_suggestion(true)
+ {
+ }
+
+ void visit(const DependencyRequiredLabel &)
+ {
+ is_suggestion = false;
+ }
+
+ void visit(const DependencyRecommendedLabel &)
+ {
+ is_suggestion = false;
+ }
+
+ void visit(const DependencySuggestedLabel &)
+ {
+ }
+ };
+
+ bool is_suggestion(const SanitisedDependency & dep)
+ {
+ if (dep.active_dependency_labels()->suggest_labels()->empty())
+ return false;
+
+ IsSuggestionVisitor v;
+ for (DependencySuggestLabelSequence::ConstIterator i(dep.active_dependency_labels()->suggest_labels()->begin()),
+ i_end(dep.active_dependency_labels()->suggest_labels()->end()) ;
+ i != i_end ; ++i)
+ (*i)->accept(v);
+ return v.is_suggestion;
+ }
+
+ bool care_about_dep_fn(const Environment * const, const ResolveCommandLine &,
+ const QPN_S &, const std::tr1::shared_ptr<const Resolution> &, const SanitisedDependency & dep)
+ {
+ return ! is_suggestion(dep);
+ }
}
@@ -845,6 +888,9 @@ ResolveCommand::run(
InitialConstraints initial_constraints;
ResolverFunctions resolver_functions(make_named_values<ResolverFunctions>(
+ value_for<n::care_about_dep_fn>(std::tr1::bind(&care_about_dep_fn,
+ env.get(), std::tr1::cref(cmdline), std::tr1::placeholders::_1,
+ std::tr1::placeholders::_2, std::tr1::placeholders::_3)),
value_for<n::get_initial_constraints_for_fn>(std::tr1::bind(&initial_constraints_for_fn,
env.get(), std::tr1::cref(cmdline), std::tr1::cref(initial_constraints), std::tr1::placeholders::_1)),
value_for<n::get_qpn_s_s_for_fn>(std::tr1::bind(&get_qpn_s_s_for_fn,