Skip to content

Commit 2c88e62

Browse files
committed
Add dependency on ExtUtils::PL2Bat
1 parent b73a902 commit 2c88e62

File tree

3 files changed

+5
-81
lines changed

3 files changed

+5
-81
lines changed

Build.PL

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ my $build = ModuleBuildBuilder->new(
6565
'version' => 0.87, # No longer requires M::B
6666
'Module::Metadata' => 1.000002, # uses version.pm
6767
'Pod::Man' => 2.17, # utf8 support
68+
($^O eq 'MSWin32' ? ('ExtUtils::PL2Bat' => 0) : ())
6869
},
6970
test_requires => {
7071
'File::Temp' => 0.15, # tmpdir() + fixes

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Revision history for Perl extension Module::Build.
22

3+
- Add dependency on ExtUtils::PL2Bat
4+
35
0.4229 - Tue Apr 16 00:49:45 CEST 2019
46
- Released 0.42_28 without changes
57

lib/Module/Build/Platform/Windows.pm

Lines changed: 2 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -87,90 +87,11 @@ sub make_executable {
8787
}
8888
}
8989

90-
# This routine was copied almost verbatim from the 'pl2bat' utility
91-
# distributed with perl. It requires too much voodoo with shell quoting
92-
# differences and shortcomings between the various flavors of Windows
93-
# to reliably shell out
9490
sub pl2bat {
9591
my $self = shift;
9692
my %opts = @_;
97-
98-
# NOTE: %0 is already enclosed in doublequotes by cmd.exe, as appropriate
99-
$opts{ntargs} = '-x -S %0 %*' unless exists $opts{ntargs};
100-
$opts{otherargs} = '-x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9' unless exists $opts{otherargs};
101-
102-
$opts{stripsuffix} = '/\\.plx?/' unless exists $opts{stripsuffix};
103-
$opts{stripsuffix} = ($opts{stripsuffix} =~ m{^/([^/]*[^/\$]|)\$?/?$} ? $1 : "\Q$opts{stripsuffix}\E");
104-
105-
unless (exists $opts{out}) {
106-
$opts{out} = $opts{in};
107-
$opts{out} =~ s/$opts{stripsuffix}$//oi;
108-
$opts{out} .= '.bat' unless $opts{in} =~ /\.bat$/i or $opts{in} =~ /^-$/;
109-
}
110-
111-
my $head = <<EOT;
112-
\@rem = '--*-Perl-*--
113-
\@echo off
114-
if "%OS%" == "Windows_NT" goto WinNT
115-
perl $opts{otherargs}
116-
goto endofperl
117-
:WinNT
118-
perl $opts{ntargs}
119-
if NOT "%COMSPEC%" == "%SystemRoot%\\system32\\cmd.exe" goto endofperl
120-
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
121-
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
122-
goto endofperl
123-
\@rem ';
124-
EOT
125-
126-
$head =~ s/^\s+//gm;
127-
my $headlines = 2 + ($head =~ tr/\n/\n/);
128-
my $tail = "\n__END__\n:endofperl\n";
129-
130-
my $linedone = 0;
131-
my $taildone = 0;
132-
my $linenum = 0;
133-
my $skiplines = 0;
134-
135-
my $start = $Config{startperl};
136-
$start = "#!perl" unless $start =~ /^#!.*perl/;
137-
138-
open(my $in, '<', "$opts{in}") or die "Can't open $opts{in}: $!";
139-
my @file = <$in>;
140-
close($in);
141-
142-
foreach my $line ( @file ) {
143-
$linenum++;
144-
if ( $line =~ /^:endofperl\b/ ) {
145-
if (!exists $opts{update}) {
146-
warn "$opts{in} has already been converted to a batch file!\n";
147-
return;
148-
}
149-
$taildone++;
150-
}
151-
if ( not $linedone and $line =~ /^#!.*perl/ ) {
152-
if (exists $opts{update}) {
153-
$skiplines = $linenum - 1;
154-
$line .= "#line ".(1+$headlines)."\n";
155-
} else {
156-
$line .= "#line ".($linenum+$headlines)."\n";
157-
}
158-
$linedone++;
159-
}
160-
if ( $line =~ /^#\s*line\b/ and $linenum == 2 + $skiplines ) {
161-
$line = "";
162-
}
163-
}
164-
165-
open(my $out, '>', "$opts{out}") or die "Can't open $opts{out}: $!";
166-
print $out $head;
167-
print $out $start, ( $opts{usewarnings} ? " -w" : "" ),
168-
"\n#line ", ($headlines+1), "\n" unless $linedone;
169-
print $out @file[$skiplines..$#file];
170-
print $out $tail unless $taildone;
171-
close($out);
172-
173-
return $opts{out};
93+
require ExtUtils::PL2Bat;
94+
return ExtUtils::PL2Bat::pl2bat(%opts);
17495
}
17596

17697

0 commit comments

Comments
 (0)