summaryrefslogtreecommitdiffstats
path: root/inc/MMPackageStash.pm
diff options
context:
space:
mode:
Diffstat (limited to 'inc/MMPackageStash.pm')
-rw-r--r--inc/MMPackageStash.pm23
1 files changed, 18 insertions, 5 deletions
diff --git a/inc/MMPackageStash.pm b/inc/MMPackageStash.pm
index dd658da..5971c98 100644
--- a/inc/MMPackageStash.pm
+++ b/inc/MMPackageStash.pm
@@ -10,10 +10,11 @@ around _build_MakeFile_PL_template => sub {
my $xs_version = $self->zilla->prereqs->requirements_for('runtime', 'recommends')->as_string_hash->{'Package::Stash::XS'};
- # copied from M::I
- my $can_cc = <<'CAN_CC';
+ # can_run and can_cc copied from M::I
+ my $helpers = <<'HELPERS';
use Config ();
use File::Spec ();
+use Text::ParseWords ();
# check if we can run some command
sub can_run {
@@ -42,16 +43,28 @@ sub can_cc {
return;
}
-CAN_CC
+
+# XXX this is gross, but apparently it's the least gross option?
+sub parse_args {
+ my $tmp = {};
+ # copied from EUMM
+ ExtUtils::MakeMaker::parse_args(
+ $tmp,
+ Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''),
+ @ARGV,
+ );
+ return $tmp->{ARGS} || {};
+}
+HELPERS
my $fixup_prereqs = <<PREREQS;
\$WriteMakefileArgs{PREREQ_PM}{'Package::Stash::XS'} = $xs_version
- if can_cc();
+ if !parse_args()->{PUREPERL_ONLY} && can_cc();
PREREQS
my $template = $self->$orig(@_);
$template =~ s/(WriteMakefile\()/$fixup_prereqs\n$1/;
- $template .= $can_cc;
+ $template .= $helpers;
return $template;
};