Tue May 20 18:43:06 2014: Request 95809 was acted upon. Transaction: Ticket created by s...@parasite.cc Queue: Inline Subject: [PATCH] Using Inline in a distribution with multiple modules Broken in: (no value) Severity: (no value) Owner: Nobody Requestors: s...@parasite.cc Status: new Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=95809 >
I'm working on a distribution which has multiple modules using Inline. Something like the following Foo Foo::Bar - uses Inline Foo::Bar::Baz - uses Inline I couldn't figure out how to make Inline::MakeMaker work in this scenario, so I've patched it to do what I think is correct. The only problem I have now is that it fails if I do a make -j n where n > 1, but I think that's a different problem so I thought I'd submit this patch first. With this patch Inline::MakeMaker will work as it does now (with a slight change behind the scenes). I've added a parameter that is passed to Inline::MakeMaker in its argument hash, %args, 'INLINE_MODULES' which is a reference to an array of modules that use Inline and should be included in the generated Makefile. diff -r 8a9bc8d83cc9 -r e52ea446fd77 Inline.pm --- a/Inline.pm Thu May 15 07:03:36 2014 -0500 +++ b/Inline.pm Thu May 15 07:14:25 2014 -0500 @@ -515,12 +515,12 @@ sub load { my $o = shift; if ($o->{CONFIG}{_INSTALL_}) { - my $inline = "$o->{API}{modfname}.inl"; + my $inline = $o->{API}{modinlname}; open INLINE, "> $inline" or croak M24_open_for_output_failed($inline); print INLINE "*** AUTOGENERATED by Inline.pm ***\n\n"; print INLINE "This file satisfies the make dependency for "; - print INLINE "$o->{API}{modfname}.pm\n"; + print INLINE "$o->{API}{module}\n"; close INLINE; return; } @@ -983,6 +983,7 @@ sub install { my @modparts = split(/::/,$o->{API}{module}); $o->{API}{modfname} = $modparts[-1]; $o->{API}{modpname} = File::Spec->catdir(@modparts); + $o->{API}{modinlname} = join('-',@modparts).'.inl'; $o->{API}{suffix} = $o->{INLINE}{ILSM_suffix}; $o->{API}{build_dir} = File::Spec->catdir($o->{INLINE}{DIRECTORY},'build', $o->{API}{modpname}); diff -r 8a9bc8d83cc9 -r e52ea446fd77 lib/Inline/MakeMaker.pm --- a/lib/Inline/MakeMaker.pm Thu May 15 07:03:36 2014 -0500 +++ b/lib/Inline/MakeMaker.pm Thu May 15 07:14:25 2014 -0500 @@ -23,8 +23,24 @@ sub WriteMakefile { my %args = @_; my $name = $args{NAME} or croak "Inline::MakeMaker::WriteMakefile requires the NAME parameter\n"; - my $object = (split(/::/, $name))[-1]; my $version = ''; + my @objects; + + if (defined $args{INLINE_MODULES}) { + croak <<END unless ref($args{INLINE_MODULES}) eq 'ARRAY'; +Inline::MakeMaker::WriteMakefile: INLINE_MODULES must be a reference to an +array of modules +END + @objects = @{$args{INLINE_MODULES}}; + + # Don't pass this on to ExtUtils::MakeMaker, it will complain + delete $args{INLINE_MODULES} if defined $args{INLINE_MODULES}; + } else { + @objects = $name; + } + + my @obj_rules; + map { s/::/-/g; s/$/.inl/ } (@obj_rules = @objects); croak <<END unless (defined $args{VERSION} or defined $args{VERSION_FROM}); Inline::MakeMaker::WriteMakefile requires either the VERSION or VERSION_FROM @@ -43,7 +59,7 @@ Must be of the form '#.##'. (For instanc END # Provide a convenience rule to clean up Inline's messes - $args{clean} = { FILES => "_Inline $object.inl" } + $args{clean} = { FILES => "_Inline ".join(' ', @obj_rules) } unless defined $args{clean}; # Add Inline to the dependencies $args{PREREQ_PM}{Inline} = '0.44' unless defined $args{PREREQ_PM}{Inline}; @@ -58,10 +74,17 @@ END # --- MakeMaker inline section: -$object.inl : \$(TO_INST_PM) - \$(PERL) -Mblib -MInline=NOISY,_INSTALL_ -M$name -e1 $version \$(INST_ARCHLIB) +MAKEFILE + for (0..$#objects) { + print MAKEFILE <<MAKEFILE; +$obj_rules[$_]: \$(TO_INST_PM) + \$(PERL) -Mblib -MInline=NOISY,_INSTALL_ -M$objects[$_] -e1 $version \$(INST_ARCHLIB) +MAKEFILE + } -pure_all :: $object.inl +print MAKEFILE "\npure_all :: ",join(' ',@obj_rules),"\n"; + +print MAKEFILE <<MAKEFILE; # The End is here. MAKEFILE diff -r e52ea446fd77 -r 8afe37491d63 Inline.pod --- a/Inline.pod Thu May 15 07:14:25 2014 -0500 +++ b/Inline.pod Tue May 20 17:36:39 2014 -0500 @@ -921,6 +921,16 @@ to use Inline::MakeMaker; +If you have multiple modules in your distribution that use Inline, you +can make Inline::MakeMaker aware of them by adding an C<INLINE_MODULES> +parameter to the arguments you pass to Inline::MakeMaker. This parameter +must be a reference to an array of module names. For example: + + INLINE_MODULES => [qw( Foo::Bar Foo::Bar::Baz )], + +By doing this Inline::MakeMaker will make sure these get built and installed +properly. + And, in order that the module build work correctly in the cpan shell, add the following directive to the Makefile.PL's WriteMakefile():