[Module::Build] Re: Module::Build 0.27_09 -> CPAN
Status: Beta
Brought to you by:
kwilliams
|
From: Ken W. <ke...@ma...> - 2006-03-14 23:50:30
|
Hi Randy,
I think the find_perl_interpreter() and perl_is_same() methods are
getting uglier and uglier (i.e. they're getting more special-casing),
which is just fine as long as they work, but I think I'm going to
want to clean them up at some point. Which means we need to have
tests that will exercise the various cases we're covering, or else
I'll probably break something.
I know that's going to pretty hard to do, but maybe a first step
would be just to list the specific cases we indeed cover, right in
the corresponding code.
I say go ahead and check this in to fix breakage, and let's try to
fairly quickly (before we forget) add those comments.
-Ken
On Mar 14, 2006, at 5:04 AM, Randy W. Sims wrote:
> Attached are my final suggested patches for MB & EUCB.
>
> Note that I've restricted the search for the perl interpreter so
> that it does not search in the PATH if PERL_CORE is set as I
> believe this is more correct. In practice this has no effect on any
> system I've tested on because we always find it where we expect now.
>
> Also, find_perl_interpreter now throws an exception if it fails.
>
> If this is sensible I can check it in and generate a patch for blead.
>
> Randy.
> Index: lib/ExtUtils/CBuilder/Base.pm
> ===================================================================
> RCS file: /cvsroot/module-build/ExtUtils-CBuilder/lib/ExtUtils/
> CBuilder/Base.pm,v
> retrieving revision 1.19
> diff -u -r1.19 Base.pm
> --- lib/ExtUtils/CBuilder/Base.pm 3 Oct 2005 22:05:14 -0000 1.19
> +++ lib/ExtUtils/CBuilder/Base.pm 14 Mar 2006 10:51:19 -0000
> @@ -240,11 +240,11 @@
>
> return unless $ENV{PERL_CORE};
>
> - my $Updir = File::Spec->updir;
> - my $dir = $Updir;
> + my $Updir = File::Spec->updir;
> + my $dir = File::Spec->curdir;
>
> # Try up to 5 levels upwards
> - for (1..5) {
> + for (0..5) {
> if (
> -f File::Spec->catfile($dir,"config_h.SH")
> &&
> @@ -257,9 +257,9 @@
>
> $dir = File::Spec->catdir($dir, $Updir);
> }
> -
> +
> warn "PERL_CORE is set but I can't find your perl source!\n";
> - return;
> + return ''; # return empty string if $ENV{PERL_CORE} but can't
> find dir ???
> }
>
> # directory of perl's include files
> Index: lib/Module/Build/Base.pm
> ===================================================================
> RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/
> Base.pm,v
> retrieving revision 1.558
> diff -u -r1.558 Base.pm
> --- lib/Module/Build/Base.pm 11 Mar 2006 03:06:20 -0000 1.558
> +++ lib/Module/Build/Base.pm 14 Mar 2006 10:50:37 -0000
> @@ -12,7 +12,6 @@
> use Data::Dumper ();
> use IO::File ();
> use Text::ParseWords ();
> -use Carp ();
>
> use Module::Build::ModuleInfo;
> use Module::Build::Notes;
> @@ -317,37 +316,67 @@
>
> sub _perl_is_same {
> my ($self, $perl) = @_;
> - return `$perl -MConfig=myconfig -e print -e myconfig` eq Config-
> >myconfig;
> +
> + my $INC = '';
> + if ($ENV{PERL_CORE}) {
> + $INC = '-I' . File::Spec->catdir(File::Basename::dirname
> ($perl), 'lib');
> + }
> +
> + return `$perl $INC -MConfig=myconfig -e print -e myconfig` eq
> Config->myconfig;
> }
>
> sub find_perl_interpreter {
> - return $^X if File::Spec->file_name_is_absolute($^X);
> my $proto = shift;
> - my $c = ref($proto) ? $proto->config : \%Config::Config;
> - my $exe = $c->{exe_ext};
> + my $c = ref($proto) ? $proto->config : \%Config::Config;
>
> - my $thisperl = $^X;
> - if ($proto->os_type eq 'VMS') {
> - # VMS might have a file version at the end
> - $thisperl .= $exe unless $thisperl =~ m/$exe(;\d+)?$/i;
> - } elsif (defined $exe) {
> - $thisperl .= $exe unless $thisperl =~ m/$exe$/i;
> - }
> + my @potential_perls;
> +
> + my $perl = $^X;
> + push( @potential_perls, $perl )
> + if File::Spec->file_name_is_absolute($perl);
> +
> + my $abs_perl = File::Spec->rel2abs($perl);
> + push( @potential_perls, $abs_perl );
> +
> + my $perl_basename = File::Basename::basename($perl);
>
> - my $uninstperl;
> if ($ENV{PERL_CORE}) {
> +
> # CBuilder is also in the core, so it should be available here
> require ExtUtils::CBuilder;
> - $uninstperl = File::Spec->catfile(ExtUtils::CBuilder::-
> >perl_src, $thisperl);
> + my $perl_src = ExtUtils::CBuilder->perl_src;
> + if ( defined($perl_src) && length($perl_src) ) {
> + my $uninstperl =
> + File::Spec->rel2abs(File::Spec->catfile( $perl_src,
> $perl_basename ));
> + push( @potential_perls, $uninstperl );
> + }
> +
> + } else {
> +
> + push( @potential_perls, $c->{perlpath} );
> +
> + push( @potential_perls,
> + map File::Spec->catfile($_, $perl_basename), File::Spec-
> >path() );
> }
>
> - foreach my $perl ( $uninstperl || (),
> - $c->{perlpath},
> - map File::Spec->catfile($_, $thisperl), File::Spec->path()
> - ) {
> - return $perl if -f $perl and $proto->_perl_is_same($perl);
> + my $exe = $c->{exe_ext};
> + foreach my $thisperl ( @potential_perls ) {
> +
> + if ($proto->os_type eq 'VMS') {
> + # VMS might have a file version at the end
> + $thisperl .= $exe unless $thisperl =~ m/$exe(;\d+)?$/i;
> + } elsif (defined $exe) {
> + $thisperl .= $exe unless $thisperl =~ m/$exe$/i;
> + }
> +
> + if ( -f $thisperl && $proto->_perl_is_same($thisperl) ) {
> + return $thisperl;
> + }
> }
> - return;
> +
> + my @paths = map File::Basename::dirname($_), @potential_perls;
> + die "Can't locate the perl binary used to run this script " .
> + "in (@paths)\n";
> }
>
> sub _is_interactive {
> @@ -1235,8 +1264,7 @@
> use $build_package;
>
> # Some platforms have problems setting \$^X in shebang contexts,
> fix it up here
> -\$^X = Module::Build->find_perl_interpreter
> - unless File::Spec->file_name_is_absolute(\$^X);
> +\$^X = Module::Build->find_perl_interpreter;
>
> if (-e 'Build.PL' and not $build_package->up_to_date('Build.PL', \
> $progname)) {
> warn "Warning: Build.PL has been altered. You may need to run
> 'perl Build.PL' again.\\n";
|