Skip to content

Commit d46cc0e

Browse files
haargbingos
authored andcommitted
initialize PERL_CORE object var early and use it consistently
The PERL_CORE environment variable is used when building perl core. Some places in the code would check for the environment variable, others would check the PERL_CORE object attribute, and others would check a global initialized based on the environment variable. Move the initialization of the PERL_CORE object attribute to very early in object construction. This allows converting all of the other users of the setting to use the object attribute rather than taking from a variety of sources. This makes overriding the setting work consistently no matter how it is set.
1 parent 758068b commit d46cc0e

File tree

4 files changed

+45
-30
lines changed

4 files changed

+45
-30
lines changed

lib/ExtUtils/MM_Unix.pm

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ sub cflags {
225225
# with the warning flags, but NOT the -std=c89 flags (the latter
226226
# would break using any system header files that are strict C99).
227227
my @ccextraflags = qw(ccwarnflags);
228-
if ($ENV{PERL_CORE}) {
228+
if ($self->{PERL_CORE}) {
229229
for my $x (@ccextraflags) {
230230
if (exists $Config{$x}) {
231231
$cflags{$x} = $Config{$x};
@@ -1748,13 +1748,47 @@ sub init_DIRFILESEP {
17481748
}
17491749

17501750

1751+
=item init_CORE
1752+
1753+
Initializes PERL_CORE and PERL_SRC.
1754+
1755+
=cut
1756+
1757+
sub init_CORE {
1758+
my ($self) = @_;
1759+
1760+
# Are we building the core?
1761+
$self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
1762+
$self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
1763+
1764+
unless ($self->{PERL_SRC}){
1765+
foreach my $dir_count (1..8) { # 8 is the VMS limit for nesting
1766+
my $dir = $self->catdir(($Updir) x $dir_count);
1767+
1768+
if (-f $self->catfile($dir,"config_h.SH") &&
1769+
-f $self->catfile($dir,"perl.h") &&
1770+
-f $self->catfile($dir,"lib","strict.pm")
1771+
) {
1772+
$self->{PERL_SRC} = $dir ;
1773+
last;
1774+
}
1775+
}
1776+
}
1777+
1778+
warn "PERL_CORE is set but I can't find your PERL_SRC!\n"
1779+
if $self->{PERL_CORE} and !$self->{PERL_SRC};
1780+
1781+
return;
1782+
}
1783+
1784+
17511785
=item init_main
17521786
17531787
Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE,
17541788
EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*,
17551789
INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
17561790
OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB,
1757-
PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION,
1791+
PERLRUN, PERLRUNINST, PREFIX, VERSION,
17581792
VERSION_SYM, XS_VERSION.
17591793
17601794
=cut
@@ -1805,23 +1839,6 @@ sub init_main {
18051839
my $inc_config_dir = dirname($INC{'Config.pm'});
18061840
my $inc_carp_dir = dirname($INC{'Carp.pm'});
18071841

1808-
unless ($self->{PERL_SRC}){
1809-
foreach my $dir_count (1..8) { # 8 is the VMS limit for nesting
1810-
my $dir = $self->catdir(($Updir) x $dir_count);
1811-
1812-
if (-f $self->catfile($dir,"config_h.SH") &&
1813-
-f $self->catfile($dir,"perl.h") &&
1814-
-f $self->catfile($dir,"lib","strict.pm")
1815-
) {
1816-
$self->{PERL_SRC}=$dir ;
1817-
last;
1818-
}
1819-
}
1820-
}
1821-
1822-
warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
1823-
$self->{PERL_CORE} and !$self->{PERL_SRC};
1824-
18251842
if ($self->{PERL_SRC}){
18261843
$self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
18271844

@@ -2160,10 +2177,6 @@ sub init_PERL {
21602177
# * including any initial directory separator preserves the `file_name_is_absolute` property
21612178
$self->{PERL} =~ s/^"(\S(:\\|:)?)/$1"/ if $self->is_make_type('dmake');
21622179

2163-
# Are we building the core?
2164-
$self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
2165-
$self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
2166-
21672180
# Make sure perl can find itself before it's installed.
21682181
my $lib_paths = $self->{UNINSTALLED_PERL} || $self->{PERL_CORE}
21692182
? ( $self->{PERL_ARCHLIB} && $self->{PERL_LIB} && $self->{PERL_ARCHLIB} ne $self->{PERL_LIB} ) ?

lib/ExtUtils/MakeMaker.pm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ our @EXPORT_OK = qw($VERSION &neatvalue &mkbootstrap &mksymlists
4444
# purged.
4545
my $Is_VMS = $^O eq 'VMS';
4646
my $Is_Win32 = $^O eq 'MSWin32';
47-
our $UNDER_CORE = $ENV{PERL_CORE}; # needs to be our
4847

4948
full_setup();
5049

@@ -450,6 +449,8 @@ sub new {
450449
# object. It will be blessed into a temp package later.
451450
bless $self, "MM";
452451

452+
$self->init_CORE;
453+
453454
# Cleanup all the module requirement bits
454455
my %key2cmr;
455456
for my $key (qw(PREREQ_PM BUILD_REQUIRES CONFIGURE_REQUIRES TEST_REQUIRES)) {
@@ -508,7 +509,7 @@ sub new {
508509
}
509510

510511
print "MakeMaker (v$VERSION)\n" if $Verbose;
511-
if (-f "MANIFEST" && ! -f "Makefile" && ! $UNDER_CORE){
512+
if (-f "MANIFEST" && ! -f "Makefile" && ! $self->{PERL_CORE}){
512513
check_manifest();
513514
}
514515

@@ -617,7 +618,7 @@ END
617618
warn sprintf "Warning: prerequisite %s %s not found.\n",
618619
$prereq, $required_version
619620
unless $self->{PREREQ_FATAL}
620-
or $UNDER_CORE;
621+
or $self->{PERL_CORE};
621622

622623
$unsatisfied{$prereq} = 'not installed';
623624
}
@@ -629,7 +630,7 @@ END
629630
warn sprintf "Warning: prerequisite %s %s not found. We have %s.\n",
630631
$prereq, $required_version, ($pr_version || 'unknown version')
631632
unless $self->{PREREQ_FATAL}
632-
or $UNDER_CORE;
633+
or $self->{PERL_CORE};
633634

634635
$unsatisfied{$prereq} = $required_version || 'unknown version' ;
635636
}
@@ -1200,7 +1201,7 @@ sub mv_all_methods {
12001201
sub skipcheck {
12011202
my($self) = shift;
12021203
my($section) = @_;
1203-
return 'skipped' if $section eq 'metafile' && $UNDER_CORE;
1204+
return 'skipped' if $section eq 'metafile' && $self->{PERL_CORE};
12041205
if ($section eq 'dynamic') {
12051206
print "Warning (non-fatal): Target 'dynamic' depends on targets ",
12061207
"in skipped section 'dynamic_bs'\n"

t/prereq.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
4646
}
4747
$warnings .= join '', @_;
4848
};
49+
4950
# prerequisite warnings are disabled while building the perl core:
50-
local $ExtUtils::MakeMaker::UNDER_CORE = 0;
51+
local $ENV{PERL_CORE} = 0;
5152

5253
WriteMakefile(
5354
NAME => 'Big::Dummy',

t/vstrings.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ sub capture_make {
7272
$warnings .= join '', @_;
7373
};
7474

75-
local $ExtUtils::MakeMaker::UNDER_CORE = 0;
75+
local $ENV{PERL_CORE} = 0;
7676

7777
WriteMakefile(
7878
NAME => 'VString::Test',

0 commit comments

Comments
 (0)