Do not clobber @INC completely in buildcustomize.pl
authorFather Chrysostomos <sprout@cpan.org>
Wed, 4 Dec 2013 13:46:40 +0000 (05:46 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 7 Dec 2013 02:40:46 +0000 (18:40 -0800)
buildcustomize.pl (for miniperl) replaces @INC (usually qw(lib .))
with the whole list of build directories we need followed by
qw(lib .).

runperl from test.pl is such that this:

    runperl(switches => [ "-Irun/flib" ], ...)

turns into:

    /path/to/perl.git/miniperl "-I../lib" -Irun/flib

The end result is that -Irun/flib gets stripped out and clobbered, and
switchM.t fails under minitest.

write_buildcustomize.pl

index 20ac532..3f78264 100644 (file)
@@ -47,7 +47,7 @@ require File::Spec::Functions;
 
 my $inc = join ",\n        ",
     map { "q\0$_\0" }
-    (map {File::Spec::Functions::rel2abs($_)} @toolchain, 'lib'), '.';
+    (map {File::Spec::Functions::rel2abs($_)} @toolchain, 'lib');
 
 open my $fh, '>', $file
     or die "Can't open $file: $!";
@@ -65,9 +65,9 @@ print $fh <<"EOT" or $error = "Can't print to $file: $!";
 #   Any changes made here will be lost!
 
 # We are miniperl, building extensions
-# Reset \@INC completely, adding the directories we need, and removing the
-# installed directories (which we don't need to read, and may confuse us)
-\@INC = ($inc);
+# Replace the first entry of \@INC ("lib") with the list of
+# directories we need.
+splice(\@INC, 0, 1, $inc);
 EOT
 
 if ($error) {