| 1 | package Dist::Zilla::Plugin::MakeMaker 6.040; | ||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: build a Makefile.PL that uses ExtUtils::MakeMaker | ||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use Dist::Zilla::Pragmas; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||
| 8 | 13 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||
| 10 | 13 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 11 | 13 | ▶ | use CPAN::Meta::Requirements 2.121; # requirements_for_module | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 12 | 13 | ▶ | use List::Util 1.29 qw(first pairs pairgrep); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 13 | 13 | ▶ | use version; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 14 | 13 | ▶ | use Dist::Zilla::File::InMemory; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 15 | 13 | ▶ | use Dist::Zilla::Plugin::MakeMaker::Runner; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||
| 17 | #pod =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||
| 18 | #pod | ||||||||||||||||||||||||||||||||||||
| 19 | #pod This plugin will produce an L<ExtUtils::MakeMaker>-powered F<Makefile.PL> for | ||||||||||||||||||||||||||||||||||||
| 20 | #pod the distribution. If loaded, the L<Manifest|Dist::Zilla::Plugin::Manifest> | ||||||||||||||||||||||||||||||||||||
| 21 | #pod plugin should also be loaded. | ||||||||||||||||||||||||||||||||||||
| 22 | #pod | ||||||||||||||||||||||||||||||||||||
| 23 | #pod =cut | ||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||
| 25 | #pod =attr eumm_version | ||||||||||||||||||||||||||||||||||||
| 26 | #pod | ||||||||||||||||||||||||||||||||||||
| 27 | #pod This option declares the version of ExtUtils::MakeMaker required to configure | ||||||||||||||||||||||||||||||||||||
| 28 | #pod and build the distribution. There is no default, although one may be added if | ||||||||||||||||||||||||||||||||||||
| 29 | #pod it can be determined that the generated F<Makefile.PL> requires some specific | ||||||||||||||||||||||||||||||||||||
| 30 | #pod minimum. I<No testing has been done on this front.> | ||||||||||||||||||||||||||||||||||||
| 31 | #pod | ||||||||||||||||||||||||||||||||||||
| 32 | #pod =cut | ||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||
| 34 | 13 | has eumm_version => ( | |||||||||||||||||||||||||||||||||||
| 35 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||
| 36 | is => 'rw', | ||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||
| 39 | #pod =attr make_path | ||||||||||||||||||||||||||||||||||||
| 40 | #pod | ||||||||||||||||||||||||||||||||||||
| 41 | #pod This option sets the path to F<make>, used to build your dist and run tests. | ||||||||||||||||||||||||||||||||||||
| 42 | #pod It defaults to the value for C<make> in L<Config>, or to C<make> if that isn't | ||||||||||||||||||||||||||||||||||||
| 43 | #pod set. | ||||||||||||||||||||||||||||||||||||
| 44 | #pod | ||||||||||||||||||||||||||||||||||||
| 45 | #pod You probably won't need to set this option. | ||||||||||||||||||||||||||||||||||||
| 46 | #pod | ||||||||||||||||||||||||||||||||||||
| 47 | #pod =cut | ||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||
| 49 | has 'make_path' => ( | ||||||||||||||||||||||||||||||||||||
| 50 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||
| 51 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 52 | 13 | ▶ | default => $Config{make} || 'make', | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$Dist::Zilla::Plugin::MakeMaker::Config{'make'} || 'make'
MC/DC0%0/1
$Dist::Zilla::Plugin::MakeMaker::Config{'make'} || 'make'
$Dist::Zilla::Plugin::MakeMaker::Config{'make'}
Truth table50%1/2
A
A= $Dist::Zilla::Plugin::MakeMaker::Config{'make'}
| |||||||||||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||
| 55 | #pod =attr main_module | ||||||||||||||||||||||||||||||||||||
| 56 | #pod | ||||||||||||||||||||||||||||||||||||
| 57 | #pod This option sets the name of the main module in your dist. It defaults to the | ||||||||||||||||||||||||||||||||||||
| 58 | #pod name derived from the distribution's name after replacing C<-> with C<::>, (e.g. | ||||||||||||||||||||||||||||||||||||
| 59 | #pod C<Foo::Bar> for distribution C<Foo-Bar>). The value is set as a C<NAME> argument | ||||||||||||||||||||||||||||||||||||
| 60 | #pod for C<WriteMakefile>. | ||||||||||||||||||||||||||||||||||||
| 61 | #pod | ||||||||||||||||||||||||||||||||||||
| 62 | #pod You want to use this option when the name of distribution doesn't reflect any | ||||||||||||||||||||||||||||||||||||
| 63 | #pod module names contained in your distribution e.g. C<LWP> vs C<libwww-perl>. | ||||||||||||||||||||||||||||||||||||
| 64 | #pod | ||||||||||||||||||||||||||||||||||||
| 65 | #pod =cut | ||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||
| 67 | 13 | has main_module => ( | |||||||||||||||||||||||||||||||||||
| 68 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||
| 69 | is => 'rw', | ||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||
| 72 | #pod =attr static_attribution | ||||||||||||||||||||||||||||||||||||
| 73 | #pod | ||||||||||||||||||||||||||||||||||||
| 74 | #pod This option omits the version number in the "generated by" | ||||||||||||||||||||||||||||||||||||
| 75 | #pod comment in the Makefile.PL. For setups that copy the Makefile.PL | ||||||||||||||||||||||||||||||||||||
| 76 | #pod back to the repo, this avoids churn just from upgrading Dist::Zilla. | ||||||||||||||||||||||||||||||||||||
| 77 | #pod | ||||||||||||||||||||||||||||||||||||
| 78 | #pod =cut | ||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||
| 80 | 13 | has 'static_attribution' => ( | |||||||||||||||||||||||||||||||||||
| 81 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||
| 82 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||
| 85 | has '_runner' => ( | ||||||||||||||||||||||||||||||||||||
| 86 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 87 | lazy => 1, | ||||||||||||||||||||||||||||||||||||
| 88 | handles => [qw(build test)], | ||||||||||||||||||||||||||||||||||||
| 89 | 2 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 90 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||
| 91 | 2 | Dist::Zilla::Plugin::MakeMaker::Runner->new({ | |||||||||||||||||||||||||||||||||||
| 92 | zilla => $self->zilla, | ||||||||||||||||||||||||||||||||||||
| 93 | plugin_name => $self->plugin_name . '::Runner', | ||||||||||||||||||||||||||||||||||||
| 94 | make_path => $self->make_path, | ||||||||||||||||||||||||||||||||||||
| 95 | default_jobs => $self->default_jobs, | ||||||||||||||||||||||||||||||||||||
| 96 | }); | ||||||||||||||||||||||||||||||||||||
| 97 | }, | ||||||||||||||||||||||||||||||||||||
| 98 | 13 | ); | |||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||
| 100 | # This is here, rather than at the top, so that the "build" and "test" methods | ||||||||||||||||||||||||||||||||||||
| 101 | # will exist, as they are required by BuildRunner and TestRunner respectively. | ||||||||||||||||||||||||||||||||||||
| 102 | # I had originally fixed this with stub methods, but stub methods do not behave | ||||||||||||||||||||||||||||||||||||
| 103 | # properly with this use case until Moose 2.0300. -- rjbs, 2012-02-08 | ||||||||||||||||||||||||||||||||||||
| 104 | 13 | with qw( | |||||||||||||||||||||||||||||||||||
| 105 | Dist::Zilla::Role::BuildRunner | ||||||||||||||||||||||||||||||||||||
| 106 | Dist::Zilla::Role::InstallTool | ||||||||||||||||||||||||||||||||||||
| 107 | Dist::Zilla::Role::PrereqSource | ||||||||||||||||||||||||||||||||||||
| 108 | Dist::Zilla::Role::FileGatherer | ||||||||||||||||||||||||||||||||||||
| 109 | Dist::Zilla::Role::TestRunner | ||||||||||||||||||||||||||||||||||||
| 110 | Dist::Zilla::Role::TextTemplate | ||||||||||||||||||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||
| 113 | 13 | my $template = q!# This file was automatically generated by {{ $generated_by }} | |||||||||||||||||||||||||||||||||||
| 114 | use strict; | ||||||||||||||||||||||||||||||||||||
| 115 | use warnings; | ||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||
| 117 | {{ $perl_prereq ? qq[use $perl_prereq;] : ''; }} | ||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||
| 119 | use ExtUtils::MakeMaker{{ defined $eumm_version && 0+$eumm_version ? ' ' . $eumm_version : '' }}; | ||||||||||||||||||||||||||||||||||||
| 120 | {{ $share_dir_code{preamble} || '' }} | ||||||||||||||||||||||||||||||||||||
| 121 | my {{ $WriteMakefileArgs }} | ||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||
| 123 | my {{ $fallback_prereqs }} | ||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||
| 125 | unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { | ||||||||||||||||||||||||||||||||||||
| 126 | delete $WriteMakefileArgs{TEST_REQUIRES}; | ||||||||||||||||||||||||||||||||||||
| 127 | delete $WriteMakefileArgs{BUILD_REQUIRES}; | ||||||||||||||||||||||||||||||||||||
| 128 | $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; | ||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||
| 131 | delete $WriteMakefileArgs{CONFIGURE_REQUIRES} | ||||||||||||||||||||||||||||||||||||
| 132 | unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; | ||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||
| 134 | WriteMakefile(%WriteMakefileArgs); | ||||||||||||||||||||||||||||||||||||
| 135 | {{ $share_dir_code{postamble} || '' }}!; | ||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||
| 137 | 29 | ▶ | sub register_prereqs { | ||||||||||||||||||||||||||||||||||
|
Subroutine
register_prereqs: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 138 | 29 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||
| 140 | 29 | ▶ | $self->zilla->register_prereqs( | ||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->eumm_version || 0
MC/DC100%1/1
$self->eumm_version || 0
$self->eumm_version
Truth table100%2/2
A
A= $self->eumm_version
| |||||||||||||||||||||||||||||||||||||
| 141 | { phase => 'configure' }, | ||||||||||||||||||||||||||||||||||||
| 142 | 'ExtUtils::MakeMaker' => $self->eumm_version || 0, | ||||||||||||||||||||||||||||||||||||
| 143 | ); | ||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||
| 145 | 29 | ▶ | return unless keys %{ $self->zilla->_share_dir_map }; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||
| 147 | 4 | $self->zilla->register_prereqs( | |||||||||||||||||||||||||||||||||||
| 148 | { phase => 'configure' }, | ||||||||||||||||||||||||||||||||||||
| 149 | 'File::ShareDir::Install' => 0.06, | ||||||||||||||||||||||||||||||||||||
| 150 | ); | ||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||
| 153 | 29 | ▶ | sub gather_files { | ||||||||||||||||||||||||||||||||||
|
Subroutine
gather_files: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 154 | 29 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||
| 156 | 29 | require Dist::Zilla::File::InMemory; | |||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||
| 158 | 29 | my $file = Dist::Zilla::File::InMemory->new({ | |||||||||||||||||||||||||||||||||||
| 159 | name => 'Makefile.PL', | ||||||||||||||||||||||||||||||||||||
| 160 | content => $template, # template evaluated later | ||||||||||||||||||||||||||||||||||||
| 161 | }); | ||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||
| 163 | 29 | $self->add_file($file); | |||||||||||||||||||||||||||||||||||
| 164 | 29 | return; | |||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||
| 167 | 28 | ▶ | sub share_dir_code { | ||||||||||||||||||||||||||||||||||
|
Subroutine
share_dir_code: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 168 | 28 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||
| 170 | 28 | my $share_dir_code = {}; | |||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||
| 172 | 28 | my $share_dir_map = $self->zilla->_share_dir_map; | |||||||||||||||||||||||||||||||||||
| 173 | 28 | ▶ | if ( keys %$share_dir_map ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 174 | 4 | my $preamble = <<'PREAMBLE'; | |||||||||||||||||||||||||||||||||||
| 175 | use File::ShareDir::Install; | ||||||||||||||||||||||||||||||||||||
| 176 | $File::ShareDir::Install::INCLUDE_DOTFILES = 1; | ||||||||||||||||||||||||||||||||||||
| 177 | $File::ShareDir::Install::INCLUDE_DOTDIRS = 1; | ||||||||||||||||||||||||||||||||||||
| 178 | PREAMBLE | ||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||
| 180 | 4 | ▶ | if ( my $dist_share_dir = $share_dir_map->{dist} ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 181 | 2 | $dist_share_dir = quotemeta $dist_share_dir; | |||||||||||||||||||||||||||||||||||
| 182 | 2 | $preamble .= qq{install_share dist => "$dist_share_dir";\n}; | |||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||
| 185 | 4 | ▶ | if ( my $mod_map = $share_dir_map->{module} ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 186 | 3 | for my $mod ( keys %$mod_map ) { | |||||||||||||||||||||||||||||||||||
| 187 | 5 | my $mod_share_dir = quotemeta $mod_map->{$mod}; | |||||||||||||||||||||||||||||||||||
| 188 | 5 | $preamble .= qq{install_share module => "$mod", "$mod_share_dir";\n}; | |||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||
| 192 | 4 | $share_dir_code->{preamble} = "\n" . $preamble . "\n"; | |||||||||||||||||||||||||||||||||||
| 193 | $share_dir_code->{postamble} | ||||||||||||||||||||||||||||||||||||
| 194 | 4 | = qq{\n\{\npackage\nMY;\nuse File::ShareDir::Install qw(postamble);\n\}\n}; | |||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||
| 197 | 28 | return $share_dir_code; | |||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||
| 200 | 29 | ▶ | sub write_makefile_args { | ||||||||||||||||||||||||||||||||||
|
Subroutine
write_makefile_args: called CC=15 SCAR=27.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 201 | 29 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||
| 203 | 29 | ▶ | my $name = $self->main_module || ($self->zilla->name =~ s/-/::/gr); | ||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->main_module || $self->zilla->name =~ s/-/::/gru
MC/DC0%0/2
$self->main_module || $self->zilla->name =~ s/-/::/gru
$self->main_module
$self->zilla->name =~ s/-/::/gru
Truth table66%2/3
A || B
A= $self->main_moduleB= $self->zilla->name =~ s/-/::/gru
| |||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||
| 205 | 1 | my @exe_files = map { $_->name } | |||||||||||||||||||||||||||||||||||
| 206 | 29 | @{ $self->zilla->find_files(':ExecFiles') }; | |||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||
| 208 | $self->log_fatal("can't install files with whitespace in their names") | ||||||||||||||||||||||||||||||||||||
| 209 | 29 | ▶ | if grep { /\s/ } @exe_files; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||
| 211 | 29 | my %test_dirs; | |||||||||||||||||||||||||||||||||||
| 212 | 29 | for my $file (@{ $self->zilla->files }) { | |||||||||||||||||||||||||||||||||||
| 213 | 177 | ▶ | next unless $file->name =~ m{\At/.+\.t\z}; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 214 | 37 | my $dir = $file->name =~ s{/[^/]+\.t\z}{/*.t}gr; | |||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||
| 216 | 37 | $test_dirs{ $dir } = 1; | |||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||
| 219 | 29 | my $prereqs = $self->zilla->prereqs; | |||||||||||||||||||||||||||||||||||
| 220 | my $perl_prereq = $prereqs->requirements_for(qw(runtime requires)) | ||||||||||||||||||||||||||||||||||||
| 221 | ->clone | ||||||||||||||||||||||||||||||||||||
| 222 | ->add_requirements($prereqs->requirements_for(qw(configure requires))) | ||||||||||||||||||||||||||||||||||||
| 223 | ->add_requirements($prereqs->requirements_for(qw(build requires))) | ||||||||||||||||||||||||||||||||||||
| 224 | ->add_requirements($prereqs->requirements_for(qw(test requires))) | ||||||||||||||||||||||||||||||||||||
| 225 | 29 | ->as_string_hash->{perl}; | |||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||
| 227 | 29 | ▶ | $perl_prereq = version->parse($perl_prereq)->numify if $perl_prereq; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||
| 229 | 116 | ▶ | my $prereqs_dump = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 230 | 116 | $self->_normalize_eumm_versions( | |||||||||||||||||||||||||||||||||||
| 231 | $prereqs->requirements_for(@_) | ||||||||||||||||||||||||||||||||||||
| 232 | ->clone | ||||||||||||||||||||||||||||||||||||
| 233 | ->clear_requirement('perl') | ||||||||||||||||||||||||||||||||||||
| 234 | ->as_string_hash | ||||||||||||||||||||||||||||||||||||
| 235 | ); | ||||||||||||||||||||||||||||||||||||
| 236 | 29 | }; | |||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||
| 238 | my %require_prereqs = map { | ||||||||||||||||||||||||||||||||||||
| 239 | 29 | $_ => $prereqs_dump->($_, 'requires'); | |||||||||||||||||||||||||||||||||||
| 240 | } qw(configure build test runtime); | ||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||
| 242 | # EUMM may soon be able to support this, but until we decide to inject a | ||||||||||||||||||||||||||||||||||||
| 243 | # higher configure-requires version, we should at least warn the user | ||||||||||||||||||||||||||||||||||||
| 244 | # https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker/issues/215 | ||||||||||||||||||||||||||||||||||||
| 245 | 29 | foreach my $phase (qw(configure build test runtime)) { | |||||||||||||||||||||||||||||||||||
| 246 | 116 | ▶ | if (my @version_ranges = pairgrep { defined($b) && !version::is_lax($b) } %{ $require_prereqs{$phase} } | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 2 branches
Condition100%5/5
my(@version_ranges) = &pairgrep(sub {
defined $b and not version::is_lax($b);
}
, %{$require_prereqs{$phase};}) and ($self->eumm_version || 0) < "7.1101"
$self->eumm_version || 0
MC/DC100%2/2
my(@version_ranges) = &pairgrep(sub {
defined $b and not version::is_lax($b);
}
, %{$require_prereqs{$phase};}) and ($self->eumm_version || 0) < "7.1101"
my(@version_ranges) = &pairgrep(sub {
defined $b and not version::is_lax($b);
}
, %{$require_prereqs{$phase};})
$self->eumm_version
Truth table100%3/3
A and B
A= my(@version_ranges) = &pairgrep(sub {
defined $b and not version::is_lax($b);
}
, %{$require_prereqs{$phase};})B= $self->eumm_version
| |||||||||||||||||||||||||||||||||||||
| 247 | and ($self->eumm_version || 0) < '7.1101') { | ||||||||||||||||||||||||||||||||||||
| 248 | $self->log_fatal([ | ||||||||||||||||||||||||||||||||||||
| 249 | 'found version range in %s prerequisites, which ExtUtils::MakeMaker cannot parse (must specify eumm_version of at least 7.1101): %s %s', | ||||||||||||||||||||||||||||||||||||
| 250 | $phase, $_->[0], $_->[1] | ||||||||||||||||||||||||||||||||||||
| 251 | 1 | ]) foreach pairs @version_ranges; | |||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||
| 255 | my %write_makefile_args = ( | ||||||||||||||||||||||||||||||||||||
| 256 | DISTNAME => $self->zilla->name, | ||||||||||||||||||||||||||||||||||||
| 257 | NAME => $name, | ||||||||||||||||||||||||||||||||||||
| 258 | 28 | ▶ | AUTHOR => join(q{, }, @{ $self->zilla->authors }), | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 259 | ABSTRACT => $self->zilla->abstract, | ||||||||||||||||||||||||||||||||||||
| 260 | VERSION => $self->zilla->version, | ||||||||||||||||||||||||||||||||||||
| 261 | LICENSE => $self->zilla->license->meta_yml_name, | ||||||||||||||||||||||||||||||||||||
| 262 | @exe_files ? ( EXE_FILES => [ sort @exe_files ] ) : (), | ||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||
| 264 | CONFIGURE_REQUIRES => $require_prereqs{configure}, | ||||||||||||||||||||||||||||||||||||
| 265 | 28 | ▶ | keys %{ $require_prereqs{build} } ? ( BUILD_REQUIRES => $require_prereqs{build} ) : (), | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 266 | 28 | keys %{ $require_prereqs{test} } ? ( TEST_REQUIRES => $require_prereqs{test} ) : (), | |||||||||||||||||||||||||||||||||||
| 267 | PREREQ_PM => $require_prereqs{runtime}, | ||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||
| 269 | 28 | test => { TESTS => join q{ }, sort keys %test_dirs }, | |||||||||||||||||||||||||||||||||||
| 270 | ); | ||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||
| 272 | 28 | ▶ | $write_makefile_args{MIN_PERL_VERSION} = $perl_prereq if $perl_prereq; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||
| 274 | 28 | return \%write_makefile_args; | |||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||
| 277 | 144 | ▶ | sub _normalize_eumm_versions { | ||||||||||||||||||||||||||||||||||
|
Subroutine
_normalize_eumm_versions: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||
| 278 | 144 | my ($self, $prereqs) = @_; | |||||||||||||||||||||||||||||||||||
| 279 | 144 | for my $v (values %$prereqs) { | |||||||||||||||||||||||||||||||||||
| 280 | 130 | ▶ | if (version::is_strict($v)) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 281 | 127 | my $version = version->parse($v); | |||||||||||||||||||||||||||||||||||
| 282 | 127 | ▶ | if ($version->is_qv) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 283 | 4 | ▶ | if ((() = $v =~ /\./g) > 1) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 284 | 4 | $v =~ s/^v//; | |||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||
| 286 | else { | ||||||||||||||||||||||||||||||||||||
| 287 | 0 | $v = $version->numify; | |||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||
| 292 | 144 | return $prereqs; | |||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||
| 295 | 56 | ▶ | sub _dump_as { | ||||||||||||||||||||||||||||||||||
|
Subroutine
_dump_as: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 296 | 56 | my ($self, $ref, $name) = @_; | |||||||||||||||||||||||||||||||||||
| 297 | 56 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||
| 298 | 56 | my $dumper = Data::Dumper->new( [ $ref ], [ $name ] ); | |||||||||||||||||||||||||||||||||||
| 299 | 56 | $dumper->Sortkeys( 1 ); | |||||||||||||||||||||||||||||||||||
| 300 | 56 | $dumper->Indent( 1 ); | |||||||||||||||||||||||||||||||||||
| 301 | 56 | $dumper->Useqq( 1 ); | |||||||||||||||||||||||||||||||||||
| 302 | 56 | return $dumper->Dump; | |||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||
| 305 | 28 | ▶ | sub fallback_prereq_pm { | ||||||||||||||||||||||||||||||||||
|
Subroutine
fallback_prereq_pm: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 306 | 28 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 307 | 28 | my $fallback | |||||||||||||||||||||||||||||||||||
| 308 | = $self->_normalize_eumm_versions( | ||||||||||||||||||||||||||||||||||||
| 309 | $self->zilla->prereqs->merged_requires | ||||||||||||||||||||||||||||||||||||
| 310 | ->clone | ||||||||||||||||||||||||||||||||||||
| 311 | ->clear_requirement('perl') | ||||||||||||||||||||||||||||||||||||
| 312 | ->as_string_hash | ||||||||||||||||||||||||||||||||||||
| 313 | ); | ||||||||||||||||||||||||||||||||||||
| 314 | 28 | return $self->_dump_as( $fallback, '*FallbackPrereqs' ); | |||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||
| 317 | 29 | ▶ | sub setup_installer { | ||||||||||||||||||||||||||||||||||
|
Subroutine
setup_installer: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 318 | 29 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||
| 320 | 29 | my $write_makefile_args = $self->write_makefile_args; | |||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||
| 322 | 28 | $self->__write_makefile_args($write_makefile_args); # save for testing | |||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||
| 324 | 28 | my $perl_prereq = $write_makefile_args->{MIN_PERL_VERSION}; | |||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||
| 326 | 28 | my $dumped_args = $self->_dump_as($write_makefile_args, '*WriteMakefileArgs'); | |||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||
| 328 | 28 | ▶ | my $file = first { $_->name eq 'Makefile.PL' } @{$self->zilla->files}; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||
| 330 | 28 | $self->log_debug([ 'updating contents of Makefile.PL in memory' ]); | |||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||
| 332 | 28 | ▶ | my $attribution = $self->static_attribution | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->VERSION || '(dev)'
MC/DC0%0/1
$self->VERSION || '(dev)'
$self->VERSION
Truth table50%1/2
A
A= $self->VERSION
| |||||||||||||||||||||||||||||||||||||
| 333 | ? ref($self) | ||||||||||||||||||||||||||||||||||||
| 334 | : sprintf("%s v%s", ref($self), $self->VERSION || '(dev)'); | ||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||
| 336 | 28 | my $content = $self->fill_in_string( | |||||||||||||||||||||||||||||||||||
| 337 | $file->content, | ||||||||||||||||||||||||||||||||||||
| 338 | { | ||||||||||||||||||||||||||||||||||||
| 339 | eumm_version => \($self->eumm_version), | ||||||||||||||||||||||||||||||||||||
| 340 | perl_prereq => \$perl_prereq, | ||||||||||||||||||||||||||||||||||||
| 341 | share_dir_code => $self->share_dir_code, | ||||||||||||||||||||||||||||||||||||
| 342 | fallback_prereqs => \($self->fallback_prereq_pm), | ||||||||||||||||||||||||||||||||||||
| 343 | WriteMakefileArgs => \$dumped_args, | ||||||||||||||||||||||||||||||||||||
| 344 | generated_by => \$attribution, | ||||||||||||||||||||||||||||||||||||
| 345 | }, | ||||||||||||||||||||||||||||||||||||
| 346 | ); | ||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||
| 348 | 28 | $file->content($content); | |||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||
| 350 | 28 | return; | |||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||
| 353 | # XXX: Just here to facilitate testing. -- rjbs, 2010-03-20 | ||||||||||||||||||||||||||||||||||||
| 354 | 13 | has __write_makefile_args => ( | |||||||||||||||||||||||||||||||||||
| 355 | is => 'rw', | ||||||||||||||||||||||||||||||||||||
| 356 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||
| 357 | ); | ||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||
| 359 | 13 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||
| 360 | 13 | 1; | |||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||
| 362 | #pod =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||
| 363 | #pod | ||||||||||||||||||||||||||||||||||||
| 364 | #pod Core Dist::Zilla plugins: | ||||||||||||||||||||||||||||||||||||
| 365 | #pod L<@Basic|Dist::Zilla::PluginBundle::Basic>, | ||||||||||||||||||||||||||||||||||||
| 366 | #pod L<ModuleBuild|Dist::Zilla::Plugin::ModuleBuild>, | ||||||||||||||||||||||||||||||||||||
| 367 | #pod L<Manifest|Dist::Zilla::Plugin::Manifest>. | ||||||||||||||||||||||||||||||||||||
| 368 | #pod | ||||||||||||||||||||||||||||||||||||
| 369 | #pod Dist::Zilla roles: | ||||||||||||||||||||||||||||||||||||
| 370 | #pod L<BuildRunner|Dist::Zilla::Role::FileGatherer>, | ||||||||||||||||||||||||||||||||||||
| 371 | #pod L<InstallTool|Dist::Zilla::Role::InstallTool>, | ||||||||||||||||||||||||||||||||||||
| 372 | #pod L<PrereqSource|Dist::Zilla::Role::PrereqSource>, | ||||||||||||||||||||||||||||||||||||
| 373 | #pod L<TestRunner|Dist::Zilla::Role::TestRunner>. | ||||||||||||||||||||||||||||||||||||
| 374 | #pod | ||||||||||||||||||||||||||||||||||||
| 375 | #pod =cut | ||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||
| 377 | __END__ | ||||||||||||||||||||||||||||||||||||