summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-08-01 11:06:44 -0400
committerJesse Luehrs <doy@tozt.net>2013-08-01 11:09:31 -0400
commit5ceef90c2388f73c0de979cd19cb3ff5060ecb66 (patch)
treedaaa7a99bee3019ebb0ed0aafebd141b61afb247
parentea99455a19e79bbededbd31a5cb56ffc1f738845 (diff)
downloadparse-keyword-5ceef90c2388f73c0de979cd19cb3ff5060ecb66.tar.gz
parse-keyword-5ceef90c2388f73c0de979cd19cb3ff5060ecb66.zip
refactor this to make it easier to modify
-rw-r--r--Makefile.PL23
-rw-r--r--inc/MMHelper.pm26
-rw-r--r--inc/MakeMaker.pm19
3 files changed, 41 insertions, 27 deletions
diff --git a/Makefile.PL b/Makefile.PL
index 2179cc5..d6d0ece 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -8,19 +8,14 @@ use warnings;
use Config;
use ExtUtils::MakeMaker::Dist::Zilla::Develop;
-use Devel::CallParser 'callparser1_h', 'callparser_linkable';
-open my $fh, '>', 'callparser1.h' or die "Couldn't write to callparser1.h";
-$fh->print(callparser1_h);
+use inc::MMHelper;
-my @linkable = callparser_linkable;
-unshift @linkable, "Keyword$Config{obj_ext}" if @linkable;
-
-WriteMakefile(
- NAME => 'Parse::Keyword',
- clean => {
- FILES => "callparser1.h",
- },
- (@linkable
- ? (OBJECT => join(' ', @linkable))
- : ()),
+my %WriteMakefileArgs = (
+ NAME => 'Parse::Keyword',
+ %{ inc::MMHelper::mm_args() },
);
+
+eval inc::MMHelper::makefile_pl_extra . ';1;'
+ or die $@;
+
+WriteMakefile(%WriteMakefileArgs);
diff --git a/inc/MMHelper.pm b/inc/MMHelper.pm
new file mode 100644
index 0000000..8e42fa9
--- /dev/null
+++ b/inc/MMHelper.pm
@@ -0,0 +1,26 @@
+package inc::MMHelper;
+use strict;
+use warnings;
+
+sub makefile_pl_extra {
+ return <<'EXTRA';
+use Config;
+use Devel::CallParser 'callparser1_h', 'callparser_linkable';
+open my $fh, '>', 'callparser1.h' or die "Couldn't write to callparser1.h";
+$fh->print(callparser1_h);
+my @linkable = callparser_linkable;
+unshift @linkable, "Keyword$Config{obj_ext}" if @linkable;
+$WriteMakefileArgs{OBJECT} = join(' ', @linkable) if @linkable;
+EXTRA
+}
+
+sub mm_args {
+ return {
+ NORECURS => 1,
+ clean => {
+ FILES => "callparser1.h",
+ }
+ };
+}
+
+1;
diff --git a/inc/MakeMaker.pm b/inc/MakeMaker.pm
index 25cbf7e..bb31600 100644
--- a/inc/MakeMaker.pm
+++ b/inc/MakeMaker.pm
@@ -1,5 +1,6 @@
package inc::MakeMaker;
use Moose;
+use inc::MMHelper;
extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';
@@ -7,15 +8,7 @@ around _build_MakeFile_PL_template => sub {
my $orig = shift;
my $self = shift;
my $tmpl = $self->$orig;
- my $extra = <<'EXTRA';
-use Config;
-use Devel::CallParser 'callparser1_h', 'callparser_linkable';
-open my $fh, '>', 'callparser1.h' or die "Couldn't write to callparser1.h";
-$fh->print(callparser1_h);
-my @linkable = callparser_linkable;
-unshift @linkable, "Keyword$Config{obj_ext}" if @linkable;
-$WriteMakefileArgs{OBJECT} = join(' ', @linkable) if @linkable;
-EXTRA
+ my $extra = inc::MMHelper::makefile_pl_extra;
$tmpl =~ s/^(WriteMakefile\()/$extra\n$1/m
or die "Couldn't fix template";
return $tmpl;
@@ -25,10 +18,10 @@ around _build_WriteMakefile_args => sub {
my $orig = shift;
my $self = shift;
my $args = $self->$orig(@_);
- $args->{clean} = {
- FILES => "callparser1.h",
- };
- return $args;
+ return {
+ %$args,
+ %{ inc::MMHelper::mm_args() },
+ }
};
__PACKAGE__->meta->make_immutable;