blib/lib/Data/Checks/Builder.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 32 CC 1 SCAR 6.9
CC
1
Cov
0%
extra_compiler_flags
2.0
extend_module_build
2.0
BEGIN
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, 2024 -- leonerd@leonerd.org.uk
5  
6 package Data::Checks::Builder 0.44;
7  
8 use v5.22;
9 use warnings;
10  
11 =head1 NAME
12  
13 C<Data::Checks::Builder> - build-time support for C<Data::Checks>
14  
15 =head1 SYNOPSIS
16  
17 In F<Build.PL>:
18  
19 use Data::Checks::Builder;
20  
21 my $build = Module::Build->new(
22 ...,
23 configure_requires => {
24 ...
25 'Data::Checks::Builder' => 0,
26 }
27 );
28  
29 Data::Checks::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<Data::Checks>. It prepares a L<Module::Build>-using
37 distribution to be able to make use of C<Data::Checks>.
38  
39 =cut
40  
41 =head2 extra_compiler_flags
42  
43 @flags = Data::Checks::Builder->extra_compiler_flags;
44  
45 Returns a list of extra flags that the build scripts should add to the
46 compiler invocation. This enables the C compiler to find the
47 F<DataChecks.h> file.
48  
49 =cut
50  
51 sub extra_compiler_flags
52 {
53 shift;
54  
55 require File::ShareDir;
56 require File::Spec;
57 require Data::Checks;
58 return "-I" . File::Spec->catdir( File::ShareDir::module_dir( "Data::Checks" ), "include" );
59 }
60  
61 =head2 extend_module_build
62  
63 Data::Checks::Builder->extend_module_build( $build );
64  
65 A convenient shortcut for performing all the tasks necessary to make a
66 L<Module::Build>-based distribution use the helper.
67  
68 =cut
69  
70 sub extend_module_build
71 {
72 my $self = shift;
73 my ( $build ) = @_;
74  
75 # preserve existing flags
76 my @flags = @{ $build->extra_compiler_flags };
77 push @flags, $self->extra_compiler_flags;
78  
79 $build->extra_compiler_flags( @flags );
80 }
81  
82 =head1 AUTHOR
83  
84 Paul Evans <leonerd@leonerd.org.uk>
85  
86 =cut
87  
88 0x55AA;