Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/about/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ priorities and future plans.

## Work in progress

- Run MakeMaker `MY::post_initialize` hooks so generated files join `pm_to_blib`, and parse Perl's `$]` version variable.

- Preserve hash-reference constant calls after typeglob undefinition, dereference glob-backed hash values during Morpheus configuration traversal, parse Error.pm's dynamic `catch $class with { ... }` form on both backends, and retain integer scalar identity through `int()` for decimal stringification; preserve regex referent types through blessed scalar references and cover Morpheus relational overload dispatch and caller filename normalization (#1342, #1376, #1427, #1428).
- Implement `Time::HiRes::stat` with high-resolution file timestamps (#1912).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public static String parseComplexIdentifierInner(Parser parser, boolean insideBr

// Special case for special variables like `$|`, `$'`, `$(`, `$)`, etc.
char firstChar = token.text.charAt(0);
if (token.type == LexerTokenType.OPERATOR && "!|/*+-<>&~.=%'?()".indexOf(firstChar) >= 0) {
if (token.type == LexerTokenType.OPERATOR && "!|/*+-<>&~.=%'?()]".indexOf(firstChar) >= 0) {
// Special case: * followed by { is glob dereference when inside braces
// @{*{expr}} should be parsed as @{ *{expr} }, not @*{expr} (hash slice on @*)
// But @*{key} outside braces IS a hash slice on @*, so only apply when insideBraces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,8 @@ public static boolean isHashLiteral(Parser parser) {
// If we've already seen a fat-comma hash indicator at depth 1,
// keep preferring hash interpretation. This avoids false block
// classification when keyword-like words leak from quoted payload.
if (!hasHashIndicator && !nextToken.text.equals("=>") && !nextToken.text.equals(",")) {
if ((!hasHashIndicator || nextToken.text.equals("("))
&& !nextToken.text.equals("=>") && !nextToken.text.equals(",")) {
// Statement modifier - definitive block indicator
if (CompilerOptions.DEBUG_ENABLED) parser.ctx.logDebug("isHashLiteral found statement modifier (block indicator)");
hasBlockIndicator = true;
Expand Down
21 changes: 18 additions & 3 deletions src/main/perl/lib/ExtUtils/MakeMaker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,24 @@ sub _install_pure_perl {
}
}
}

# ExtUtils::MakeMaker subclasses use post_initialize to extend the
# initialized MakeMaker object, including its PM mapping. Older pure-Perl
# distributions use this to add generated data files to the normal
# pm_to_blib staging pass (for example, Lingua::ZH::Romanize::Pinyin).
# Run the hook after discovering the default mapping and before deciding
# whether the distribution has installable files.
my $mm = PerlOnJava::MM::Installed->new($args);
$mm->{PM} = { %pm };
$mm->{clean} = {};
if (defined &MY::post_initialize) {
$mm->{post_initialize} = MY::post_initialize($mm) // '';
%pm = %{$mm->{PM}} if ref $mm->{PM} eq 'HASH';
}

if (!%pm) {
print "Warning: No installable files found (no .pm, .pl, .dat, etc.).\n";
print "Expected structure: lib/Your/Module.pm\n\n";
my $mm = PerlOnJava::MM::Installed->new($args);
_create_mymeta($name, $version, $args);
_create_install_makefile($name, $version, $args, {}, {}, $mm);
_create_build_script_proxy() if -f 'Build.PL';
Expand Down Expand Up @@ -635,8 +648,6 @@ sub _install_pure_perl {
print "\n";

# Create MM object first (needed by postamble)
my $mm = PerlOnJava::MM::Installed->new($args);

# Create MYMETA.yml for CPAN.pm dependency resolution
_create_mymeta($name, $version, $args);

Expand Down Expand Up @@ -1091,6 +1102,9 @@ sub _create_install_makefile {
my $depend_rules_str = _make_depend_rules($args->{depend});

my $makefile_comments = _make_makefile_comments($args, $distname, $version);
my $post_initialize = $mm->{post_initialize} || '';
$post_initialize .= "\n" if length($post_initialize)
&& $post_initialize !~ /\n\z/;

# Honor user-supplied `macro => { ... }` from WriteMakefile by emitting
# extra Makefile macro definitions. LaTeXML and others stuff custom
Expand All @@ -1113,6 +1127,7 @@ sub _create_install_makefile {
# This matches standard ExtUtils::MakeMaker semantics so that 'cpan -t'
# (test only) does not install, while 'cpan -i' (install) does.
$makefile_comments
$post_initialize
NAME = $name
DISTNAME = $distname
VERSION = $version
Expand Down
41 changes: 41 additions & 0 deletions src/test/resources/unit/makemaker_post_initialize_generated_pm.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use strict;
use warnings;
use Test::More tests => 4;
use File::Temp qw(tempdir);
use Cwd qw(getcwd);

my $dir = tempdir(CLEANUP => 1);
my $cwd = getcwd();
chdir $dir or die "chdir $dir: $!";

mkdir 'lib' or die "mkdir lib: $!";
mkdir 'lib/Fixture' or die "mkdir lib/Fixture: $!";
open my $module, '>', 'lib/Fixture/Module.pm' or die $!;
print {$module} "package Fixture::Module; 1;\n";
close $module;
open my $makefile_pl, '>', 'Makefile.PL' or die $!;
print {$makefile_pl} "# generated test fixture\n";
close $makefile_pl;

{
package MY;
sub post_initialize {
my ($self) = @_;
$self->{clean}{FILES} = 'lib/Fixture/Generated.store';
$self->{PM}{'lib/Fixture/Generated.store'} = 'blib/lib/Fixture/Generated.store';
return '';
}
sub postamble {
return "\nlib/Fixture/Generated.store :\n\tprintf generated > lib/Fixture/Generated.store\n";
}
}

use ExtUtils::MakeMaker;
WriteMakefile(NAME => 'Fixture::Module', VERSION => '0.01');

ok(!-e 'lib/Fixture/Generated.store', 'configure does not fabricate generated data');
ok(-f 'Makefile', 'Makefile was generated');
is(system($ENV{MAKE} || 'make', 'all'), 0, 'make runs the custom generated-file rule');
ok(-f 'blib/lib/Fixture/Generated.store', 'pm_to_blib stages the generated file');

chdir $cwd or die "chdir $cwd: $!";
11 changes: 11 additions & 0 deletions src/test/resources/unit/special_version_variable.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use strict;
use warnings;
use Test::More;

{
plan skip_all => 'Perl 5.8.1 or better is required to test this' unless ( $] >= 5.008001 );
plan tests => 2;
ok($] >= 5.008001, '$] supports the standard Perl version comparison');
my $supported = 1 unless ($] < 5.008001);
ok($supported, '$] parses in a parenthesized unless condition');
}
Loading