File Coverage

Makefile.PL
Criterion Covered Total %
statement 7 72 9.7
branch 0 48 0.0
condition 0 12 0.0
subroutine 3 8 37.5
pod n/a
total 10 140 7.1


line stmt bran cond sub pod time code
1             # -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2              
3 1     1   493 use strict;
  1         2  
  1         34  
4 1     1   915 use ExtUtils::MakeMaker qw(WriteMakefile);
  1         113890  
  1         1371  
5             # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6             # the contents of the Makefile that is written.
7              
8             # Normalize version strings like 6.30_02 to 6.3002,
9             # so that we can do numerical comparisons on it.
10             my $eumm_version = $ExtUtils::MakeMaker::VERSION;
11             $eumm_version =~ s/_//;
12              
13             my $module = 'Net::Async::OSC';
14             (my $main_file = "lib/$module.pm" ) =~ s!::!/!g;
15             (my $distbase = $module) =~ s!::!-!g;
16             my $distlink = $distbase;
17              
18             my @tests = map { glob $_ } 't/*.t', 't/*/*.t';
19              
20             my %module = (
21             NAME => $module,
22             AUTHOR => q{Max Maischein },
23             VERSION_FROM => $main_file,
24             ABSTRACT_FROM => $main_file,
25             META_MERGE => {
26             "meta-spec" => { version => 2 },
27             resources => {
28             repository => {
29             web => "https://github.com/Corion/$distlink",
30             url => "git://github.com/Corion/$distlink.git",
31             type => 'git',
32             },
33             bugtracker => {
34             web => "https://github.com/Corion/$distbase/issues",
35             # mailto => 'meta-bugs@example.com',
36             },
37             license => "https://dev.perl.org/licenses/",
38             },
39             dynamic_config => 0, # we promise to keep META.* up-to-date
40             x_static_install => 1, # we are pure Perl and don't do anything fancy
41              
42             },
43              
44             MIN_PERL_VERSION => '5.020', # I use signatures
45              
46             'LICENSE'=> 'perl',
47              
48             PL_FILES => {},
49             BUILD_REQUIRES => {
50             'ExtUtils::MakeMaker' => 0,
51             },
52              
53             PREREQ_PM => {
54             'Carp' => 0,
55             'ExtUtils::MakeMaker' => 0,
56             'Getopt::Long' => 0,
57             'IO::Async::Loop' => 0,
58             'IO::Async::Socket' => 0,
59             'IO::Async::Timer::Periodic' => 0,
60             'Moo' => 2,
61             'Protocol::OSC' => 0,
62             'Socket' => 0,
63             'Term::Output::List' => 0,
64              
65             # For the example player
66             'Music::Chord::Note' => 0,
67             'Music::Scales' => 0,
68             'Music::VoiceGen' => 0,
69             },
70              
71             TEST_REQUIRES => {
72             'Test2::V0' => 0,
73             },
74              
75             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
76             clean => { FILES => "$distbase-*" },
77              
78             test => { TESTS => join( ' ', @tests ) },
79             );
80              
81             # This is so that we can do
82             # require 'Makefile.PL'
83             # and then call get_module_info
84              
85 1     1   14 sub get_module_info { %module }
86              
87             if( ! caller ) {
88             # I should maybe use something like Shipwright...
89             regen_README($main_file);
90             regen_EXAMPLES() if -d 'examples';
91             WriteMakefile1(get_module_info);
92             };
93              
94             1;
95              
96             sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
97 0     0     my %params=@_;
98 0           my $eumm_version=$ExtUtils::MakeMaker::VERSION;
99 0           $eumm_version=eval $eumm_version;
100 0 0         die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
101 0 0         die "License not specified" if not exists $params{LICENSE};
102 0 0 0       if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
103             #EUMM 6.5502 has problems with BUILD_REQUIRES
104 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
  0            
  0            
105 0           delete $params{BUILD_REQUIRES};
106             }
107 0 0 0       if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
108 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
  0            
  0            
109 0           delete $params{TEST_REQUIRES};
110             }
111 0 0         delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
112 0 0         delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
113 0 0         delete $params{META_MERGE} if $eumm_version < 6.46;
114 0 0         delete $params{META_ADD} if $eumm_version < 6.46;
115 0 0         delete $params{LICENSE} if $eumm_version < 6.31;
116 0 0         delete $params{AUTHOR} if $] < 5.005;
117 0 0         delete $params{ABSTRACT_FROM} if $] < 5.005;
118 0 0         delete $params{BINARY_LOCATION} if $] < 5.005;
119              
120 0           WriteMakefile(%params);
121             }
122              
123             sub regen_README {
124             # README is the short version that just tells people what this is
125             # and how to install it
126 0     0     eval {
127             # Get description
128 0           my $readme = join "\n",
129             pod_section($_[0], 'NAME', 'no heading' ),
130             pod_section($_[0], 'DESCRIPTION' ),
131             <
132              
133             INSTALLATION
134              
135             This is a Perl module distribution. It should be installed with whichever
136             tool you use to manage your installation of Perl, e.g. any of
137              
138             cpanm .
139             cpan .
140             cpanp -i .
141              
142             Consult https://www.cpan.org/modules/INSTALL.html for further instruction.
143             Should you wish to install this module manually, the procedure is
144              
145             perl Makefile.PL
146             make
147             make test
148             make install
149              
150             INSTALL
151             pod_section($_[0], 'REPOSITORY'),
152             pod_section($_[0], 'SUPPORT'),
153             pod_section($_[0], 'TALKS'),
154             pod_section($_[0], 'KNOWN ISSUES'),
155             pod_section($_[0], 'BUG TRACKER'),
156             pod_section($_[0], 'CONTRIBUTING'),
157             pod_section($_[0], 'SEE ALSO'),
158             pod_section($_[0], 'AUTHOR'),
159             pod_section($_[0], 'LICENSE' ),
160             pod_section($_[0], 'COPYRIGHT' ),
161             ;
162 0           update_file( 'README', $readme );
163             };
164             # README.mkdn is the documentation that will be shown as the main
165             # page of the repository on Github. Hence we recreate the POD here
166             # as Markdown
167 0           eval {
168 0           require Pod::Markdown;
169              
170 0           my $parser = Pod::Markdown->new();
171              
172             # Read POD from Module.pm and write to README
173 0           $parser->parse_from_file($_[0]);
174 0           my $readme_mkdn = <as_markdown;
175              
176             [![Windows](https://github.com/Corion/$distbase/workflows/windows/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Awindows)
177             [![MacOS](https://github.com/Corion/$distbase/workflows/macos/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Amacos)
178             [![Linux](https://github.com/Corion/$distbase/workflows/linux/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Alinux)
179              
180             STATUS
181 0           update_file( 'README.mkdn', $readme_mkdn );
182             };
183             }
184              
185             sub pod_section {
186 0     0     my( $filename, $section, $remove_heading ) = @_;
187 0 0         open my $fh, '<', $filename
188             or die "Couldn't read '$filename': $!";
189              
190             my @section =
191 0           grep { /^=head1\s+$section/.../^=/ } <$fh>;
  0            
192              
193             # Trim the section
194 0 0         if( @section ) {
195 0 0         pop @section if $section[-1] =~ /^=/;
196 0 0         shift @section if $remove_heading;
197              
198             pop @section
199 0   0       while @section and $section[-1] =~ /^\s*$/;
200             shift @section
201 0   0       while @section and $section[0] =~ /^\s*$/;
202             };
203              
204 0           @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
  0            
  0            
205 0           return join "", @section;
206             }
207              
208             sub regen_EXAMPLES {
209 0     0     my $perl = $^X;
210 0 0         if ($perl =~/\s/) {
211 0           $perl = qq{"$perl"};
212             };
213 0           (my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
214 0           my $examples = `$perl -w examples/gen_examples_pod.pl`;
215 0 0         if ($examples) {
216 0           warn "(Re)Creating $example_file\n";
217 0           $examples =~ s/\r\n/\n/g;
218 0           update_file( $example_file, $examples );
219             };
220             };
221              
222             sub update_file {
223 0     0     my( $filename, $new_content ) = @_;
224 0           my $content;
225 0 0         if( -f $filename ) {
226 0 0         open my $fh, '<:raw:encoding(UTF-8)', $filename
227             or die "Couldn't read '$filename': $!";
228 0           local $/;
229 0           $content = <$fh>;
230             };
231              
232 0 0         if( $content ne $new_content ) {
233 0 0         if( open my $fh, '>:raw:encoding(UTF-8)', $filename ) {
234 0           print $fh $new_content;
235             } else {
236 0           warn "Couldn't (re)write '$filename': $!";
237             };
238             };
239             }