Skip to content

Commit 154730c

Browse files
committed
Revert commit 59c2e8, add test for PM_FILTER, fix RT-144085
1 parent 3966577 commit 154730c

File tree

5 files changed

+48
-28
lines changed

5 files changed

+48
-28
lines changed

.appveyor.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@ skip_tags: true ## do not build on tags
1515

1616
environment:
1717
matrix:
18+
# this has dmake "Version 4.12 (Windows / MinGW)"
1819
- Perl_VERSION: "5.12"
19-
- Perl_VERSION: "5.10"
20-
- Perl_VERSION: "5.8.9"
20+
# these have dmake -V "Version 4.8-20070327-SHAY (Windows / MS Visual C++)"
21+
# which appear to be broken with the PM_FILTER fix; when running `dmake`
22+
# with EUMM's Makefile, it says
23+
# "C:\strawberry\perl\bin\perl.exe" "-Iblib\arch" "-Iblib\lib" -MExtUtils::Command -e mkpath -- blib\lib\ExtUtils
24+
# The system cannot find the path specified.
25+
# dmake: Error code 129, while making 'blib\lib\ExtUtils\.exists'
26+
# - Perl_VERSION: "5.10"
27+
# - Perl_VERSION: "5.8.9"
2128
global:
2229
AUTOMATED_TESTING: 1
2330
CI_CACHE_DIR: "C:\\cache"
@@ -130,12 +137,12 @@ before_build:
130137

131138
build_script:
132139
- ps: ; write-host $("[{0:HH:mm:ss}].build.build_script" -f $($mark = get-date; $mark)) -f darkgray
133-
- ps: . "${env:CI_HELPERS}\#build-build_script.PS1"
140+
- dmake NOECHO=
134141
- ps: ; write-host $("[{0:HH:mm:ss}].build.build_script ... done ({1:0.0}s)" -f $(get-date; $($(get-date) - $mark).totalseconds)) -f green
135142

136143
test_script:
137144
- ps: ; write-host $("[{0:HH:mm:ss}].test.test_script" -f $($mark = get-date; $mark)) -f darkgray
138-
- ps: . "${env:CI_HELPERS}\#test-test_script.PS1"
145+
- dmake test NOECHO=
139146
- ps: ; write-host $("[{0:HH:mm:ss}].test.test_script ... done ({1:0.0}s)" -f $(get-date; $($(get-date) - $mark).totalseconds)) -f green
140147

141148
after_test:

lib/ExtUtils/MM_Any.pm

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,6 +2499,10 @@ sub tools_other {
24992499
my($self) = shift;
25002500
my @m;
25012501

2502+
my $is_nmake = $self->is_make_type('nmake');
2503+
push @m, <<'EOF' if $is_nmake;
2504+
EUMM_NMAKE_HASH = ^# # to get hash character into strings - yes, horrible
2505+
EOF
25022506
# We set PM_FILTER as late as possible so it can see all the earlier
25032507
# on macro-order sensitive makes such as nmake.
25042508
for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
@@ -2515,8 +2519,14 @@ sub tools_other {
25152519
CP_NONEMPTY
25162520
} )
25172521
{
2518-
next unless defined $self->{$tool};
2519-
push @m, "$tool = $self->{$tool}\n";
2522+
next unless defined(my $value = $self->{$tool});
2523+
# https://learn.microsoft.com/en-us/cpp/build/reference/contents-of-a-makefile?view=msvc-170#special-characters-in-a-makefile
2524+
if ($is_nmake) {
2525+
$value =~ s/#/\$(EUMM_NMAKE_HASH)/g
2526+
} else {
2527+
$value =~ s/#/\\#/g
2528+
}
2529+
push @m, "$tool = $value\n";
25202530
}
25212531

25222532
return join "", @m;

lib/ExtUtils/MM_Unix.pm

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,11 +2151,6 @@ sub init_PERL {
21512151
# already escaped spaces.
21522152
$self->{FULLPERL} =~ tr/"//d if $Is{VMS};
21532153

2154-
# `dmake` can fail for image (aka, executable) names which start with double-quotes
2155-
# * push quote inward by at least one character (or the drive prefix, if present)
2156-
# * including any initial directory separator preserves the `file_name_is_absolute` property
2157-
$self->{FULLPERL} =~ s/^"(\S(:\\|:)?)/$1"/ if $self->is_make_type('dmake');
2158-
21592154
# Little hack to get around VMS's find_perl putting "MCR" in front
21602155
# sometimes.
21612156
$self->{ABSPERL} = $self->{PERL};
@@ -2178,11 +2173,6 @@ sub init_PERL {
21782173
# already escaped spaces.
21792174
$self->{PERL} =~ tr/"//d if $Is{VMS};
21802175

2181-
# `dmake` can fail for image (aka, executable) names which start with double-quotes
2182-
# * push quote inward by at least one character (or the drive prefix, if present)
2183-
# * including any initial directory separator preserves the `file_name_is_absolute` property
2184-
$self->{PERL} =~ s/^"(\S(:\\|:)?)/$1"/ if $self->is_make_type('dmake');
2185-
21862176
# Are we building the core?
21872177
$self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
21882178
$self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
@@ -3201,11 +3191,17 @@ pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM)
32013191

32023192
# VMS will swallow '' and PM_FILTER is often empty. So use q[]
32033193
my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
3204-
pm_to_blib({\@ARGV}, '$autodir', q[\$(PM_FILTER)], '\$(PERM_DIR)')
3194+
\$i=0; \$i++ until \$i > \$#ARGV or \$ARGV[\$i] eq "--";
3195+
die "Failed to find -- in ".join("|",\@ARGV) if \$i > \$#ARGV;
3196+
\@parts=splice \@ARGV,0,\$i+1;
3197+
pop \@parts; \$filter=join " ", map qq{"\$_"}, \@parts;
3198+
pm_to_blib({\@ARGV}, '$autodir', \$filter, '\$(PERM_DIR)')
32053199
CODE
3200+
$pm_to_blib .= q[ $(PM_FILTER) --];
32063201

32073202
my @cmds = $self->split_command($pm_to_blib,
3208-
map { ($self->quote_literal($_) => $self->quote_literal($self->{PM}->{$_})) } sort keys %{$self->{PM}});
3203+
map +($self->quote_literal($_) => $self->quote_literal($self->{PM}{$_})),
3204+
sort keys %{$self->{PM}});
32093205

32103206
$r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
32113207
$r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n};

lib/ExtUtils/MakeMaker.pm

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,6 @@ END
693693
} else {
694694
my $value = $self->{$key};
695695
# not going to test in FS so only stripping start
696-
$value =~ s/"// if $key =~ /PERL$/ and $self->is_make_type('dmake');
697696
$value =~ s/^"// if $key =~ /PERL$/;
698697
$value = $self->catdir("..", $value)
699698
unless $self->file_name_is_absolute($value);
@@ -2650,17 +2649,13 @@ to stdout) that is passed on each .pm file during the build (in the
26502649
pm_to_blib() phase). It is empty by default, meaning no filtering is done.
26512650
You could use:
26522651
2653-
PM_FILTER => 'perl -ne "print unless /^\\#/"',
2652+
PM_FILTER => 'perl -ne "print unless /^#/"',
26542653
26552654
to remove all the leading comments on the fly during the build. In order
26562655
to be as portable as possible, please consider using a Perl one-liner
2657-
rather than Unix (or other) utilities, as above. The # is escaped for
2658-
the Makefile, since what is going to be generated will then be:
2659-
2660-
PM_FILTER = perl -ne "print unless /^\#/"
2661-
2662-
Without the \ before the #, we'd have the start of a Makefile comment,
2663-
and the macro would be incorrectly defined.
2656+
rather than Unix (or other) utilities, as above. MakeMaker will escape the
2657+
C<#> for the Makefile, since what goes in the Makefile will depend on
2658+
which C<make> implementation is being targeted.
26642659
26652660
You will almost certainly be better off using the C<PL_FILES> system,
26662661
instead. See above, or the L<ExtUtils::MakeMaker::FAQ> entry.

t/basic.t

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use ExtUtils::MM;
2525
use Test::More
2626
!MM->can_run(make()) && $ENV{PERL_CORE} && $Config{'usecrosscompile'}
2727
? (skip_all => "cross-compiling and make not available")
28-
: (tests => 195);
28+
: (tests => 198);
2929
use File::Find;
3030
use File::Spec;
3131
use File::Path;
@@ -472,6 +472,18 @@ $realclean_out = run("$make realclean");
472472
rmtree 'Liar';
473473
rmtree $DUMMYINST;
474474

475+
# test PM_FILTER - RT#144085
476+
$text = $preserve_MPL;
477+
ok(($text =~ s:\);: PM_FILTER => '\$(ABSPERLRUN) -ne "print unless /^#/"',\n$&:), 'successful M.PL edit');
478+
write_file($file, $text);
479+
@mpl_out = run(qq{$perl Makefile.PL});
480+
$test_out = run("$make test NOECHO=");
481+
like( $test_out, qr/All tests successful/, 'make test' );
482+
is( $?, 0, ' exited normally' ) ||
483+
diag $test_out;
484+
write_file($file, $preserve_MPL); # restore Makefile.PL
485+
$realclean_out = run("$make realclean");
486+
475487
sub _normalize {
476488
my $hash = shift;
477489
%$hash= map { lc($_) => $hash->{$_} } keys %$hash;

0 commit comments

Comments
 (0)