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