In perl.git, the branch leont/pl2bat_refactor has been updated <https://perl5.git.perl.org/perl.git/commitdiff/bcafea090c1453af91759e824d172f95c957b808?hp=b83a7c56f1a002f0ea41a881960be35641f929cc>
discards b83a7c56f1a002f0ea41a881960be35641f929cc (commit) discards eacfdadb156832bd6a9368c30b81d5643cf5aedc (commit) discards a05dd09a0b7b0aad4ba5711affea08e6970646e1 (commit) - Log ----------------------------------------------------------------- commit bcafea090c1453af91759e824d172f95c957b808 Author: Leon Timmermans <faw...@gmail.com> Date: Thu Apr 25 14:50:50 2019 +0200 Make pl2bat use ExtUtils::PL2Bat commit 9acc2e6b8552b06ef5f9e549ddc83dd816b15b0c Author: Leon Timmermans <faw...@gmail.com> Date: Thu Apr 25 13:22:28 2019 +0200 Eliminate -a option of pl2bat commit f32b7e53313ffb9bf77e8b0be9393f2fa278f47a Author: Leon Timmermans <faw...@gmail.com> Date: Thu Apr 25 11:11:05 2019 +0200 Import ExtUtils::PL2Bat ----------------------------------------------------------------------- Summary of changes: MANIFEST | 2 + Porting/Maintainers.pl | 8 ++ cpan/ExtUtils-PL2Bat/t/00-compile.t | 54 ----------- lib/.gitignore | 1 + lib/ExtUtils/PL2Bat.pm | 185 ------------------------------------ 5 files changed, 11 insertions(+), 239 deletions(-) delete mode 100644 cpan/ExtUtils-PL2Bat/t/00-compile.t delete mode 100644 lib/ExtUtils/PL2Bat.pm diff --git a/MANIFEST b/MANIFEST index f058168722..9e4984e90e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -876,6 +876,8 @@ cpan/ExtUtils-MakeMaker/t/writemakefile_args.t See if WriteMakefile works cpan/ExtUtils-Manifest/lib/ExtUtils/Manifest.pm Utilities to write MANIFEST files cpan/ExtUtils-Manifest/lib/ExtUtils/MANIFEST.SKIP The default MANIFEST.SKIP cpan/ExtUtils-Manifest/t/Manifest.t See if ExtUtils::Manifest works +cpan/ExtUtils-PL2Bat/lib/ExtUtils/PL2Bat.pm Implement pl2bat +cpan/ExtUtils-PL2Bat/t/make_executable.t Tests if ExtUtils::PL2Bat makes bat files that are executable cpan/File-Fetch/lib/File/Fetch.pm File::Fetch cpan/File-Fetch/t/01_File-Fetch.t File::Fetch tests cpan/File-Fetch/t/null_subclass.t diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index 7d48d0dbe0..cac24ce623 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -475,6 +475,14 @@ use File::Glob qw(:case); ], }, + 'ExtUtils::PL2Bat' => { + 'DISTRIBUTION' => 'LEONT/ExtUtils-PL2Bat-0.001.tar.gz', + 'FILES' => q[cpan/ExtUtils-PL2Bat], + 'EXCLUDED' => [ + 't/00-compile.t', + ], + }, + 'ExtUtils::Manifest' => { 'DISTRIBUTION' => 'ETHER/ExtUtils-Manifest-1.72.tar.gz', 'FILES' => q[cpan/ExtUtils-Manifest], diff --git a/cpan/ExtUtils-PL2Bat/t/00-compile.t b/cpan/ExtUtils-PL2Bat/t/00-compile.t deleted file mode 100644 index d54e1d1c2e..0000000000 --- a/cpan/ExtUtils-PL2Bat/t/00-compile.t +++ /dev/null @@ -1,54 +0,0 @@ -use 5.006; -use strict; -use warnings; - -# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.054 - -use Test::More; - -plan tests => 2; - -my @module_files = ( - 'ExtUtils/PL2Bat.pm' -); - - - -# no fake home requested - -my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; - -use File::Spec; -use IPC::Open3; -use IO::Handle; - -open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; - -my @warnings; -for my $lib (@module_files) -{ - # see L<perlfaq8/How can I capture STDERR from an external command?> - my $stderr = IO::Handle->new; - - my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); - binmode $stderr, ':crlf' if $^O eq 'MSWin32'; - my @_warnings = <$stderr>; - waitpid($pid, 0); - is($?, 0, "$lib loaded ok"); - - shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ - and not eval { require blib; blib->VERSION('1.01') }; - - if (@_warnings) - { - warn @_warnings; - push @warnings, @_warnings; - } -} - - - -is(scalar(@warnings), 0, 'no warnings found') - or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ); - - diff --git a/lib/.gitignore b/lib/.gitignore index 9a38e68ed3..efce00a5ee 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -73,6 +73,7 @@ /ExtUtils/Miniperl.pm /ExtUtils/Mkbootstrap.pm /ExtUtils/Mksymlists.pm +/ExtUtils/PL2Bat.pm /ExtUtils/Packlist.pm /ExtUtils/ParseXS.pm /ExtUtils/ParseXS.pod diff --git a/lib/ExtUtils/PL2Bat.pm b/lib/ExtUtils/PL2Bat.pm deleted file mode 100644 index 3dfa2b6003..0000000000 --- a/lib/ExtUtils/PL2Bat.pm +++ /dev/null @@ -1,185 +0,0 @@ -package ExtUtils::PL2Bat; -$ExtUtils::PL2Bat::VERSION = '0.001'; -use strict; -use warnings; - -use 5.006; - -use base 'Exporter'; -our @EXPORT = qw/pl2bat/; - -use Config; -use Carp qw/croak/; - -sub pl2bat { - my %opts = @_; - - # NOTE: %0 is already enclosed in doublequotes by cmd.exe, as appropriate - $opts{ntargs} = '-x -S %0 %*' unless exists $opts{ntargs}; - $opts{otherargs} = '-x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9' unless exists $opts{otherargs}; - - $opts{stripsuffix} = qr/\.plx?/ unless exists $opts{stripsuffix}; - - if (not exists $opts{out}) { - $opts{out} = $opts{in}; - $opts{out} =~ s/$opts{stripsuffix}$//i; - $opts{out} .= '.bat' unless $opts{in} =~ /\.bat$/i or $opts{in} eq '-'; - } - - my $head = <<"EOT"; - \@rem = '--*-Perl-*-- - \@echo off - if "%OS%" == "Windows_NT" goto WinNT - perl $opts{otherargs} - \@set ErrorLevel=%ErrorLevel% - goto endofperl - :WinNT - perl $opts{ntargs} - \@set ErrorLevel=%ErrorLevel% - if NOT "%COMSPEC%" == "%SystemRoot%\\system32\\cmd.exe" goto endofperl - if %errorlevel% == 9009 echo You do not have Perl in your PATH. - goto endofperl - \@rem '; -EOT - - $head =~ s/^\s+//gm; - my $headlines = 2 + ($head =~ tr/\n/\n/); - my $tail = <<'EOT'; - __END__ - :endofperl - @"%COMSPEC%" /c exit /b %ErrorLevel% -EOT - $tail =~ s/^\s+//gm; - - my $linedone = 0; - my $taildone = 0; - my $linenum = 0; - my $skiplines = 0; - - my $start = $Config{startperl}; - $start = '#!perl' unless $start =~ /^#!.*perl/; - - open my $in, '<', $opts{in} or croak "Can't open $opts{in}: $!"; - my @file = <$in>; - close $in; - - foreach my $line ( @file ) { - $linenum++; - if ( $line =~ /^:endofperl\b/ ) { - if (!exists $opts{update}) { - warn "$opts{in} has already been converted to a batch file!\n"; - return; - } - $taildone++; - } - if ( not $linedone and $line =~ /^#!.*perl/ ) { - if (exists $opts{update}) { - $skiplines = $linenum - 1; - $line .= '#line '.(1+$headlines)."\n"; - } else { - $line .= '#line '.($linenum+$headlines)."\n"; - } - $linedone++; - } - if ( $line =~ /^#\s*line\b/ and $linenum == 2 + $skiplines ) { - $line = ''; - } - } - - open my $out, '>', $opts{out} or croak "Can't open $opts{out}: $!"; - print $out $head; - print $out $start, ( $opts{usewarnings} ? ' -w' : '' ), - "\n#line ", ($headlines+1), "\n" unless $linedone; - print $out @file[$skiplines..$#file]; - print $out $tail unless $taildone; - close $out; - - return $opts{out}; -} - -1; - -# ABSTRACT: Batch file creation to run perl scripts on Windows - -__END__ - -=pod - -=encoding UTF-8 - -=head1 NAME - -ExtUtils::PL2Bat - Batch file creation to run perl scripts on Windows - -=head1 VERSION - -version 0.001 - -=head1 OVERVIEW - -This module converts a perl script into a batch file that can be executed on Windows/DOS-like operating systems. This is intended to allow you to use a Perl script like regular programs and batch files where you just enter the name of the script [probably minus the extension] plus any command-line arguments and the script is found in your B<PATH> and run. - -=head1 FUNCTIONS - -=head2 pl2bat(%opts) - -This function takes a perl script and write a batch file that contains the script. This is sometimes necessary - -=over 8 - -=item * C<in> - -The name of the script that is to be batchified. This argument is mandatory. - -=item * C<out> - -The name of the output batch file. If not given, it will be generated using C<in> and C<stripsuffix>. - -=item * C<ntargs> - -Arguments to invoke perl with in generated batch file when run from -Windows NT. Defaults to S<'-x -S %0 %*'>. - -=item * C<otherargs> - -Arguments to invoke perl with in generated batch file except when -run from Windows NT (ie. when run from DOS, Windows 3.1, or Windows 95). -Defaults to S<'-x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9'>. - -=item * C<stripsuffix> - -Strip a suffix string from file name before appending a ".bat" -suffix. The suffix is not case-sensitive. It can be a regex or a string and a trailing -C<$> is always assumed). Defaults to C<qr/\.plx?/>. - -=item * C<usewarnings> - -With the C<usewarnings> -option, C<" -w"> is added after the value of C<$Config{startperl}>. -If a line matching C</^#!.*perl/> already exists in the script, -then it is not changed and the B<-w> option is ignored. - -=item * C<update> - -If the script appears to have already been processed by B<pl2bat>, -then the script is skipped and not processed unless C<update> was -specified. If C<update> is specified, the existing preamble is replaced. - -=back - -=head1 ACKNOWLEDGEMENTS - -This code was taken from Module::Build and then modified; which had taken it from perl's pl2bat script. This module is an attempt at unifying all three implementations. - -=head1 AUTHOR - -Leon Timmermans <le...@cpan.org> - -=head1 COPYRIGHT AND LICENSE - -This software is copyright (c) 2015 by Leon Timmermans. - -This is free software; you can redistribute it and/or modify it under -the same terms as the Perl 5 programming language system itself. - -=cut -- Perl5 Master Repository