Permalink
Browse files

Rewrite all Makefile oneliners in terms of EU::MM::oneliner

  • Loading branch information...
1 parent 44e95db commit 3ba58fe4768f0cca6731dad6ac669b5ab049980e @ribasushi ribasushi committed Dec 16, 2012
Showing with 38 additions and 10 deletions.
  1. +7 −1 Makefile.PL
  2. +22 −5 maint/Makefile.PL.inc/11_authortests.pl
  3. +9 −4 maint/Makefile.PL.inc/53_autogen_pod.pl
View
@@ -146,9 +146,15 @@ if ($Module::Install::AUTHOR and ! $ENV{MAKELEVEL}) {
warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
}
+ # We need the MM facilities to generate the pieces for the final MM run.
+ # Just instantiate a throaway object here
+ my $mm_proto = ExtUtils::MakeMaker->new({
+ NAME => Meta->name || die 'The Module::Install metadata must be available at this point but is not - did you rearrange the Makefile.PL...?',
+ });
+
require File::Spec;
# string-eval, not do(), because we need to provide the
- # $reqs and $*_requires lexicals to the included file
+ # $mm_proto, $reqs and $*_requires lexicals to the included file
# (some includes *do* modify $reqs above)
for my $inc (sort glob ( File::Spec->catfile('maint', 'Makefile.PL.inc', '*') ) ) {
my $src = do { local (@ARGV, $/) = $inc; <> } or die $!;
@@ -9,21 +9,38 @@
);
}, 'xt');
-my $xt_tests = join (' ', map { File::Spec->catfile($_, '*.t') } sort keys %$xt_dirs );
+my @xt_tests = map { File::Spec->catfile($_, '*.t') } sort keys %$xt_dirs;
# this will add the xt tests to the `make test` target among other things
-Meta->tests(join (' ', map { $_ || () } Meta->tests, $xt_tests ) );
+Meta->tests(join (' ', map { $_ || () } Meta->tests, @xt_tests ) );
# inject an explicit xt test run for the create_distdir target
postamble <<"EOP";
create_distdir : test_xt
-test_xt :
-\tPERL_DL_NONLAZY=1 RELEASE_TESTING=1 \$(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness(\$(TEST_VERBOSE), 'inc', '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $xt_tests
+test_xt : pm_to_blib
+@{[
+ # When xt tests are explicitly requested, we want to run with RELEASE_TESTING=1
+ # so that all optdeps are turned into a hard failure
+ # However portably modifying ENV for a single command is surprisingly hard
+ # So instead we (ab)use perl's ability to stack -e options, and simply modify
+ # the ENV from within perl itself
+ $mm_proto->test_via_harness(
+ # perl cmd
+ join( ' ',
+ '$(ABSPERLRUN)',
+ # $'s need to be escaped (doubled) before inserting into the Makefile
+ map { $mm_proto->quote_literal($_) } qw(-e $$ENV{RELEASE_TESTING}=1;)
+ ),
+ # test list
+ join( ' ',
+ map { $mm_proto->quote_literal($_) } @xt_tests
+ ),
+ )
+]}
EOP
-
# keep the Makefile.PL eval happy
1;
@@ -29,7 +29,9 @@
clonedir_generate_files : dbic_clonedir_gen_optdeps_pod
dbic_clonedir_gen_optdeps_pod :
-\t\$(ABSPERLRUN) -Ilib -MDBIx::Class::Optional::Dependencies -e "DBIx::Class::Optional::Dependencies->_gen_pod(qw($ver $pod_dir))"
+\t@{[
+ $mm_proto->oneliner("DBIx::Class::Optional::Dependencies->_gen_pod(q($ver), q($pod_dir))", [qw/-Ilib -MDBIx::Class::Optional::Dependencies/])
+]}
EOP
}
@@ -62,8 +64,9 @@
dbic_clonedir_copy_generated_pod :
\t\$(RM_F) $pod_dir.packlist
-\t\$(ABSPERLRUN) -MExtUtils::Install -e 'install([ from_to => {qw($pod_dir lib write $pod_dir.packlist)}, verbose => 0, uninstall_shadows => 0, skip => [] ]);'
-
+\t@{[
+ $mm_proto->oneliner("install([ from_to => {q($pod_dir) => 'lib', write => q($pod_dir.packlist)}, verbose => 0, uninstall_shadows => 0, skip => [] ])", ['-MExtUtils::Install'])
+]}
EOP
}
@@ -75,7 +78,9 @@
clonedir_cleanup_generated_files : dbic_clonedir_cleanup_generated_pod_copies
dbic_clonedir_cleanup_generated_pod_copies :
-\t\$(ABSPERLRUN) -MExtUtils::Install -e 'uninstall(qw($pod_dir.packlist))'
+\t@{[
+ $mm_proto->oneliner("uninstall(q($pod_dir.packlist))", ['-MExtUtils::Install'])
+]}
EOP
}

0 comments on commit 3ba58fe

Please sign in to comment.