blib/lib/XS/Parse/Keyword/Builder.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 38 CC 1 SCAR 6.9
CC
1
Cov
0%
write_XSParseKeyword_h
2.0
extra_compiler_flags
2.0
extend_module_build
2.0
CRAP 2.0
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 -- leonerd@leonerd.org.uk
5  
6 package XS::Parse::Keyword::Builder 0.51;
7  
8 use v5.14;
9 use warnings;
10  
11 =head1 NAME
12  
13 C<XS::Parse::Keyword::Builder> - build-time support for C<XS::Parse::Keyword>
14  
15 =head1 SYNOPSIS
16  
17 =for highlighter language=perl
18  
19 In F<Build.PL>:
20  
21 use XS::Parse::Keyword::Builder;
22  
23 my $build = Module::Build->new(
24 ...,
25 configure_requires => {
26 ...
27 'XS::Parse::Keyword::Builder' => 0,
28 }
29 );
30  
31 XS::Parse::Keyword::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::Keyword>. It prepares a L<Module::Build>-using
39 distribution to be able to make use of C<XS::Parse::Keyword>.
40  
41 =cut
42  
43 use XS::Parse::Keyword::Builder_data;
44  
45 =head1 FUNCTIONS
46  
47 =cut
48  
49 =head2 write_XSParseKeyword_h
50  
51 XS::Parse::Keyword::Builder->write_XSParseKeyword_h;
52  
53 This method no longer does anything I<since version 0.43>.
54  
55 =cut
56  
57 sub write_XSParseKeyword_h
58 {
59 }
60  
61 =head2 extra_compiler_flags
62  
63 @flags = XS::Parse::Keyword::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<XSParseKeyword.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::Keyword;
78  
79 return "-I" . File::Spec->catdir( File::ShareDir::module_dir( "XS::Parse::Keyword" ), "include" ),
80 XS::Parse::Keyword::Builder_data->BUILDER_CFLAGS;
81 }
82  
83 =head2 extend_module_build
84  
85 XS::Parse::Keyword::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 <leonerd@leonerd.org.uk>
107  
108 =cut
109  
110 0x55AA;