[Bps-public-commit] r18452 - Shipwright/trunk/lib/Shipwright/Util

jesse at bestpractical.com jesse at bestpractical.com
Wed Feb 18 17:51:11 EST 2009


Author: jesse
Date: Wed Feb 18 17:51:10 2009
New Revision: 18452

Modified:
   Shipwright/trunk/lib/Shipwright/Util/CleanINC.pm

Log:
* When a build script calls perl -I, don't strip it from @INC

Modified: Shipwright/trunk/lib/Shipwright/Util/CleanINC.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Util/CleanINC.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Util/CleanINC.pm	Wed Feb 18 17:51:10 2009
@@ -4,14 +4,50 @@
 use Config;
 
 sub import {
+
+    # It's expensive to do, but we need to find out what's in @INC now that
+    # should be kept (because it was specified on the commandline with -I)
+    # and what we should drop because it's baked into perl as a local lib
+    my %to_kill = map { $_ => 1} _default_inc();
+    my @inc_to_save;
+    for (@INC) {
+        next if exists $to_kill{$_};
+                push @inc_to_save, $_;
+            }
     @INC = (
+        @inc_to_save,
+        '.',
+        $ENV{PERL5LIB} ? split( ':', $ENV{PERL5LIB} ) : (),
         $Config::Config{privlibexp},
         $Config::Config{archlibexp},
-        $ENV{PERL5LIB} ? split( ':', $ENV{PERL5LIB} ) : (),
-        '.',
     );
 }
 
+
+
+{
+
+    # This code stolen from 
+    # http://cpansearch.perl.org/src/ANDYA/Test-Harness-3.15/lib/Test/Harness.pm
+    # Cache this to avoid repeatedly shelling out to Perl.
+    my @inc;
+
+    sub _default_inc {
+        return @inc if @inc;
+        local $ENV{PERL5LIB} = '';
+        local $ENV{PERLLIB} = '';
+        local $ENV{PERL5DB} = '';
+        local $ENV{PERL5OPT} = '';
+        local $ENV{PERL5ENV} = '';
+
+
+        my $perl =  $^X;
+        # Avoid using -l for the benefit of Perl 6
+        chomp( @inc = `$perl -e "print join qq[\\n], \@INC, q[]"` );
+        return @inc;
+    }
+}
+
 package inc::Shipwright::Util::CleanINC;
 # this file will be copied to inc/ in shipwright's repository
 sub import {



More information about the Bps-public-commit mailing list