Skip to content

Commit

Permalink
Add is_unixish(), is_windowsish(), is_vmsish()
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.perl.org/modules/Module-Build/trunk@9468 50811bd7-b8ce-0310-adc1-d9db26280581
  • Loading branch information
kenahoo committed Apr 28, 2007
1 parent 9df0a8d commit 60ac77b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
4 changes: 4 additions & 0 deletions 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]
Expand Down
4 changes: 4 additions & 0 deletions lib/Module/Build.pm
Expand Up @@ -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__
Expand Down
12 changes: 12 additions & 0 deletions lib/Module/Build/API.pod
Expand Up @@ -1295,6 +1295,18 @@ whatever is appropriate. If you're running on an unknown platform, it
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)
Expand Down
8 changes: 4 additions & 4 deletions lib/Module/Build/Base.pm
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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";
Expand Down
10 changes: 5 additions & 5 deletions lib/Module/Build/Compat.pm
Expand Up @@ -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';

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion t/xs.t
Expand Up @@ -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')};
Expand Down

0 comments on commit 60ac77b

Please sign in to comment.