diff --git a/src/main/java/org/perlonjava/core/Configuration.java b/src/main/java/org/perlonjava/core/Configuration.java index 251f09a08..2976baaca 100644 --- a/src/main/java/org/perlonjava/core/Configuration.java +++ b/src/main/java/org/perlonjava/core/Configuration.java @@ -33,7 +33,7 @@ public final class Configuration { * Automatically populated by Gradle/Maven during build. * DO NOT EDIT MANUALLY - this value is replaced at build time. */ - public static final String gitCommitId = "e3750ee00"; + public static final String gitCommitId = "00acf915b"; /** * Git commit date of the build (ISO format: YYYY-MM-DD). @@ -48,7 +48,7 @@ public final class Configuration { * Parsed by App::perlbrew and other tools via: perl -V | grep "Compiled at" * DO NOT EDIT MANUALLY - this value is replaced at build time. */ - public static final String buildTimestamp = "Apr 28 2026 13:11:57"; + public static final String buildTimestamp = "Apr 28 2026 13:54:08"; // Prevent instantiation private Configuration() { diff --git a/src/main/perl/lib/ExtUtils/MakeMaker.pm b/src/main/perl/lib/ExtUtils/MakeMaker.pm index 36f4e7db2..bcdfab3ad 100644 --- a/src/main/perl/lib/ExtUtils/MakeMaker.pm +++ b/src/main/perl/lib/ExtUtils/MakeMaker.pm @@ -339,6 +339,7 @@ sub _install_pure_perl { 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'; return $mm; } @@ -398,6 +399,15 @@ sub _install_pure_perl { # Create Makefile with install commands (actual install deferred to 'make') _create_install_makefile($name, $version, $args, \%pm, \%scripts, $mm); + + # If Build.PL exists in cwd, the distribution was configured via Module::Build + # (or Module::Install's Build.PL-delegates-to-Makefile.PL trick). CPAN.pm will + # then invoke `./Build`, `./Build test`, `./Build install` instead of `make`. + # Write a thin Build script that delegates to the corresponding make targets, + # so the Module::Build flow works on top of our Makefile. + if (-f 'Build.PL') { + _create_build_script_proxy(); + } my $total = scalar(keys %pm) + scalar(keys %scripts); print "=" x 60, "\n"; @@ -738,6 +748,50 @@ sub _shell_cp { return "\t\@if [ -f '$src' ]; then rm -f '$dest' && cp '$src' '$dest'; else echo 'PerlOnJava: skipping missing source: $src'; fi"; } +# Write a tiny `Build` script that delegates to make targets. Some CPAN +# distributions ship a Build.PL whose only job is to delegate to Makefile.PL +# (Module::Install's "Dear Distribution Packager" trick, e.g. Data::Utilities). +# CPAN.pm sees Build.PL, sets $self->{modulebuild} = 1, and then expects to +# invoke `./Build`, `./Build test`, `./Build install`. Without a real +# Module::Build (which we don't run here because PerlOnJava MakeMaker took +# over WriteMakefile via Makefile.PL), no Build script is produced and the +# CPAN install fails with "no Build file available". This proxy bridges the +# gap by translating Module::Build subcommands to the corresponding make +# targets generated by _create_install_makefile. +sub _create_build_script_proxy { + my $build = 'Build'; + open my $fh, '>', $build or do { + warn "Note: Could not create Build script: $!\n"; + return; + }; + print $fh <<'BUILD'; +#!/usr/bin/env perl +# Generated by PerlOnJava MakeMaker as a Module::Build->make proxy. +# CPAN.pm runs this when a Build.PL was used to configure the dist. +use strict; +use warnings; +my $cmd = shift @ARGV; +$cmd = 'all' if !defined $cmd || $cmd eq '' || $cmd eq 'build'; +# Map Module::Build subcommands to make targets. Anything unknown is +# passed through verbatim so e.g. './Build distclean' still works. +my %map = ( + all => 'all', + test => 'test', + install => 'install', + clean => 'clean', + realclean => 'realclean', + distclean => 'distclean', + config => 'config', +); +my $target = exists $map{$cmd} ? $map{$cmd} : $cmd; +my @make = ($ENV{MAKE} || 'make', $target, @ARGV); +exec { $make[0] } @make + or die "PerlOnJava Build proxy: failed to exec '@make': $!\n"; +BUILD + close $fh; + chmod 0755, $build; +} + sub _create_mymeta { my ($name, $version, $args) = @_;