Skip to content

Commit 52dd573

Browse files
committed
Breakup MakeMaker->new: extract_CONFIGURE method
1 parent 8c25b07 commit 52dd573

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

lib/ExtUtils/MakeMaker.pm

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -448,21 +448,8 @@ sub new {
448448
$self->extract_hints;
449449

450450
$self->check_min_perl_version;
451-
452-
my %configure_att; # record &{$self->{CONFIGURE}} attributes
453-
my(%initial_att) = %$self; # record initial attributes
454-
455451
my $unsatisfied_prereqs = $self->check_prereqs($cmrstash);
456-
457-
if (defined $self->{CONFIGURE}) {
458-
if (ref $self->{CONFIGURE} eq 'CODE') {
459-
%configure_att = %{&{$self->{CONFIGURE}}};
460-
_convert_compat_attrs(\%configure_att);
461-
%$self = (%$self, %configure_att);
462-
} else {
463-
croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
464-
}
465-
}
452+
my ($initial_att, $configure_att) = $self->extract_CONFIGURE;
466453

467454
local @Parent = @Parent; # Protect against non-local exits
468455
$self->extract_PARENT;
@@ -493,12 +480,26 @@ END
493480
File::Spec->catfile($Config{'archlibexp'}, "Config.pm")
494481
);
495482

496-
$self->makefile_preamble(\@ARGV, \%initial_att, \%configure_att);
483+
$self->makefile_preamble(\@ARGV, $initial_att, $configure_att);
497484
$self->generate_makefile;
498485

499486
$self;
500487
}
501488

489+
sub extract_CONFIGURE {
490+
my ($self) = @_;
491+
my %initial_att = %$self; # record initial attributes
492+
my %configure_att; # record &{$self->{CONFIGURE}} attributes
493+
if (defined $self->{CONFIGURE}) {
494+
croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n"
495+
unless ref $self->{CONFIGURE} eq 'CODE';
496+
%configure_att = %{&{$self->{CONFIGURE}}};
497+
_convert_compat_attrs(\%configure_att);
498+
while (my ($k, $v) = each %configure_att) { $self->{$k} = $v }
499+
}
500+
(\%initial_att, \%configure_att);
501+
}
502+
502503
sub makefile_preamble {
503504
my ($self, $argvref, $initial_att, $configure_att) = @_;
504505
my ($argv) = neatvalue($argvref);

0 commit comments

Comments
 (0)