From: Karen Etheridge Date: Thu, 24 Apr 2014 03:57:19 +0000 (-0700) Subject: reverse order of data construction, to keep Cpanel::JSON::XS out of META.* X-Git-Tag: v1.002002~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=037386f7cb71bd68786a2dcc2ac5aec7fb1b86c7;p=p5sagit%2FJSON-MaybeXS.git reverse order of data construction, to keep Cpanel::JSON::XS out of META.* We need to use META_ADD and make that data look how we want it to be in META.*, then use that to construct PREREQ_PM etc (META_ADD rather than META_MERGE means that this data, based on the state of the releaser's machine, won't be added to META.* Of course, if we generated META.* via a different mechanism than EUMM, we wouldn't have to go to all this trouble... --- diff --git a/Changes b/Changes index f2b489e..fb00556 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for JSON-MaybeXS + - more metadata fiddling, to remove the Cpanel::JSON::XS dependency visible + to static analyzers (the prequisites at install time remain unchanged) + 1.002001 - 2014-04-23 - fix installation on older perls with an older ExtUtils::MakeMaker (RT#94964) diff --git a/Makefile.PL b/Makefile.PL index 8952a08..bd5408d 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -4,34 +4,36 @@ use 5.008001; use ExtUtils::MakeMaker; (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; -# we require Cpanel::JSON::XS, except if JSON::XS is already installed. -# (we also always recommend Cpanel::JSON::XS, just to make sure.) -my $require_cpanel_json_xs = can_xs() && !eval { require JSON::XS; 1; }; - my %WriteMakefileArgs = ( NAME => 'JSON::MaybeXS', VERSION_FROM => 'lib/JSON/MaybeXS.pm', - PREREQ_PM => { - 'JSON::PP' => '2.27202', - ($require_cpanel_json_xs - ? ('Cpanel::JSON::XS' => '2.3310') - : ()), - perl => '5.006', - }, - CONFIGURE_REQUIRES => { - 'ExtUtils::CBuilder' => '0.27', - 'File::Spec' => '0', - 'File::Temp' => '0', - }, - TEST_REQUIRES => { - 'Test::Without::Module' => '0.17', - 'Test::More' => '0.88' - }, - - META_MERGE => { + META_ADD => { 'meta-spec' => { version => 2 }, dynamic_config => 1, - prereqs => { runtime => { recommends => { 'Cpanel::JSON::XS' => '2.3310' } } }, + prereqs => { + configure => { + requires => { + 'ExtUtils::CBuilder' => '0.27', + 'File::Spec' => '0', + 'File::Temp' => '0', + }, + }, + runtime => { + requires => { + 'JSON::PP' => '2.27202', + # we may also add a runtime prereq for Cpanel::JSON::XS, on the + # installer's machine + perl => '5.006', + }, + recommends => { 'Cpanel::JSON::XS' => '2.3310' }, + }, + test => { + requires => { + 'Test::Without::Module' => '0.17', + 'Test::More' => '0.88', + }, + }, + }, resources => { repository => { @@ -50,6 +52,23 @@ my %WriteMakefileArgs = ( ); my $eumm_version = eval $ExtUtils::MakeMaker::VERSION; + +for (qw(configure build test runtime)) { + my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES'; + next unless exists $WriteMakefileArgs{META_ADD}{prereqs}{$_} + or exists $WriteMakefileArgs{$key}; + my $r = $WriteMakefileArgs{$key} = { + %{$WriteMakefileArgs{META_ADD}{prereqs}{$_}{requires} || {}}, + %{delete $WriteMakefileArgs{$key} || {}}, + }; + defined $r->{$_} or delete $r->{$_} for keys %$r; +} + +# we require Cpanel::JSON::XS, except if JSON::XS is already installed. +# (we also always recommend Cpanel::JSON::XS, just to make sure.) +$WriteMakefileArgs{PREREQ_PM}{'Cpanel::JSON::XS'} = '2.3310' + if can_xs() && !eval { require JSON::XS; 1; }; + $WriteMakefileArgs{MIN_PERL_VERSION} = delete $WriteMakefileArgs{PREREQ_PM}{perl} || 0; $WriteMakefileArgs{BUILD_REQUIRES} = { diff --git a/lib/JSON/MaybeXS.pm b/lib/JSON/MaybeXS.pm index d051116..c8f6154 100644 --- a/lib/JSON/MaybeXS.pm +++ b/lib/JSON/MaybeXS.pm @@ -4,7 +4,7 @@ use strict; use warnings FATAL => 'all'; use base qw(Exporter); -our $VERSION = '1.002001'; +our $VERSION = '1.002002'; sub _choose_json_module { return 'Cpanel::JSON::XS' if $INC{'Cpanel/JSON/XS.pm'};