.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Module::Build::WithXSpp 3pm" .TH Module::Build::WithXSpp 3pm "2016-08-27" "perl v5.22.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Module::Build::WithXSpp \- XS++ enhanced flavour of Module::Build .SH "SYNOPSIS" .IX Header "SYNOPSIS" In \fIBuild.PL\fR: .PP .Vb 3 \& use strict; \& use warnings; \& use 5.006001; \& \& use Module::Build::WithXSpp; \& \& my $build = Module::Build::WithXSpp\->new( \& # normal Module::Build arguments... \& # optional: mix in some extra C typemaps: \& extra_typemap_modules => { \& \*(AqExtUtils::Typemaps::ObjectMap\*(Aq => \*(Aq0\*(Aq, \& }, \& ); \& $build\->create_build_script; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This subclass of Module::Build adds some tools and processes to make it easier to use for wrapping \*(C+ using \s-1XS++ \s0(ExtUtils::XSpp). .PP There are a few minor differences from using \f(CW\*(C`Module::Build\*(C'\fR for an ordinary \s-1XS\s0 module and a few conventions that you should be aware of as an \s-1XS++\s0 module author. They are documented in the \*(L"\s-1FEATURES AND CONVENTIONS\*(R"\s0 section below. But if you can't be bothered to read all that, you may choose skip it and blindly follow the advice in \*(L"\s-1JUMP START FOR THE IMPATIENT\*(R"\s0. .PP An example of a full distribution based on this build tool can be found in the ExtUtils::XSpp distribution under \&\fIexamples/XSpp\-Example\fR. Using that example as the basis for your \f(CW\*(C`Module::Build::WithXSpp\*(C'\fR\-based distribution is probably a good idea. .SH "FEATURES AND CONVENTIONS" .IX Header "FEATURES AND CONVENTIONS" .SS "\s-1XS\s0 files" .IX Subsection "XS files" By default, \f(CW\*(C`Module::Build::WithXSpp\*(C'\fR will automatically generate a main \s-1XS\s0 file for your module which includes all \s-1XS++\s0 files and does the correct incantations to support \&\*(C+. .PP If \f(CW\*(C`Module::Build::WithXSpp\*(C'\fR detects any \s-1XS\s0 files in your module, it will skip the generation of this default file and assume that you wrote a custom main \s-1XS\s0 file. If that is not what you want, and wish to simply include plain \s-1XS\s0 code, then you should put the \s-1XS\s0 in a verbatim block of an \fI.xsp\fR file. In case you need to use the plain-C part of an \s-1XS\s0 file for \f(CW\*(C`#include\*(C'\fR directives and other code, then put your code into a header file and \f(CW\*(C`#include\*(C'\fR it from an \fI.xsp\fR file: .PP In \fIsrc/mystuff.h\fR: .PP .Vb 2 \& #include \& using namespace some::thing; .Ve .PP In \fIxsp/MyClass.xsp\fR .PP .Vb 1 \& #include "mystuff.h" \& \& %{ \& ... verbatim XS here ... \& %} .Ve .PP Note that there is no guarantee about the order in which the \&\s-1XS++\s0 files are picked up. .SS "Build directory" .IX Subsection "Build directory" When building your \s-1XS++\s0 based extension, a temporary build directory \fIbuildtmp\fR is created for the byproducts. It is automatically cleaned up by \f(CW\*(C`./Build clean\*(C'\fR. .SS "Source directories" .IX Subsection "Source directories" A Perl module distribution typically has the module \f(CW\*(C`.pm\*(C'\fR files in its \fIlib\fR subdirectory. In a \f(CW\*(C`Module::Build::WithXSpp\*(C'\fR based distribution, there are two more such conventions about source directories: .PP If any \*(C+ source files are present in the \fIsrc\fR directory, they will be compiled to object files and linked automatically. .PP Any \f(CW\*(C`.xs\*(C'\fR, \f(CW\*(C`.xsp\*(C'\fR, and \f(CW\*(C`.xspt\*(C'\fR files in an \fIxs\fR or \fIxsp\fR subdirectory will be automatically picked up and included by the build system. .PP For backwards compatibility, files of the above types are also recognized in \fIlib\fR. .SS "Typemaps" .IX Subsection "Typemaps" In \s-1XS++,\s0 there are two types of typemaps: The ordinary \s-1XS\s0 typemaps which conventionally put in a file called \fItypemap\fR, and \s-1XS++\s0 typemaps. .PP The ordinary \s-1XS\s0 typemaps will be found in the main directory, under \fIlib\fR, and in the \s-1XS\s0 directories (\fIxs\fR and \fIxsp\fR). They are required to carry the \f(CW\*(C`.map\*(C'\fR extension or to be called \fItypemap\fR. You may use multiple \fI.map\fR files if the entries do not collide. They will be merged at build time into a complete \fItypemap\fR file in the temporary build directory. .PP The \f(CW\*(C`extra_typemap_modules\*(C'\fR option is the preferred way to do \s-1XS\s0 typemapping. It works like any other \f(CW\*(C`Module::Build\*(C'\fR argument that declares dependencies except that it loads the listed modules at build time and includes their typemaps into the build. .PP The \s-1XS++\s0 typemaps are required to carry the \f(CW\*(C`.xspt\*(C'\fR extension or (for backwards compatibility) to be called \f(CW\*(C`typemap.xsp\*(C'\fR. .SS "Detecting the \*(C+ compiler" .IX Subsection "Detecting the compiler" \&\f(CW\*(C`Module::Build::WithXSpp\*(C'\fR uses ExtUtils::CppGuess to detect a \*(C+ compiler on your system that is compatible with the C compiler that was used to compile your perl binary. It sets some additional compiler/linker options. .PP This is known to work on \s-1GCC \s0(Linux, MacOS, Windows, and ?) as well as the \s-1MS VC\s0 toolchain. Patches to enable other compilers are \&\fBvery\fR welcome. .SS "Automatic dependencies" .IX Subsection "Automatic dependencies" \&\f(CW\*(C`Module::Build::WithXSpp\*(C'\fR automatically adds several dependencies (on the currently running versions) to your distribution. You can disable this by setting \&\f(CW\*(C`auto_configure_requires => 0\*(C'\fR in \fIBuild.PL\fR. .PP These are at configure time: \f(CW\*(C`Module::Build\*(C'\fR, \&\f(CW\*(C`Module::Build::WithXSpp\*(C'\fR itself, and \f(CW\*(C`ExtUtils::CppGuess\*(C'\fR. Additionally there will be a build-time dependency on \&\f(CW\*(C`ExtUtils::XSpp\*(C'\fR. .PP You do not have to set these dependencies yourself unless you need to set the required versions manually. .SS "Include files" .IX Subsection "Include files" Unfortunately, including the perl headers produces quite some pollution and redefinition of common symbols. Therefore, it may be necessary to include some of your headers before including the perl headers. Specifically, this is the case for \s-1MSVC\s0 compilers and the standard library headers. .PP Therefore, if you care about that platform in the least, you should use the \f(CW\*(C`early_includes\*(C'\fR option when creating a \f(CW\*(C`Module::Build::WithXSpp\*(C'\fR object to list headers to include before the perl headers. If such a supplied header file starts with a double quote, \f(CW\*(C`#include "..."\*(C'\fR is used, otherwise \f(CW\*(C`#include <...>\*(C'\fR is the default. Example: .PP .Vb 6 \& Module::Build::WithXSpp\->new( \& early_includes => [qw( \& "mylocalheader.h" \& \& )] \& ) .Ve .SH "JUMP START FOR THE IMPATIENT" .IX Header "JUMP START FOR THE IMPATIENT" There are as many ways to start a new \s-1CPAN\s0 distribution as there are \s-1CPAN\s0 distributions. Choose your favourite (I just do \f(CW\*(C`h2xs \-An My::Module\*(C'\fR), then apply a few changes to your setup: .IP "\(bu" 2 Obliterate any \fIMakefile.PL\fR. .Sp This is what your \fIBuild.PL\fR should look like: .Sp .Vb 4 \& use strict; \& use warnings; \& use 5.006001; \& use Module::Build::WithXSpp; \& \& my $build = Module::Build::WithXSpp\->new( \& module_name => \*(AqMy::Module\*(Aq, \& license => \*(Aqperl\*(Aq, \& dist_author => q{John Doe }, \& dist_version_from => \*(Aqlib/My/Module.pm\*(Aq, \& build_requires => { \*(AqTest::More\*(Aq => 0, }, \& extra_typemap_modules => { \& \*(AqExtUtils::Typemaps::ObjectMap\*(Aq => \*(Aq0\*(Aq, \& # ... \& }, \& ); \& $build\->create_build_script; .Ve .Sp If you need to link against some library \f(CW\*(C`libfoo\*(C'\fR, add this to the options: .Sp .Vb 1 \& extra_linker_flags => [qw(\-lfoo)], .Ve .Sp There is \f(CW\*(C`extra_compiler_flags\*(C'\fR, too, if you need it. .IP "\(bu" 2 You create two folders in the main distribution folder: \&\fIsrc\fR and \fIxsp\fR. .IP "\(bu" 2 You put any \*(C+ code that you want to build and include in the module into \fIsrc/\fR. All the typical C(++) file extensions are recognized and will be compiled to object files and linked into the module. And headers in that folder will be accessible for \f(CW\*(C`#include \*(C'\fR. .Sp For good measure, move a copy of \fIppport.h\fR to that directory. See Devel::PPPort. .IP "\(bu" 2 You do not write normal \s-1XS\s0 files. Instead, you write \s-1XS++\s0 and put it into the \fIxsp/\fR folder in files with the \f(CW\*(C`.xsp\*(C'\fR extension. Do not worry, you can include verbatim \s-1XS\s0 blocks in \s-1XS++.\s0 For details on \s-1XS++,\s0 see ExtUtils::XSpp. .IP "\(bu" 2 If you need to do any \s-1XS\s0 type mapping, put your typemaps into a \fI.map\fR file in the \f(CW\*(C`xsp\*(C'\fR directory. Alternatively, search \s-1CPAN\s0 for an appropriate typemap module (cf. ExtUtils::Typemaps::Default for an explanation). \&\s-1XS++\s0 typemaps belong into \fI.xspt\fR files in the same directory. .IP "\(bu" 2 In this scheme, \fIlib/\fR only contains Perl module files (and \s-1POD\s0). If you started from a pure-Perl distribution, don't forget to add these magic two lines to your main module: .Sp .Vb 2 \& require XSLoader; \& XSLoader::load(\*(AqMy::Module\*(Aq, $VERSION); .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Module::Build upon which this module is based. .PP ExtUtils::XSpp implements \s-1XS++.\s0 The \f(CW\*(C`ExtUtils::XSpp\*(C'\fR distribution contains an \fIexamples\fR directory with a usage example of this module. .PP ExtUtils::Typemaps implements progammatic modification (merging) of C/XS typemaps. \f(CW\*(C`ExtUtils::Typemaps\*(C'\fR was renamed from \f(CW\*(C`ExtUtils::Typemap\*(C'\fR since the original name conflicted with the core \fItypemap\fR file on case-insensitive file systems. .PP ExtUtils::Typemaps::Default explains the concept of having typemaps shipped as modules. .PP ExtUtils::Typemaps::ObjectMap is such a typemap module and probably very useful for any \s-1XS++\s0 module. .PP ExtUtils::Typemaps::STL::String implements simple typemapping for \&\s-1STL \s0\f(CW\*(C`std::string\*(C'\fRs. .SH "AUTHOR" .IX Header "AUTHOR" Steffen Mueller .PP With input and bug fixes from: .PP Mattia Barbon .PP Shmuel Fomberg .PP Florian Schlichting .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2010, 2011, 2012, 2013 Steffen Mueller. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.