From: Dave Rolsky Date: Tue, 28 Dec 2010 15:55:49 +0000 (-0500) Subject: Move MakeMaker customizations to a module in inc that can be used for dzil and the... X-Git-Tag: 1.9900~3^2~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=004ac8d9484099572b66056101474c83ad154721;p=gitmo%2FMoose.git Move MakeMaker customizations to a module in inc that can be used for dzil and the dev-only Makefil.e.PL Also make sure our dev-only Makefile.PL sees all test files --- diff --git a/Makefile.PL b/Makefile.PL index b338413..0b9d0c3 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -4,6 +4,10 @@ use warnings; use Config; use ExtUtils::MakeMaker; +use lib 'inc'; + +use MMHelper; + warn <<'EOF'; ********************************* WARNING ********************************** @@ -16,61 +20,10 @@ warn <<'EOF'; EOF -my $ccflags = ( $Config::Config{ccflags} || '' ) . ' -I.'; -$ccflags .= ' -Wall -Wdeclaration-after-statement'; - -my %mm = ( CCFLAGS => $ccflags ); - -{ - my (@OBJECT, %XS); - - for my $xs () { - (my $c = $xs) =~ s/\.xs$/.c/i; - (my $o = $xs) =~ s/\.xs$/\$(OBJ_EXT)/i; - - $XS{$xs} = $c; - push @OBJECT, $o; - } - - for my $c (<*.c>) { - (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i; - push @OBJECT, $o; - } - - %mm = ( - %mm, - clean => { FILES => join( q{ }, @OBJECT ) }, - OBJECT => join( q{ }, @OBJECT ), - XS => \%XS, - ); -} +eval MMHelper::my_package_subs(); WriteMakefile( NAME => 'Moose', - %mm, + test => { TESTS => 't/*.t t/*/*.t' }, + MMHelper::mm_args(q{.}), ); - -package MY; - -use Config; - -sub const_cccmd { - my $ret = shift->SUPER::const_cccmd(@_); - return q{} unless $ret; - - if ($Config{cc} =~ /^cl\b/i) { - warn 'you are using MSVC... my condolences.'; - $ret .= ' /Fo$@'; - } - else { - $ret .= ' -o $@'; - } - - return $ret; -} - -sub postamble { - return <<'EOF'; -$(OBJECT) : mop.h -EOF -} diff --git a/inc/MMHelper.pm b/inc/MMHelper.pm new file mode 100644 index 0000000..fde6d5b --- /dev/null +++ b/inc/MMHelper.pm @@ -0,0 +1,70 @@ +package MMHelper; + +use strict; +use warnings; + +use Config; +use Cwd qw( abs_path ); +use File::Basename qw( dirname ); + +sub mm_args { + my $root = shift; + + my $ccflags = ( $Config::Config{ccflags} || '' ) . ' -I.'; + $ccflags .= ' -Wall -Wdeclaration-after-statement'; + + my %mm = ( CCFLAGS => $ccflags ); + + my ( @object, %xs ); + + for my $xs ( glob "$root/xs/*.xs" ) { + ( my $c = $xs ) =~ s/\.xs$/.c/i; + ( my $o = $xs ) =~ s/\.xs$/\$(OBJ_EXT)/i; + + $xs{$xs} = $c; + push @object, $o; + } + + for my $c ( glob "$root/*.c" ) { + ( my $o = $c ) =~ s/\.c$/\$(OBJ_EXT)/i; + push @object, $o; + } + + return ( + CCFLAGS => $ccflags, + clean => { FILES => join( q{ }, @object ) }, + OBJECT => join( q{ }, @object ), + XS => \%xs, + ); +} + +sub my_package_subs { + return <<'EOP'; +package MY; + +use Config; + +sub const_cccmd { + my $ret = shift->SUPER::const_cccmd(@_); + return q{} unless $ret; + + if ($Config{cc} =~ /^cl\b/i) { + warn 'you are using MSVC... my condolences.'; + $ret .= ' /Fo$@'; + } + else { + $ret .= ' -o $@'; + } + + return $ret; +} + +sub postamble { + return <<'EOF'; +$(OBJECT) : mop.h +EOF +} +EOP +} + +1; diff --git a/inc/MakeMaker.pm b/inc/MakeMaker.pm new file mode 100644 index 0000000..8ff80d3 --- /dev/null +++ b/inc/MakeMaker.pm @@ -0,0 +1,7 @@ +package inc::MakeMaker; + +use Moose; + +use MMHelper; + +with 'Dist::Zilla::Role::';