Re: [Module-build-general] [PATCH] MSWin32 override make_executable() to call pl2bat utility.
Status: Beta
Brought to you by:
kwilliams
|
From: Ken W. <ke...@ma...> - 2003-03-11 16:31:37
|
Thanks - I've applied it, finally.
The make_executable() routine is called for any script requiring
execution privileges, does it make sense to always create a .bat file,
even for things like the Build script?
-Ken
On Saturday, March 1, 2003, at 03:33 PM, Randy W. Sims wrote:
> Calls the pl2bat utility (distributed with the perl core) on perl
> scripts which adds a short batch startup script to the file which
> invokes perl. As per MakeMaker both the .pl and the new .bat file will
> be installed. See the documentation in
> <perl-source>/win32/bin/pl2bat.pl and in the
> <perl-source>/README.win32 file in the section 'Usage Hints' -
> 'Running Perl Scripts' for details.
>
> Randy.
> 18d17
> < # Check compiler type.
> 19a19,20
>>
>> # Check compiler type.
> 31a33,47
>> # Find 'pl2bat.bat' utility used for installing perl scripts.
>> # This search is probably overkill, as I've never met a MSWin32 perl
>> # where these locations differed from each other.
>> my @potential_dirs = map { File::Spec->canonpath($_) }
>> @${cf}{qw(installscript installbin installsitebin
>> installvendorbin)},
>> File::Basename::dirname($self->{properties}{perl});
>>
>> foreach my $dir (@potential_dirs) {
>> my $potential_file = File::Spec->catfile($dir, 'pl2bat.bat');
>> if ( -f $potential_file && !-d _ ) {
>> $cf->{pl2bat} = $potential_file;
>> last;
>> }
>> }
>>
> 192a209,237
>> sub make_executable {
>> my $self = shift;
>> $self->SUPER::make_executable(@_);
>>
>> my $pl2bat = $self->{config}{pl2bat};
>>
>> if ( defined($pl2bat) && length($pl2bat) ) {
>> foreach my $script (@_) {
>> # Don't run 'pl2bat.bat' for the 'Build' script;
>> # there is no easy way to get the resulting 'Build.bat'
>> # to delete itself when doing a 'Build realclean'.
>> next if ( $script eq $self->{properties}{build_script} );
>>
>> (my $script_bat = $script) =~ s/\.plx?//i;
>> $script_bat .= '.bat' unless $script_bat =~ /\.bat$/i;
>>
>> my $status = $self->do_system($pl2bat, '<', $script, '>',
>> $script_bat);
>> if ( $status && -f $script_bat ) {
>> $self->SUPER::make_executable($script_bat);
>> } else {
>> warn "Unable to convert '$script' to an executable.\n";
>> }
>> }
>> } else {
>> warn "Could not find 'pl2bat.bat' utility needed to make scripts
>> executable.\n"
>> . "Unable to convert scripts ( " . join(', ', @_) . " ) to
>> executables.\n";
>> }
>> }
|