Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Making Inline::C modules fit for CPAN

by tsee (Curate)
on Nov 16, 2006 at 17:56 UTC ( #584540=note: print w/ replies, xml ) Need Help??


in reply to Making Inline::C modules fit for CPAN

Okay, I got a little further. Along the way, various issues of varying potential to make me really sick came up. Supposing I release Module::Inline::C to CPAN, here's the recipe for converting your Inline::C-based CPAN distribution to use Module::Inline::C. This works for MakeMaker-based distributions only at this point.

  • Replace all invocations of Inline with M::I::C:
    # use Inline C => '<<HERE'; # becomes use Module::Inline::C <<'HERE'; ... HERE
  • Replace the 1; that ends the module/.pm file with use Module::Inline::C 'END';
  • The version declaration of your module needs to be accessible at compile time and also determinable by MakeMaker which uses a simple regex to extract it. That means you need to do this:
    # our $VERSION = '0.01'; # becomes our $VERSION = '0.01'; BEGIN {$VERSION = '0.01'};
    (Similarly if you prefer use vars '$VERSION'.)
  • You need to add a bit to your Makefile.PL. For module Foo::Bar, this might look like:
    use ExtUtils::MakeMaker; my $module_file = 'lib/Foo/Bar.pm'; WriteMakefile( NAME => 'Foo::Bar', VERSION_FROM => $module_file, PREREQ_PM => { 'Module::Inline::C' => '0', # instead of Inline }, ($] >= 5.005 ? (ABSTRACT_FROM => $module_file, AUTHOR => 'Your Name <and@e.mail>') : ()), dist => { PREOP => "perl -MModule::Inline::C::MM=\$(DISTNAME)-\$(VERSION +) -c $module_file", }, );
    The dist => ... part specifies that before tar-ing up the distribution file, the Inline::C to XS conversion should take place. The MANIFEST of the generated distribution is updated automatically.

That should be mostly it. Afterwards, anybody downloading and installing your distribution should be able to do the usual

perl Makefile.PL make # compiles XS => so/dll into blib/ make test # doesn't use Inline! make install # no more Inline for this module, ever.

Of course, the user is free to delete the .xs files from the distribution and use Inline instead. Using Inline::C can be much more enjoyable for development (IMHO).

There's still a lot of cleaning up to do as well as adding documentation and implementations for Module::Build and Module::Install. Additionally, if you have a distribution with several XS (or rather: Inline::C) modules, you might run into trouble with this. But you're welcome to read up on the issue. It's not specific to this but rather common to all XS distributions.

Steffen

Update: I forgot one item in the list.


Comment on Re: Making Inline::C modules fit for CPAN
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://584540]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-12-20 22:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (99 votes), past polls