in reply to xs code in a perl module

I'd recommend against doing this. If others are already (or eventually will) use the XS module but don't need the functionality from the one you propose to encompass it by, then they are two distinct distributions. One just so happens to use the other. What happens if you realize you want another small XS distribution... will you bundle that as well? Now people who want the first small library have to install a distribution with even more code they don't need.

I have several examples of this sort of thing. I put all of the dissimilar/separate XS code into their own distributions, then require it in higher-level distributions. That allows anyone to use X::Y; and use X::Z; without requiring them to use X; that may have brought in X::A through X::X, which contain functionality they have no need for.

For example, my RPi::WiringPi distribution pulls in 10 or so XS distributions (eg: RPi::I2C, RPi::SPI, RPi::DHT11). Instead of forcing users to install a whole crapload of distributions they don't need by forcing them to install the top-level one (which takes a relatively significant time to build on the platform it was designed for), they can just install individual components if that's all they need (SPI for example). There are benefits to installing the whole shebang, but that's only if you're going to use multiple pieces of the functionality.

If the two distributions can be used independently from one another (in your case it sounds like there are benefits to using them independently), they should, imho, remain separate.

Replies are listed 'Best First'.
Re^2: xs code in a perl module
by frazap (Monk) on Oct 26, 2017 at 13:36 UTC
    Well thanks. I will keep them separate.

    Now since I have done a some testing I 've found a way that works to get the xs files in the same hierarchy, here it is for the reccord:

    the makefile.pl in the main folder is unchanged except for the added parameter to WriteMakefile

     DIR => [qw(xs)], In the xs folder I have all the *.h, *.c, *.xs. typemap files.

    xs/readme.pl is

    WriteMakefile( NAME => 'Win32::Shortkeys::Kbh', OBJECT => 'hook.o Kbh.o', INC => '-I.'
    and the Win32/Shortkeys/Kbh.pm file is in the lib tree above this xs folder.

    I can use makefile mantra from the main folder to compile, test, and it works.