diff options
author | Ed J <mohawk2@users.noreply.github.com> | 2015-01-19 00:17:31 +0000 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2016-01-25 11:11:46 +1100 |
commit | 273df2b1892ae130ffc042e07ffa9c25a0a75605 (patch) | |
tree | 03cc9a934de66186b0214d10c79936287f36447c /cpan | |
parent | 2641c7ef11e829d033673670fd5d79477f86982a (diff) | |
download | perl-273df2b1892ae130ffc042e07ffa9c25a0a75605.tar.gz |
Cache is_make_type
Diffstat (limited to 'cpan')
-rw-r--r-- | cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Any.pm | 19 | ||||
-rw-r--r-- | cpan/ExtUtils-MakeMaker/t/cd.t | 2 |
2 files changed, 16 insertions, 5 deletions
diff --git a/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Any.pm b/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Any.pm index 570ea7203a..154f784653 100644 --- a/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Any.pm +++ b/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Any.pm @@ -202,19 +202,28 @@ Returns true if C<<$self->make>> is the given type; possibilities are: =cut +my %maketype2true; +# undocumented - so t/cd.t can still do its thing +sub _clear_maketype_cache { %maketype2true = () } + sub is_make_type { my($self, $type) = @_; + return $maketype2true{$type} if defined $maketype2true{$type}; (undef, undef, my $make_basename) = $self->splitpath($self->make); - return 1 if $make_basename =~ /\b$type\b/i; # executable's filename - return 0 if $make_basename =~ /\b(dmake|nmake)\b/i; # Never fall through for dmake/nmake + return $maketype2true{$type} = 1 + if $make_basename =~ /\b$type\b/i; # executable's filename + return $maketype2true{$type} = 0 + if $make_basename =~ /\b(dmake|nmake|gmake)\b/i; # Never fall through for dmake/nmake/gmake # now have to run with "-v" and guess my $redirect = $self->can_redirect_error ? '2>&1' : ''; my $make = $self->make || $self->{MAKE}; my $minus_v = `"$make" -v $redirect`; - return 1 if $type eq 'gmake' and $minus_v =~ /GNU make/i; - return 1 if $type eq 'bsdmake' + return $maketype2true{$type} = 1 + if $type eq 'gmake' and $minus_v =~ /GNU make/i; + return $maketype2true{$type} = 1 + if $type eq 'bsdmake' and $minus_v =~ /^usage: make \[-BeikNnqrstWwX\]/im; - 0; # it wasn't whatever you asked + $maketype2true{$type} = 0; # it wasn't whatever you asked } diff --git a/cpan/ExtUtils-MakeMaker/t/cd.t b/cpan/ExtUtils-MakeMaker/t/cd.t index 16f66679e4..67dfd9839e 100644 --- a/cpan/ExtUtils-MakeMaker/t/cd.t +++ b/cpan/ExtUtils-MakeMaker/t/cd.t @@ -26,6 +26,7 @@ my @cd_args = ($dir, "command1", "command2"); { local *make = sub { "nmake" }; + $mm->_clear_maketype_cache; my @dirs = (File::Spec->updir) x 2; my $expected_updir = File::Spec->catdir(@dirs); @@ -39,6 +40,7 @@ qq{cd $dir { local *make = sub { "dmake" }; + $mm->_clear_maketype_cache; ::is $mm->cd(@cd_args), qq{cd $dir && command1 |