Skip to content

Commit c622331

Browse files
committed
Breakup MakeMaker->new: extract_CONFIGURE method
1 parent 7fe377d commit c622331

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

lib/ExtUtils/MakeMaker.pm

+16-15
Original file line numberDiff line numberDiff line change
@@ -437,21 +437,8 @@ sub new {
437437
$self->extract_hints;
438438

439439
$self->check_min_perl_version;
440-
441-
my %configure_att; # record &{$self->{CONFIGURE}} attributes
442-
my(%initial_att) = %$self; # record initial attributes
443-
444440
my $unsatisfied_prereqs = $self->check_prereqs($cmrstash);
445-
446-
if (defined $self->{CONFIGURE}) {
447-
if (ref $self->{CONFIGURE} eq 'CODE') {
448-
%configure_att = %{&{$self->{CONFIGURE}}};
449-
_convert_compat_attrs(\%configure_att);
450-
%$self = (%$self, %configure_att);
451-
} else {
452-
croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
453-
}
454-
}
441+
my ($initial_att, $configure_att) = $self->extract_CONFIGURE;
455442

456443
local @Parent = @Parent; # Protect against non-local exits
457444
$self->extract_PARENT;
@@ -482,12 +469,26 @@ END
482469
File::Spec->catfile($Config{'archlibexp'}, "Config.pm")
483470
);
484471

485-
$self->makefile_preamble(\@ARGV, \%initial_att, \%configure_att);
472+
$self->makefile_preamble(\@ARGV, $initial_att, $configure_att);
486473
$self->generate_makefile;
487474

488475
$self;
489476
}
490477

478+
sub extract_CONFIGURE {
479+
my ($self) = @_;
480+
my %initial_att = %$self; # record initial attributes
481+
my %configure_att; # record &{$self->{CONFIGURE}} attributes
482+
if (defined $self->{CONFIGURE}) {
483+
croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n"
484+
unless ref $self->{CONFIGURE} eq 'CODE';
485+
%configure_att = %{&{$self->{CONFIGURE}}};
486+
_convert_compat_attrs(\%configure_att);
487+
while (my ($k, $v) = each %configure_att) { $self->{$k} = $v }
488+
}
489+
(\%initial_att, \%configure_att);
490+
}
491+
491492
sub makefile_preamble {
492493
my ($self, $argvref, $initial_att, $configure_att) = @_;
493494
my ($argv) = neatvalue($argvref);

0 commit comments

Comments
 (0)