[svn:Module-Build] r13350 - in Module-Build/trunk: . lib/Module/Build lib/Module/Build/Platform

[email protected] Wed, 16 Sep 2009 04:16:54 -0700 (PDT)
Newsgroups perl.module.build.checkins
Message-ID <[email protected]>
Author: dagolden
Date: Wed Sep 16 04:16:54 2009
New Revision: 13350

Modified:
   Module-Build/trunk/Build.PL
   Module-Build/trunk/lib/Module/Build/Base.pm
   Module-Build/trunk/lib/Module/Build/Platform/VMS.pm
   Module-Build/trunk/lib/Module/Build/Platform/Windows.pm
   Module-Build/trunk/lib/Module/Build/Platform/cygwin.pm
   Module-Build/trunk/lib/Module/Build/Platform/os2.pm

Log:
inline code from IPC::Cmd and ExtUtils::MakeMaker

Modified: Module-Build/trunk/Build.PL
==============================================================================
--- Module-Build/trunk/Build.PL	(original)
+++ Module-Build/trunk/Build.PL	Wed Sep 16 04:16:54 2009
@@ -38,7 +38,6 @@
     'ExtUtils::Manifest'    => 0,
     'ExtUtils::Mkbootstrap' => 0,
     'IO::File'              => 0,
-    'IPC::Cmd'              => 0,
     'Cwd'                   => 0,
     'Text::Abbrev'          => 0,
     'Text::ParseWords'      => 0,

Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm	(original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm	Wed Sep 16 04:16:54 2009
@@ -501,6 +501,28 @@
       "in (@paths)\n";
 }
 
+# Adapted from IPC::Cmd::can_run()
+sub find_command {
+    my ($self, $command) = @_;
+
+    if( File::Spec->file_name_is_absolute($command) ) {
+        return $self->_maybe_command($command);
+
+    } else {
+        for my $dir ( File::Spec->path ) {
+            my $abs = File::Spec->catfile($dir, $command);
+            return $abs if $abs = $self->_maybe_command($abs);
+        }
+    }
+}
+
+# Copied from ExtUtils::MM_Unix::maybe_command
+sub _maybe_command {
+    my($self,$file) = @_;
+    return $file if -x $file && ! -d $file;
+    return;
+}
+
 sub _is_interactive {
   return -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ;   # Pipe?
 }
@@ -3205,11 +3227,10 @@
   # relative command should be relative to our active Perl
   # so we need to locate that command
   if ( ! File::Spec->file_name_is_absolute( $command ) ) {
-    require IPC::Cmd;
     my @bindirs = File::Basename::dirname($self->perl);
     push @bindirs, map {$self->config->{"install${_}bin"}} '','site','vendor';
     for my $d ( @bindirs ) {
-      my $abs_cmd = IPC::Cmd::can_run(File::Spec->catfile( $d, $command ));
+      my $abs_cmd = $self->find_command(File::Spec->catfile( $d, $command ));
       if ( defined $abs_cmd ) {
         $command = $abs_cmd;
         last;

Modified: Module-Build/trunk/lib/Module/Build/Platform/VMS.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Platform/VMS.pm	(original)
+++ Module-Build/trunk/lib/Module/Build/Platform/VMS.pm	Wed Sep 16 04:16:54 2009
@@ -173,6 +173,62 @@
   return `$cmd $args`;
 }
 
+=item find_command
+
+Local an executable program
+
+=cut
+
+sub find_command {
+    my ($self, $command) = @_;
+
+    # a lot of VMS executables have a symbol defined
+    # check those first
+    if ( $^O eq 'VMS' ) {
+        require VMS::DCLsym;
+        my $syms = VMS::DCLsym->new;
+        return $command if scalar $syms->getsym( uc $command );
+    }
+
+    $self->SUPER::find_command($command);
+}
+
+# _maybe_command copied from ExtUtils::MM_VMS::maybe_command
+
+=item _maybe_command (override)
+
+Follows VMS naming conventions for executable files.
+If the name passed in doesn't exactly match an executable file,
+appends F<.Exe> (or equivalent) to check for executable image, and F<.Com>
+to check for DCL procedure.  If this fails, checks directories in DCL$PATH
+and finally F<Sys$System:> for an executable file having the name specified,
+with or without the F<.Exe>-equivalent suffix.
+
+=cut
+
+sub _maybe_command {
+    my($self,$file) = @_;
+    return $file if -x $file && ! -d _;
+    my(@dirs) = ('');
+    my(@exts) = ('',$Config{'exe_ext'},'.exe','.com');
+
+    if ($file !~ m![/:>\]]!) {
+        for (my $i = 0; defined $ENV{"DCL\$PATH;$i"}; $i++) {
+            my $dir = $ENV{"DCL\$PATH;$i"};
+            $dir .= ':' unless $dir =~ m%[\]:]$%;
+            push(@dirs,$dir);
+        }
+        push(@dirs,'Sys$System:');
+        foreach my $dir (@dirs) {
+            my $sysfile = "$dir$file";
+            foreach my $ext (@exts) {
+                return $file if -x "$sysfile$ext" && ! -d _;
+            }
+        }
+    }
+    return;
+}
+
 =item do_system
 
 Override to ensure that we quote the arguments but not the command.

Modified: Module-Build/trunk/lib/Module/Build/Platform/Windows.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Platform/Windows.pm	(original)
+++ Module-Build/trunk/lib/Module/Build/Platform/Windows.pm	Wed Sep 16 04:16:54 2009
@@ -273,6 +273,27 @@
   return !$status;
 }
 
+# Copied from ExtUtils::MM_Win32
+sub _maybe_command {
+    my($self,$file) = @_;
+    my @e = exists($ENV{'PATHEXT'})
+          ? split(/;/, $ENV{PATHEXT})
+	  : qw(.com .exe .bat .cmd);
+    my $e = '';
+    for (@e) { $e .= "\Q$_\E|" }
+    chop $e;
+    # see if file ends in one of the known extensions
+    if ($file =~ /($e)$/i) {
+	return $file if -e $file;
+    }
+    else {
+	for (@e) {
+	    return "$file$_" if -e "$file$_";
+	}
+    }
+    return;
+}
+
 
 1;
 

Modified: Module-Build/trunk/lib/Module/Build/Platform/cygwin.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Platform/cygwin.pm	(original)
+++ Module-Build/trunk/lib/Module/Build/Platform/cygwin.pm	Wed Sep 16 04:16:54 2009
@@ -13,6 +13,27 @@
    '.'
 }
 
+# Copied from ExtUtils::MM_Cygwin::maybe_command()
+
+=item _maybe_command
+
+If our path begins with F</cygdrive/> then we use C<ExtUtils::MM_Win32>
+to determine if it may be a command.  Otherwise we use the tests
+from C<ExtUtils::MM_Unix>.
+
+=cut
+
+sub _maybe_command {
+    my ($self, $file) = @_;
+
+    if ($file =~ m{^/cygdrive/}i) {
+        require Module::Build::Platform::Win32;
+        return Module::Build::Platform::Win32->_maybe_command($file);
+    }
+
+    return $self->SUPER::_maybe_command($file);
+}
+
 1;
 __END__
 

Modified: Module-Build/trunk/lib/Module/Build/Platform/os2.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Platform/os2.pm	(original)
+++ Module-Build/trunk/lib/Module/Build/Platform/os2.pm	Wed Sep 16 04:16:54 2009
@@ -13,6 +13,16 @@
 
 sub have_forkpipe { 0 }
 
+# Copied from ExtUtils::MM_OS2::maybe_command
+sub _maybe_command {
+    my($self,$file) = @_;
+    $file =~ s,[/\\]+,/,g;
+    return $file if -x $file && ! -d _;
+    return "$file.exe" if -x "$file.exe" && ! -d _;
+    return "$file.cmd" if -x "$file.cmd" && ! -d _;
+    return;
+}
+
 1;
 __END__