Update of /cvsroot/module-build/Module-Build/lib/Module/Build/Platform
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27370/lib/Module/Build/Platform
Modified Files:
Windows.pm
Log Message:
The command to delete 'Build.bat' did not work on Win9x because the syntax differs between Win9x and WinNT variants. We now use the appropriate syntax based on Win32::GetOSVersion().
The user can invoke the 'realclean' action with either of 'Build realclean' (the batch script) or 'perl Build realclean'. We need to know which one was used, so we customize the use of the 'pl2bat' utility to append a special option, '--batch_bat', to the command line in the batch script. Based on the presence of this option we use an appropriate method of removing 'Build.bat'.
Index: Windows.pm
===================================================================
RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Platform/Windows.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- Windows.pm 21 Feb 2006 02:22:56 -0000 1.29
+++ Windows.pm 23 Feb 2006 04:03:52 -0000 1.30
@@ -38,7 +38,7 @@
} else {
@potential_dirs = map { File::Spec->canonpath($_) }
@${cf}{qw(installscript installbin installsitebin installvendorbin)},
- File::Basename::dirname($self->{properties}{perl});
+ File::Basename::dirname($self->perl);
}
foreach my $dir (@potential_dirs) {
@@ -54,44 +54,68 @@
my $self = shift;
$self->SUPER::make_executable(@_);
+ my $perl = $self->perl;
+
my $pl2bat = $self->{config}{pl2bat};
+ my $pl2bat_args = '';
if ( defined($pl2bat) && length($pl2bat) ) {
+
foreach my $script (@_) {
next if $script =~ /\.(bat|cmd)$/i; # already a script; nothing to do
(my $script_bat = $script) =~ s/\.plx?$//i;
$script_bat .= '.bat'; # MSWin32 executable batch script file extension
-# $self->add_to_cleanup($script_bat); # don't do this for $script_bat since it unlinks itself
- local $self->{properties}{quiet} = 1 if $self->build_script; # Psst, keep this quiet
- my $status = $self->do_system("$self->{properties}{perl} $pl2bat < $script > $script_bat");
+ my $quiet_state = $self->{properties}{quiet}; # keep quiet
+ if ( $script eq $self->build_script ) {
+ $self->{properties}{quiet} = 1;
+ $pl2bat_args =
+ q(-n "-x -S """%0""" "--build_bat" %*" ) .
+ q(-o "-x -S """%0""" "--build_bat" %1 %2 %3 %4 %5 %6 %7 %8 %9");
+ }
+
+ my $status = $self->do_system("$perl $pl2bat $pl2bat_args " .
+ "< $script > $script_bat");
$self->SUPER::make_executable($script_bat);
+
+ $self->{properties}{quiet} = $quiet_state; # restore quiet
}
+
} else {
- warn "Could not find 'pl2bat.bat' utility needed to make scripts executable.\n"
- . "Unable to convert scripts ( " . join(', ', @_) . " ) to executables.\n";
+ warn <<"EOF";
+Could not find 'pl2bat.bat' utility needed to make scripts executable.
+Unable to convert scripts ( @{[join(', ', @_)]} ) to executables.
+EOF
}
}
sub ACTION_realclean {
my ($self) = @_;
- $self->depends_on('clean');
+
+ $self->SUPER::ACTION_realclean();
my $basename = basename($0);
$basename =~ s/(?:\.bat)?$//i;
if ( $basename eq $self->build_script ) {
- my $full_progname = $0;
- $full_progname =~ s/(?:\.bat)?$/.bat/i;
+ if ( $self->build_bat ) {
+ my $full_progname = $0;
+ $full_progname =~ s/(?:\.bat)?$/.bat/i;
- my $fh = IO::File->new(">> $basename.bat") or die "Can't create $basename.bat: $!";
- print $fh qq(start "" /min "\%comspec\%" /c del "$full_progname"); # should work for NT variants, possibly 9x
- close $fh ;
+ # Syntax differs between 9x & NT: the later requires a null arg (???)
+ require Win32;
+ my $null_arg = (Win32::GetOSVersion == 2) ? '""' : '';
+ my $cmd = qq(start $null_arg /min "\%comspec\%" /c del "$full_progname");
+ my $fh = IO::File->new(">> $basename.bat")
+ or die "Can't create $basename.bat: $!";
+ print $fh $cmd;
+ close $fh ;
+ } else {
+ $self->delete_filetree($self->build_script . '.bat');
+ }
}
-
- $self->delete_filetree($self->config_dir, $self->build_script);
}
sub manpage_separator {
|