I think the ideal way would be to have the bootstrap statement in your .pm file simply load the appropriate .dll/.so. That is, the bootstrap statement already knows where to look and what to look for depending upon which platform it is invoked on.
So, if you can make the build process only attempt to build the platform specific .xs file and put it into the right place, and if all platforms present the same interface, then the whole thing get taken care of at extension build times and there is nothing more to do.
It would certainly move a heap of messy platform-conditional stuff out of the sources. Of course, it can also create a maintanence problem with code duplication, but on the basis that only the performance critical or "only possible in C" code should be done in XS with the rest done in the .PM file, the duplication would be minimal.
Whether there is anything in the existing makefile generation processors to cater for this I'm not sure, but at the simplest of levels it could be something along the lines of having a module.xs.w32 and module.xs.nix and just copying or renaming the appropriate one to module.xs when setting up the blib.
Alternatively, since compilers already know how to do platform specific selection at compile time, it might be better to have a single module.xs and platform specific includes. It also eliminates the need for common code duplication:
// module.xs ... #if defined(WIN32) # include "module.win32"; #elseif define(MAC) # include "module.mac" #else # include "module.unix" #endif ...
Same make file; same .xs file; same .pm file; same bootstrap. Just the contents of the .dll/.so changes?
Somebody will point out that #include is for header files, and include files should be named .h, and having executable code in include files is frowned upon; but XS is a different langauge to C and it can set what rules it decides upon.
In reply to Re: Splitting an extension based on OS
by BrowserUk
in thread Splitting an extension based on OS
by syphilis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |