Author: kwilliams
Date: Sat Apr 28 09:55:07 2007
New Revision: 9468

Modified:
   Module-Build/trunk/Changes
   Module-Build/trunk/lib/Module/Build.pm
   Module-Build/trunk/lib/Module/Build/API.pod
   Module-Build/trunk/lib/Module/Build/Base.pm
   Module-Build/trunk/lib/Module/Build/Compat.pm
   Module-Build/trunk/t/xs.t

Log:
Add is_unixish(), is_windowsish(), is_vmsish()

Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes  (original)
+++ Module-Build/trunk/Changes  Sat Apr 28 09:55:07 2007
@@ -1,5 +1,9 @@
 Revision history for Perl extension Module::Build.
 
+ - Added is_vmsish(), is_windowsish(), and is_unixish() boolean
+   convenience functions.  Fixes some test failures on platforms where
+   $^O is set to a value we don't know about (like 'gnu').
+
  - Upgraded to version.pm 0.7203. [John Peacock]
 
  - Support get_action_docs() =head2 style. [ewilhelm]

Modified: Module-Build/trunk/lib/Module/Build.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build.pm      (original)
+++ Module-Build/trunk/lib/Module/Build.pm      Sat Apr 28 09:55:07 2007
@@ -95,6 +95,10 @@
 
 sub os_type { $OSTYPES{$^O} }
 
+sub is_vmsish { return ((os_type() || '') eq 'VMS') }
+sub is_windowsish { return ((os_type() || '') eq 'Windows') }
+sub is_unixish { return ((os_type() || '') eq 'Unix') }
+
 1;
 
 __END__

Modified: Module-Build/trunk/lib/Module/Build/API.pod
==============================================================================
--- Module-Build/trunk/lib/Module/Build/API.pod (original)
+++ Module-Build/trunk/lib/Module/Build/API.pod Sat Apr 28 09:55:07 2007
@@ -1295,6 +1295,18 @@
 will return C<undef> - there shouldn't be many unknown platforms
 though.
 
+=item is_vmsish()
+
+=item is_windowsish()
+
+=item is_unixish()
+
+Convenience functions that return a boolean value indicating whether
+this platform behaves respectively like VMS, Windows, or Unix.  For
+arbitrary reasons other platforms don't get their own such functions,
+at least not yet.
+
+
 =item prefix_relpaths()
 
 =item prefix_relpaths($installdirs)

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 Sat Apr 28 09:55:07 2007
@@ -447,7 +447,7 @@
   my $exe = $c->get('exe_ext');
   foreach my $thisperl ( @potential_perls ) {
 
-    if ($proto->os_type eq 'VMS') {
+    if ($proto->is_vmsish) {
       # VMS might have a file version at the end
       $thisperl .= $exe unless $thisperl =~ m/$exe(;\d+)?$/i;
     } elsif (defined $exe) {
@@ -2289,7 +2289,7 @@
   
   foreach my $file (keys %$files) {
     my $result = $self->copy_if_modified($file, $script_dir, 'flatten') or 
next;
-    $self->fix_shebang_line($result) unless $self->os_type eq 'VMS';
+    $self->fix_shebang_line($result) unless $self->is_vmsish;
     $self->make_executable($result);
   }
 }
@@ -2376,7 +2376,7 @@
 
 sub localize_file_path {
   my ($self, $path) = @_;
-  $path =~ s/\.\z// if $self->os_type eq 'VMS';
+  $path =~ s/\.\z// if $self->is_vmsish;
   return File::Spec->catfile( split m{/}, $path );
 }
 
@@ -2409,7 +2409,7 @@
     $shb .= qq{
 eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}'
     if 0; # not running under some shell
-} unless $self->os_type eq 'Windows'; # this won't work on win32, so don't
+} unless $self->is_windowsish; # this won't work on win32, so don't
     
     my $FIXOUT = IO::File->new(">$file.new")
       or die "Can't create new $file: $!\n";

Modified: Module-Build/trunk/lib/Module/Build/Compat.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Compat.pm       (original)
+++ Module-Build/trunk/lib/Module/Build/Compat.pm       Sat Apr 28 09:55:07 2007
@@ -206,11 +206,11 @@
     warn "Unknown 'build_class', defaulting to 'Module::Build'\n";
     $args{build_class} = 'Module::Build';
   }
+  my $class = $args{build_class};
 
-  my $perl = $args{build_class}->find_perl_interpreter;
-  my $os_type = $args{build_class}->os_type;
-  my $noop = ($os_type eq 'Windows' ? 'rem>nul' :
-             $os_type eq 'VMS'     ? 'Continue' :
+  my $perl = $class->find_perl_interpreter;
+  my $noop = ($class->is_windowsish ? 'rem>nul'  :
+             $class->is_vmsish     ? 'Continue' :
              'true');
   my $Build = 'Build --makefile_env_macros 1';
 
@@ -226,7 +226,7 @@
        @ $noop
 EOF
 
-  foreach my $action ($args{build_class}->known_actions) {
+  foreach my $action ($class->known_actions) {
     next if $action =~ /^(all|realclean|force_do_it)$/;  # Don't double-define
     $maketext .= <<"EOF";
 $action : force_do_it

Modified: Module-Build/trunk/t/xs.t
==============================================================================
--- Module-Build/trunk/t/xs.t   (original)
+++ Module-Build/trunk/t/xs.t   Sat Apr 28 09:55:07 2007
@@ -85,7 +85,7 @@
 
 SKIP: {
   skip( "skipping a Unixish-only tests", 1 )
-      unless $mb->os_type eq 'Unix';
+      unless $mb->is_unixish;
 
   $mb->{config}->push(ld => "FOO=BAR ".$mb->config('ld'));
   eval {$mb->dispatch('build')};

Reply via email to