aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-12 18:22:14 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-12 18:26:27 +0100
commitf0259663d5f279300449c3f6a916218b33cf2402 (patch)
tree8b7926a478c5e29e03df7a8df661db687f625464
parent9932da12a0310806ada93eff65a71d389415449e (diff)
downloadpaludis-f0259663d5f279300449c3f6a916218b33cf2402.tar.gz
paludis-f0259663d5f279300449c3f6a916218b33cf2402.tar.xz
New so hooks API
-rw-r--r--doc/configuration/hooks.html.part6
-rw-r--r--paludis/hook.hh5
-rw-r--r--paludis/hooker.cc14
-rw-r--r--paludis/sohooks_TEST.cc4
4 files changed, 18 insertions, 11 deletions
diff --git a/doc/configuration/hooks.html.part b/doc/configuration/hooks.html.part
index 314061a..1a78232 100644
--- a/doc/configuration/hooks.html.part
+++ b/doc/configuration/hooks.html.part
@@ -432,7 +432,8 @@ The hook takes the form of a shared library with a filename ending in <code>.so.
where <i>N</i> is the first component of the Paludis version number multiplied by 100,
plus the second component of the version number (for example, 26 for Paludis 0.26.x,
or 102 for Paludis 1.2.y). The library must export a function with prototype
-<code>paludis::HookResult paludis_hook_run(const paludis::Environment *, const paludis::Hook &amp;)</code>
+<code>paludis::HookResult paludis_hook_run_3(const paludis::Environment *,
+ const paludis::Hook &amp;, const std::shared_ptr&lt;paludis::OutputManager&gt; &amp;)</code>
that performs the action, and optionally one with prototype
<code>void paludis_hook_add_dependencies(const paludis::Environment *, const paludis::Hook &amp;,
paludis::DirectedGraph&lt;std::string, int&gt; &amp;)</code>
@@ -449,6 +450,9 @@ declared in the header <code>&lt;paludis/hook.hh&gt;</code>, including any neces
<dt><code>const paludis::Hook &amp;</code></dt>
<dd>Contains information about the hook being called. In <code>paludis_hook_add_dependencies</code>,
the only useful member is <code>name()</code>.</dd>
+<dt><code>const std::shared_ptr&lt;paludis::OutputManager&gt; &amp;</code></dt>
+<dd>The output manager being used when the hook is run. Will sometimes be a null pointer, as not all hooks are run with
+output managed -- in this case, use of stdout is normal.</dd>
<dt><code>paludis::DirectedGraph&lt;std::string, int&gt; &amp;</code></dt>
<dd>A graph containing, as nodes, all named hooks that will be executed along with
this one. The <code>paludis_hook_add_dependencies</code> function should add any
diff --git a/paludis/hook.hh b/paludis/hook.hh
index cd0865a..93abbff 100644
--- a/paludis/hook.hh
+++ b/paludis/hook.hh
@@ -29,6 +29,7 @@
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/sequence-fwd.hh>
#include <paludis/util/named_value.hh>
+#include <paludis/output_manager-fwd.hh>
#include <memory>
#include <string>
@@ -153,8 +154,8 @@ namespace paludis
extern template class WrappedForwardIterator<Hook::ConstIteratorTag, const std::pair<const std::string, std::string> >;
}
-extern "C" paludis::HookResult PALUDIS_VISIBLE paludis_hook_run(
- const paludis::Environment *, const paludis::Hook &);
+extern "C" paludis::HookResult PALUDIS_VISIBLE paludis_hook_run_3(
+ const paludis::Environment *, const paludis::Hook &, const std::shared_ptr<paludis::OutputManager> &);
extern "C" void PALUDIS_VISIBLE paludis_hook_add_dependencies(
const paludis::Environment *, const paludis::Hook &, paludis::DirectedGraph<std::string, int> &);
diff --git a/paludis/hooker.cc b/paludis/hooker.cc
index 3311a71..6eacba4 100644
--- a/paludis/hooker.cc
+++ b/paludis/hooker.cc
@@ -132,7 +132,7 @@ namespace
const Environment * const _env;
void * _dl;
- HookResult (*_run)(const Environment *, const Hook &);
+ HookResult (*_run)(const Environment *, const Hook &, const std::shared_ptr<OutputManager> &);
void (*_add_dependencies)(const Environment *, const Hook &, DirectedGraph<std::string, int> &);
const std::shared_ptr<const Sequence<std::string > > (*_auto_hook_names)(const Environment *);
@@ -406,12 +406,12 @@ SoHookFile::SoHookFile(const FSEntry & f, const bool, const Environment * const
if (_dl)
{
_run = reinterpret_cast<HookResult (*)(
- const Environment *, const Hook &)>(
- reinterpret_cast<uintptr_t>(dlsym(_dl, "paludis_hook_run")));
+ const Environment *, const Hook &, const std::shared_ptr<OutputManager> &)>(
+ reinterpret_cast<uintptr_t>(dlsym(_dl, "paludis_hook_run_3")));
if (! _run)
- Log::get_instance()->message("hook.so.no_paludis_hook_run", ll_warning, lc_no_context)
- << ".so hook '" << f << "' does not define the paludis_hook_run function";
+ Log::get_instance()->message("hook.so.no_paludis_hook_run_3", ll_warning, lc_no_context)
+ << ".so hook '" << f << "' does not define the paludis_hook_run_3 function";
_add_dependencies = reinterpret_cast<void (*)(
const Environment *, const Hook &, DirectedGraph<std::string, int> &)>(
@@ -428,7 +428,7 @@ SoHookFile::SoHookFile(const FSEntry & f, const bool, const Environment * const
HookResult
SoHookFile::run(const Hook & hook,
- const std::shared_ptr<OutputManager> &) const
+ const std::shared_ptr<OutputManager> & optional_output_manager) const
{
Context c("When running .so hook '" + stringify(file_name()) + "' for hook '" + hook.name() + "':");
@@ -438,7 +438,7 @@ SoHookFile::run(const Hook & hook,
Log::get_instance()->message("hook.so.starting", ll_debug, lc_no_context) << "Starting .so hook '" <<
file_name() << "' for '" << hook.name() << "'";
- return _run(_env, hook);
+ return _run(_env, hook, optional_output_manager);
}
void
diff --git a/paludis/sohooks_TEST.cc b/paludis/sohooks_TEST.cc
index bb97637..c6d7c85 100644
--- a/paludis/sohooks_TEST.cc
+++ b/paludis/sohooks_TEST.cc
@@ -61,8 +61,9 @@ namespace
}
}
+extern "C"
HookResult
-paludis_hook_run(const Environment * env, const Hook & hook)
+paludis_hook_run_3(const Environment * env, const Hook & hook, const std::shared_ptr<OutputManager> &)
{
if ("so_hook" == hook.name())
return so_hook_run(env, hook);
@@ -74,6 +75,7 @@ paludis_hook_run(const Environment * env, const Hook & hook)
return make_named_values<HookResult>(n::max_exit_status() = 0, n::output() = "");
}
+extern "C"
void
paludis_hook_add_dependencies(const Environment * env, const Hook & hook,
DirectedGraph<std::string, int> & graph)