]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Add genwrapper hook, that can be used to add code into the C wrapper.
authorJoey Hess <joey@gnu.kitenet.net>
Thu, 10 Sep 2009 18:04:46 +0000 (14:04 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Thu, 10 Sep 2009 18:04:46 +0000 (14:04 -0400)
IkiWiki/Plugin/skeleton.pm.example
IkiWiki/Wrapper.pm
debian/changelog
doc/plugins/write.mdwn

index 573510191c5c92507fbf0dc68615f9246f3b3437..ddf2996d64ace9c2dce9a6f9e6222f041de85e98 100644 (file)
@@ -39,6 +39,7 @@ sub import {
        hook(type => "renamepage", id => "skeleton", call => \&renamepage);
        hook(type => "rename", id => "skeleton", call => \&rename);
        hook(type => "savestate", id => "skeleton", call => \&savestate);
+       hook(type => "genwrapper", id => "skeleton", call => \&genwrapper);
 }
 
 sub getopt () {
@@ -239,4 +240,8 @@ sub savestate () {
        debug("skeleton plugin running in savestate");
 }
 
+sub genwrapper () {
+       debug("skeleton plugin running in genwrapper");
+}
+
 1
index 6555fe625f8e542e786f3b6d7d05a72772ea207f..cf85738d68163763e8ac2bb1c7fc2ab04ef69187 100644 (file)
@@ -38,11 +38,12 @@ sub gen_wrapper () {
 EOF
        }
 
-       my $test_receive="";
        if ($config{test_receive}) {
                require IkiWiki::Receive;
-               $test_receive=IkiWiki::Receive::gen_wrapper();
        }
+       
+       my @wrapper_hooks;
+       run_hooks(genwrapper => sub { push @wrapper_hooks, shift->() });
 
        my $check_commit_hook="";
        my $pre_exec="";
@@ -120,7 +121,7 @@ int main (int argc, char **argv) {
        char *s;
 
 $check_commit_hook
-$test_receive
+@wrapper_hooks
 $envsave
        newenviron[i++]="HOME=$ENV{HOME}";
        newenviron[i++]="WRAPPED_OPTIONS=$configstring";
@@ -144,7 +145,6 @@ $pre_exec
        exit(1);
 }
 EOF
-       close OUT;
 
        my $cc=exists $ENV{CC} ? possibly_foolish_untaint($ENV{CC}) : 'cc';
        if (system($cc, "$wrapper.c", "-o", "$wrapper.new") != 0) {
index 2e178171349e37fbb85f7890fb37c4eeb6dd724f..488aef8661811069ef88072d46ef28233401652a 100644 (file)
@@ -7,6 +7,7 @@ ikiwiki (3.14159265) UNRELEASED; urgency=low
   * underlay: Also allow configuring additional directories to search 
     for template files in.
   * Fix parsing web commits from ipv6 addresses.
+  * Add genwrapper hook, that can be used to add code into the C wrapper.
 
  -- Joey Hess <joeyh@debian.org>  Wed, 02 Sep 2009 15:01:27 -0400
 
index 3976f9adf5a74b504b66efa8478e4d0acc2ebd6e..668f8d8b69dff65acc0727fa5fa3233e516b132a 100644 (file)
@@ -496,6 +496,13 @@ describes the plugin as a whole. For example:
   and undef if a rebuild could be needed in some circumstances, but is not
   strictly required.
 
+### genwrapper
+
+       hook(type => "genwrapper", id => "foo", call => \&genwrapper);
+
+This hook is used to inject C code (which it returns) into the `main`
+function of the ikiwiki wrapper when it is being generated.
+
 ## Plugin interface
 
 To import the ikiwiki plugin interface: