Distribution-Cooker

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

a module.

To build the distribution, run this file normally:

	% perl Makefile.PL

But, it's more interesting than that. You can load it with C<require>
and call C<arguments> to get the data structure it passes to
C<WriteMakefile>:

	my $package = require '/path/to/Makefile.PL';
	my $arguments = $package->arguments;

Note that C<require>-ing a file makes an entry in C<%INC> for exactly
that name. If you try to C<require> another file with the same name,
even from a different path, C<require> thinks it has already loaded
the file. As such, I recommend you always require the full path to the
file.

The return value of the C<require> is a package name (in this case,
the name of the main module. Use that to call the C<arguments> method.

xt/version_check.t  view on Meta::CPAN

	Makefile: @{[ makefile_minimum() ]}
HERE

ok( makefile_minimum() == module_minimum(), "Makefile version matches module version" )
	or diag( "Makefile: @{[makefile_minimum()]} Module: @{[module_minimum()]}" );

done_testing();

# Get the declared versions from the modules
sub module_minimum {
	state $ff = require File::Find;
	state $min_version = undef;

	return $min_version if defined $min_version;

	my @pm_files = ();
	my $wanted = sub {
		push @pm_files, $File::Find::name if $File::Find::name =~ /\.pm\z/;
		};
	File::Find::find( $wanted, 'lib' );

xt/version_check.t  view on Meta::CPAN

	return $min_version // '5.008';
	}

# Get the declared version from the Makefile.PL
sub makefile_minimum {
	state $min_version = undef;

	return $min_version if defined $min_version;

	delete $INC{'./Makefile.PL'};
	my $package = require './Makefile.PL';
	my $makefile_args = $package->arguments;
	my $declared = $makefile_args->{MIN_PERL_VERSION};
	$min_version = Perl::Version->new( $declared // '5.008' );

	return $min_version;
	}



( run in 0.467 second using v1.01-cache-2.11-cpan-0d8aa00de5b )