| 1 | # You may distribute under the terms of either the GNU General Public License | ||
| 2 | # or the Artistic License (the same terms as Perl itself) | ||
| 3 | # | ||
| 4 | # (C) Paul Evans, 2020-2024 -- leonerd@leonerd.org.uk | ||
| 5 | |||
| 6 | package XS::Parse::Sublike::Builder 0.42; | ||
| 7 | |||
| 8 | use v5.14; | ||
| 9 | use warnings; | ||
| 10 | |||
| 11 | =head1 NAME | ||
| 12 | |||
| 13 | C<XS::Parse::Sublike::Builder> - build-time support for C<XS::Parse::Sublike> | ||
| 14 | |||
| 15 | =head1 SYNOPSIS | ||
| 16 | |||
| 17 | In F<Build.PL>: | ||
| 18 | |||
| 19 | use XS::Parse::Sublike::Builder; | ||
| 20 | |||
| 21 | my $build = Module::Build->new( | ||
| 22 | ..., | ||
| 23 | configure_requires => { | ||
| 24 | ... | ||
| 25 | 'XS::Parse::Sublike::Builder' => 0, | ||
| 26 | } | ||
| 27 | ); | ||
| 28 | |||
| 29 | XS::Parse::Sublike::Builder->extend_module_build( $build ); | ||
| 30 | |||
| 31 | ... | ||
| 32 | |||
| 33 | =head1 DESCRIPTION | ||
| 34 | |||
| 35 | This module provides a build-time helper to assist authors writing XS modules | ||
| 36 | that use L<XS::Parse::Sublike>. It prepares a L<Module::Build>-using | ||
| 37 | distribution to be able to make use of C<XS::Parse::Sublike>. | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | =head1 FUNCTIONS | ||
| 42 | |||
| 43 | =cut | ||
| 44 | |||
| 45 | =head2 write_XSParseSublike_h | ||
| 46 | |||
| 47 | XS::Parse::Sublike::Builder->write_XSParseSublike_h; | ||
| 48 | |||
| 49 | This method no longer does anything I<since version 0.22>. | ||
| 50 | |||
| 51 | =cut | ||
| 52 | |||
| 53 | sub write_XSParseSublike_h | ||
| 54 | { | ||
| 55 | } | ||
| 56 | |||
| 57 | =head2 extra_compiler_flags | ||
| 58 | |||
| 59 | @flags = XS::Parse::Sublike::Builder->extra_compiler_flags; | ||
| 60 | |||
| 61 | Returns a list of extra flags that the build scripts should add to the | ||
| 62 | compiler invocation. This enables the C compiler to find the | ||
| 63 | F<XSParseSublike.h> file. | ||
| 64 | |||
| 65 | =cut | ||
| 66 | |||
| 67 | sub extra_compiler_flags | ||
| 68 | { | ||
| 69 | shift; | ||
| 70 | |||
| 71 | require File::ShareDir; | ||
| 72 | require File::Spec; | ||
| 73 | require XS::Parse::Sublike; | ||
| 74 | return "-I" . File::Spec->catdir( File::ShareDir::module_dir( "XS::Parse::Sublike" ), "include" ); | ||
| 75 | } | ||
| 76 | |||
| 77 | =head2 extend_module_build | ||
| 78 | |||
| 79 | XS::Parse::Sublike::Builder->extend_module_build( $build ); | ||
| 80 | |||
| 81 | A convenient shortcut for performing all the tasks necessary to make a | ||
| 82 | L<Module::Build>-based distribution use the helper. | ||
| 83 | |||
| 84 | =cut | ||
| 85 | |||
| 86 | sub extend_module_build | ||
| 87 | { | ||
| 88 | my $self = shift; | ||
| 89 | my ( $build ) = @_; | ||
| 90 | |||
| 91 | # preserve existing flags | ||
| 92 | my @flags = @{ $build->extra_compiler_flags }; | ||
| 93 | push @flags, $self->extra_compiler_flags; | ||
| 94 | |||
| 95 | $build->extra_compiler_flags( @flags ); | ||
| 96 | } | ||
| 97 | |||
| 98 | =head1 AUTHOR | ||
| 99 | |||
| 100 | Paul Evans <leonerd@leonerd.org.uk> | ||
| 101 | |||
| 102 | =cut | ||
| 103 | |||
| 104 | 0x55AA; |