From: Dave Rolsky Date: Tue, 28 Dec 2010 16:21:51 +0000 (-0500) Subject: Centralize MakeMaker customizations so they can be shared between dzil and dev-only... X-Git-Tag: 1.9900~3^2~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6bf5d14dc3eda832a81a0ad6fef0947518ad2aca;p=gitmo%2FMoose.git Centralize MakeMaker customizations so they can be shared between dzil and dev-only Makefile.PL --- diff --git a/Makefile.PL b/Makefile.PL index 0b9d0c3..5359a20 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -25,5 +25,5 @@ eval MMHelper::my_package_subs(); WriteMakefile( NAME => 'Moose', test => { TESTS => 't/*.t t/*/*.t' }, - MMHelper::mm_args(q{.}), + MMHelper::mm_args('dev'), ); diff --git a/dist.ini b/dist.ini index eedb3fa..d25967e 100644 --- a/dist.ini +++ b/dist.ini @@ -6,7 +6,11 @@ copyright_holder = Infinity Interactive, Inc. version = 1.9900 -[@Basic] +[@Filter] +bundle = @Basic +remove = MakeMaker + +[=inc::MakeMaker] [PruneFiles] filenames = Makefile.PL diff --git a/inc/MMHelper.pm b/inc/MMHelper.pm index fde6d5b..a63cd59 100644 --- a/inc/MMHelper.pm +++ b/inc/MMHelper.pm @@ -8,16 +8,17 @@ use Cwd qw( abs_path ); use File::Basename qw( dirname ); sub mm_args { - my $root = shift; + my $is_dev = shift; my $ccflags = ( $Config::Config{ccflags} || '' ) . ' -I.'; - $ccflags .= ' -Wall -Wdeclaration-after-statement'; + $ccflags .= ' -Wall -Wdeclaration-after-statement' + if $is_dev; my %mm = ( CCFLAGS => $ccflags ); my ( @object, %xs ); - for my $xs ( glob "$root/xs/*.xs" ) { + for my $xs ( glob "xs/*.xs" ) { ( my $c = $xs ) =~ s/\.xs$/.c/i; ( my $o = $xs ) =~ s/\.xs$/\$(OBJ_EXT)/i; @@ -25,7 +26,7 @@ sub mm_args { push @object, $o; } - for my $c ( glob "$root/*.c" ) { + for my $c ( glob "*.c" ) { ( my $o = $c ) =~ s/\.c$/\$(OBJ_EXT)/i; push @object, $o; } @@ -40,6 +41,7 @@ sub mm_args { sub my_package_subs { return <<'EOP'; +{ package MY; use Config; @@ -64,6 +66,7 @@ sub postamble { $(OBJECT) : mop.h EOF } +} EOP } diff --git a/inc/MakeMaker.pm b/inc/MakeMaker.pm index 8ff80d3..114d177 100644 --- a/inc/MakeMaker.pm +++ b/inc/MakeMaker.pm @@ -2,6 +2,32 @@ package inc::MakeMaker; use Moose; +use lib 'inc'; + use MMHelper; -with 'Dist::Zilla::Role::'; +extends 'Dist::Zilla::Plugin::MakeMaker::Awesome'; + +override _build_MakeFile_PL_template => sub { + my $self = shift; + + my $tmpl = super(); + + return $tmpl . "\n\n" . MMHelper::my_package_subs(); +}; + +override _build_WriteMakefile_args => sub { + my $self = shift; + + my $args = super(); + + return { + %{$args}, + MMHelper::mm_args(), + }; +}; + +1; + + +