Greets,

I'm working on a CPAN distro with dozens of modules, several of which are outfitted with XS code. What's the best directory structure for this kind of thing?

Traditionally, .xs files and their associated Makefile.PL files get put in either the root directory of the distro, or one level above in a folder named for the last part of the package (e.g. Bar.xs from Foo::Bar gets put in MyDist-0.01/Bar/, along with Bar.pm). That doesn't scale well, unfortunately -- the distro's root directory gets real cluttered.

For now, what I'm doing is putting all the .pm files in MyDist-0.01/lib/ and giving each XS module a folder in MyDist-0.01/XS/. The upside of this strategy is that you can grok the distro's structure by looking only at Mydist-0.01/lib/, as if it were a pure Perl distro.

There are two downsides. First, the xs dirs are not organized hierarchically, but collected in a flat dir which doesn't mirror the distro's structure. Second, MakeMaker chdir's into the dir with the Makefile.PL before running it, so building the the path to the associated .pm file at MyDist-0.01/lib/Foo/Bar.pm gets messy. Right now, the code looks like...

my $path_to_pm_file = catfile(updir, updir, 'lib', 'Foo', 'Bar.pm');

... and I'm not even sure that's portable.

Suggestions?

--
Marvin Humphrey
Rectangular Research ― http://www.rectangular.com

In reply to Distro with multiple XS modules by creamygoodness

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.