| Dist::Zilla::Plugin::MakeMaker::Awesome - A more awesome MakeMaker plugin for L<Dist::Zilla> |
Dist::Zilla::Plugin::MakeMaker::Awesome - A more awesome MakeMaker plugin for the Dist::Zilla manpage
the Dist::Zilla manpage's MakeMaker plugin is
limited, if you want to stray from the marked path and do something
that would normally be done in a package MY section or otherwise
run custom code in your Makefile.PL you're out of luck.
This plugin is 100% compatable with the Dist::Zilla::Plugin::MakeMaker manpage, but if you need something more complex you can just subclass it:
Then, in your dist.ini:
;; Replace [MakeMaker]
;[MakeMaker]
[MakeMaker::Awesome]
More complex use, adding a package MY section to your
Makefile.PL:
In your dist.ini:
[=inc::MyDistMakeMaker / MyDistMakeMaker]
Then in your inc/MyDistMakeMaker.pm, real example from Hailo
(which has [=inc::HailoMakeMaker / HailoMakeMaker] in its
dist.ini):
package inc::HailoMakeMaker;
use Moose;
extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';
override _build_MakeFile_PL_template => sub {
my ($self) = @_;
my $template = super();
$template .= <<'TEMPLATE';
package MY;
sub test {
my $inherited = shift->SUPER::test(@_);
# Run tests with Moose and Mouse
$inherited =~ s/^test_dynamic :: pure_all\n\t(.*?)\n/test_dynamic :: pure_all\n\tANY_MOOSE=Mouse $1\n\tANY_MOOSE=Moose $1\n/m;
return $inherited;
}
TEMPLATE
return $template;
};
__PACKAGE__->meta->make_immutable;
Or maybe you're writing an XS distro and want to pass custom arguments
to WriteMakefile(), here's an example of adding a LIBS argument
in the re::engine::PCRE manpage:
package inc::PCREMakeMaker;
use Moose;
extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';
override _build_WriteMakefile_args => sub { +{
# Add LIBS => to WriteMakefile() args
%{ super() },
LIBS => [ '-lpcre' ],
} };
__PACKAGE__->meta->make_immutable;
And another example from the re::engine::Plan9 manpage:
package inc::Plan9MakeMaker;
use Moose;
extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';
override _build_WriteMakefile_args => sub {
my ($self) = @_;
our @DIR = qw(libutf libfmt libregexp);
our @OBJ = map { s/\.c$/.o/; $_ }
grep { ! /test/ }
glob "lib*/*.c";
return +{
%{ super() },
DIR => [ @DIR ],
INC => join(' ', map { "-I$_" } @DIR),
# This used to be '-shared lib*/*.o' but that doesn't work on Win32
LDDLFLAGS => "-shared @OBJ",
};
};
__PACKAGE__->meta->make_immutable;
If you have custom code in your the ExtUtils::MakeMaker manpage-based Makefile.PL that the Dist::Zilla manpage can't replace via its default facilities you'll be able replace it by using this module.
Even if your Makefile.PL isn't the ExtUtils::MakeMaker manpage-based you should be able to override it. You'll just have to provide a new _build_MakeFile_PL_template.
These are the methods you can currently the override manpage in your custom inc/ module. The work that this module does is entirely done in small modular methods that can be overriden in your subclass. Here are some of the highlights:
Returns the Text::Template manpage string used to construct the Makefile.PL.
A HashRef of arguments that'll be passed to
the ExtUtils::MakeMaker manpage's WriteMakefile function.
Takes the return value of _build_WriteMakefile_args and constructs a Str that'll be included in the Makefile.PL by _build_MakeFile_PL_template.
The test/bin/share dirs and exe_files. These'll all be passed to /"_build_WriteMakefile_args" later.
Used for the Dist::Zilla::Plugin::ShareDir manpage support. Don't touch it if you don't need some deep ShareDir magic.
An ArrayRef[Str] with two elements to be used by
_build_MakeFile_PL_template. The first will declare your
ShareDir and the second will add a magic
package MY section to install it. Deep magic.
The main entry point is setup_installer via the
the Dist::Zilla::Role::InstallTool manpage role. There are also other magic
Dist::Zilla roles, check the source for more info.
This plugin would suck less if the Dist::Zilla manpage didn't use a INI-based config system so you could add a stuff like this in your main configuration file like you can with the Module::Install manpage.
The .ini file format can only support key-value pairs whereas any
complex use of the ExtUtils::MakeMaker manpage requires running custom Perl
code and passing complex data structures to WriteMakefile.
Ævar Arnfjörð Bjarmason <avar@cpan.org>
Copyright 2010 Ævar Arnfjörð Bjarmason <avar@cpan.org>
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
| Dist::Zilla::Plugin::MakeMaker::Awesome - A more awesome MakeMaker plugin for L<Dist::Zilla> |