diff --git a/Changes b/Changes index d93db190..cfc5e40c 100644 --- a/Changes +++ b/Changes @@ -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] diff --git a/lib/Module/Build.pm b/lib/Module/Build.pm index fc32c23e..389a0f3e 100644 --- a/lib/Module/Build.pm +++ b/lib/Module/Build.pm @@ -95,6 +95,10 @@ if (grep {-e File::Spec->catfile($_, qw(Module Build Platform), $^O) . '.pm'} @I 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__ diff --git a/lib/Module/Build/API.pod b/lib/Module/Build/API.pod index 5cd018b6..6f98e48f 100644 --- a/lib/Module/Build/API.pod +++ b/lib/Module/Build/API.pod @@ -1295,6 +1295,18 @@ whatever is appropriate. If you're running on an unknown platform, it will return C - 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) diff --git a/lib/Module/Build/Base.pm b/lib/Module/Build/Base.pm index 12007b49..4b91fe9e 100644 --- a/lib/Module/Build/Base.pm +++ b/lib/Module/Build/Base.pm @@ -447,7 +447,7 @@ sub find_perl_interpreter { 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 @@ sub process_script_files { 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 _find_file_by_type { 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 @@ sub fix_shebang_line { # Adapted from fixin() in ExtUtils::MM_Unix 1.35 $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"; diff --git a/lib/Module/Build/Compat.pm b/lib/Module/Build/Compat.pm index aea19605..c64dfc01 100644 --- a/lib/Module/Build/Compat.pm +++ b/lib/Module/Build/Compat.pm @@ -206,11 +206,11 @@ sub fake_makefile { 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 @@ force_do_it : @ $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 diff --git a/t/xs.t b/t/xs.t index c15a98f8..96cede43 100644 --- a/t/xs.t +++ b/t/xs.t @@ -85,7 +85,7 @@ is $@, ''; 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')};