Hello community, here is the log from the commit of package perl-JSON-MaybeXS for openSUSE:Factory checked in at 2018-02-07 18:43:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-JSON-MaybeXS (Old) and /work/SRC/openSUSE:Factory/.perl-JSON-MaybeXS.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-JSON-MaybeXS" Wed Feb 7 18:43:21 2018 rev:4 rq:573770 version:1.003010 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-JSON-MaybeXS/perl-JSON-MaybeXS.changes 2017-03-28 15:20:54.452737603 +0200 +++ /work/SRC/openSUSE:Factory/.perl-JSON-MaybeXS.new/perl-JSON-MaybeXS.changes 2018-02-07 18:43:22.814657154 +0100 @@ -1,0 +2,11 @@ +Wed Feb 7 15:42:12 UTC 2018 - [email protected] + +- updated to 1.003010 + see /usr/share/doc/packages/perl-JSON-MaybeXS/Changes + + 1.003010 - 2018-01-28 + - use bundled ExtUtils::HasCompiler rather than ExtUtils::CBuilder to detect + compiler availability. + - clarify exported JSON in documentation + +------------------------------------------------------------------- Old: ---- JSON-MaybeXS-1.003009.tar.gz New: ---- JSON-MaybeXS-1.003010.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-JSON-MaybeXS.spec ++++++ --- /var/tmp/diff_new_pack.AIK130/_old 2018-02-07 18:43:23.442627751 +0100 +++ /var/tmp/diff_new_pack.AIK130/_new 2018-02-07 18:43:23.446627564 +0100 @@ -1,7 +1,7 @@ # # spec file for package perl-JSON-MaybeXS # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,21 +17,20 @@ Name: perl-JSON-MaybeXS -Version: 1.003009 +Version: 1.003010 Release: 0 %define cpan_name JSON-MaybeXS Summary: Use L<Cpanel::JSON::XS> with a fallback to L<JSON::XS> and L<JSON::PP> License: Artistic-1.0 or GPL-1.0+ Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/JSON-MaybeXS/ -Source0: https://cpan.metacpan.org/authors/id/E/ET/ETHER/%{cpan_name}-%{version}.tar.gz +Source0: https://cpan.metacpan.org/authors/id/H/HA/HAARG/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(Cpanel::JSON::XS) >= 2.3310 -BuildRequires: perl(ExtUtils::CBuilder) >= 0.27 BuildRequires: perl(JSON::PP) >= 2.27300 BuildRequires: perl(Test::More) >= 0.88 Requires: perl(Cpanel::JSON::XS) >= 2.3310 ++++++ JSON-MaybeXS-1.003009.tar.gz -> JSON-MaybeXS-1.003010.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/Changes new/JSON-MaybeXS-1.003010/Changes --- old/JSON-MaybeXS-1.003009/Changes 2017-02-27 08:26:50.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/Changes 2018-01-28 02:42:13.000000000 +0100 @@ -1,5 +1,10 @@ Revision history for JSON-MaybeXS +1.003010 - 2018-01-28 + - use bundled ExtUtils::HasCompiler rather than ExtUtils::CBuilder to detect + compiler availability. + - clarify exported JSON in documentation + 1.003009 - 2017-02-27 - fix tests to no longer rely on . being in @INC (RT#120404) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/MANIFEST new/JSON-MaybeXS-1.003010/MANIFEST --- old/JSON-MaybeXS-1.003009/MANIFEST 2017-02-27 08:27:21.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/MANIFEST 2018-01-28 02:42:23.000000000 +0100 @@ -1,4 +1,5 @@ Changes +inc/ExtUtils/HasCompiler.pm lib/JSON/MaybeXS.pm maint/Makefile.PL.include Makefile.PL diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/META.json new/JSON-MaybeXS-1.003010/META.json --- old/JSON-MaybeXS-1.003009/META.json 2017-02-27 08:27:21.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/META.json 2018-01-28 02:42:22.000000000 +0100 @@ -4,7 +4,7 @@ "mst - Matt S. Trout (cpan:MSTROUT) <[email protected]>" ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 7.2501, CPAN::Meta::Converter version 2.150010", + "generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010", "keywords" : [ "json", "serializer", @@ -22,16 +22,14 @@ "no_index" : { "directory" : [ "t", - "inc" + "xt" ] }, "prereqs" : { + "build" : {}, "configure" : { "requires" : { - "ExtUtils::CBuilder" : "0.27", - "ExtUtils::MakeMaker" : "0", - "File::Spec" : "0", - "File::Temp" : "0" + "ExtUtils::MakeMaker" : "0" } }, "runtime" : { @@ -57,13 +55,16 @@ "mailto" : "[email protected]", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=JSON-MaybeXS" }, + "license" : [ + "http://dev.perl.org/licenses/" + ], "repository" : { "type" : "git", "url" : "https://github.com/p5sagit/JSON-MaybeXS.git", "web" : "https://github.com/p5sagit/JSON-MaybeXS" } }, - "version" : "1.003009", + "version" : "1.003010", "x_contributors" : [ "Clinton Gormley <[email protected]>", "Graham Knop <[email protected]>", @@ -72,5 +73,5 @@ "Kieren Diment <[email protected]>", "Matt S Trout <[email protected]>" ], - "x_serialization_backend" : "JSON::MaybeXS version 1.003008" + "x_serialization_backend" : "JSON::PP version 2.97000" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/META.yml new/JSON-MaybeXS-1.003010/META.yml --- old/JSON-MaybeXS-1.003009/META.yml 2017-02-27 08:27:21.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/META.yml 2018-01-28 02:42:22.000000000 +0100 @@ -5,12 +5,9 @@ build_requires: Test::More: '0.88' configure_requires: - ExtUtils::CBuilder: '0.27' ExtUtils::MakeMaker: '0' - File::Spec: '0' - File::Temp: '0' dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 7.2501, CPAN::Meta::Converter version 2.150010' +generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010' keywords: - json - serializer @@ -24,7 +21,7 @@ no_index: directory: - t - - inc + - xt recommends: Cpanel::JSON::XS: '2.3310' requires: @@ -34,8 +31,9 @@ perl: '5.006' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=JSON-MaybeXS + license: http://dev.perl.org/licenses/ repository: https://github.com/p5sagit/JSON-MaybeXS.git -version: '1.003009' +version: '1.003010' x_contributors: - 'Clinton Gormley <[email protected]>' - 'Graham Knop <[email protected]>' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/Makefile.PL new/JSON-MaybeXS-1.003010/Makefile.PL --- old/JSON-MaybeXS-1.003009/Makefile.PL 2017-02-27 08:24:33.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/Makefile.PL 2017-09-26 23:02:08.000000000 +0200 @@ -1,137 +1,91 @@ use strict; use warnings FATAL => 'all'; +use 5.006; +use lib 'inc'; +use ExtUtils::HasCompiler qw(can_compile_loadable_object); use ExtUtils::MakeMaker; -(do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; -my %WriteMakefileArgs = ( - NAME => 'JSON::MaybeXS', - VERSION_FROM => 'lib/JSON/MaybeXS.pm', - - META_MERGE => { - 'meta-spec' => { version => 2 }, - dynamic_config => 1, - resources => { - # GitHub mirrors from Shadowcat. We list it so we can get pull requests. - # The canonical repo is: - # r/o: git://git.shadowcat.co.uk/p5sagit/JSON-MaybeXS.git - # r/w: [email protected]:JSON-MaybeXS.git - # web: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/JSON-MaybeXS.git - repository => { - url => 'https://github.com/p5sagit/JSON-MaybeXS.git', - web => 'https://github.com/p5sagit/JSON-MaybeXS', - type => 'git', - }, - bugtracker => { - mailto => '[email protected]', - web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=JSON-MaybeXS', +my %META = ( + name => 'JSON-MaybeXS', + license => 'perl_5', + dynamic_config => 1, + prereqs => { + configure => { + requires => { + 'ExtUtils::MakeMaker' => '0', }, }, - x_contributors => [ # manually added, from git shortlog -e -s -n - 'Clinton Gormley <[email protected]>', - 'Graham Knop <[email protected]>', - 'John SJ Anderson <[email protected]>', - 'Karen Etheridge <[email protected]>', - 'Kieren Diment <[email protected]>', - 'Matt S Trout <[email protected]>', - ], - keywords => [ qw(json serializer serialiser data) ], - }, - - META_ADD => { - 'meta-spec' => { version => 2 }, - prereqs => { - configure => { - requires => { - 'ExtUtils::MakeMaker' => '0', - 'ExtUtils::CBuilder' => '0.27', - 'File::Spec' => '0', - 'File::Temp' => '0', - }, - }, - runtime => { - requires => { - 'Scalar::Util' => '0', - 'Carp' => '0', - 'JSON::PP' => '2.27300', - # 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' }, + runtime => { + requires => { + 'Scalar::Util' => '0', + 'Carp' => '0', + 'JSON::PP' => '2.27300', + # we may also add a runtime prereq for Cpanel::JSON::XS, on the + # installer's machine + perl => '5.006', }, - test => { - requires => { - 'Test::More' => '0.88', - }, + recommends => { 'Cpanel::JSON::XS' => '2.3310' }, + }, + test => { + requires => { + 'Test::More' => '0.88', }, }, }, + resources => { + # GitHub mirrors from Shadowcat. We list it so we can get pull requests. + # The canonical repo is: + # r/o: git://git.shadowcat.co.uk/p5sagit/JSON-MaybeXS.git + # r/w: [email protected]:JSON-MaybeXS.git + # web: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/JSON-MaybeXS.git + repository => { + url => 'https://github.com/p5sagit/JSON-MaybeXS.git', + web => 'https://github.com/p5sagit/JSON-MaybeXS', + type => 'git', + }, + bugtracker => { + mailto => '[email protected]', + web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=JSON-MaybeXS', + }, + license => [ 'http://dev.perl.org/licenses/' ], + }, + x_contributors => [ # manually added, from git shortlog -e -s -n + 'Clinton Gormley <[email protected]>', + 'Graham Knop <[email protected]>', + 'John SJ Anderson <[email protected]>', + 'Karen Etheridge <[email protected]>', + 'Kieren Diment <[email protected]>', + 'Matt S Trout <[email protected]>', + ], + keywords => [ qw(json serializer serialiser data) ], + no_index => { + directory => [ 't', 'xt' ] + }, ); -my $eumm_version = eval $ExtUtils::MakeMaker::VERSION; +my %MM_ARGS = (); -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; +if (! parse_args()->{PUREPERL_ONLY}) { + # we require Cpanel::JSON::XS, except if JSON::XS is already installed. + # (we also always recommend Cpanel::JSON::XS, just to make sure.) + $MM_ARGS{PREREQ_PM}{'Cpanel::JSON::XS'} = '2.3310' + if eval { require Cpanel::JSON::XS; 1 } + or ( + not eval { require JSON::XS; 1; } + and can_compile_loadable_object(quiet => 1) + ); + + # JSON::XS 3 changed its boolean handling - update it + # if JSON::XS is installed and < 3.0 + $MM_ARGS{PREREQ_PM}{'JSON::XS'} = '3.00' + if eval { require JSON::XS; 1 } + and not eval { JSON::XS->VERSION('3.0'); 1 }; } -# dynamic prereqs get added here. - -my $args = parse_args(); - -if (not $args->{PUREPERL_ONLY}) { - # 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 eval { require Cpanel::JSON::XS; 1 } - or (not eval { require JSON::XS; 1; } and can_xs()); - - # JSON::XS 3 changed its boolean handling - update it - # if JSON::XS is installed and < 3.0 - $WriteMakefileArgs{PREREQ_PM}{'JSON::XS'} = '3.00' - if eval { require JSON::XS; 1 } and not eval { JSON::XS->VERSION('3.0'); 1 }; -} - -$WriteMakefileArgs{MIN_PERL_VERSION} = delete $WriteMakefileArgs{PREREQ_PM}{perl} || 0; - -die 'attention developer: you need to do a sane meta merge here!' - if keys %{$WriteMakefileArgs{BUILD_REQUIRES}}; - -$WriteMakefileArgs{BUILD_REQUIRES} = { - %{$WriteMakefileArgs{BUILD_REQUIRES} || {}}, - %{delete $WriteMakefileArgs{TEST_REQUIRES}} -} if $eumm_version < 6.63_03; - -$WriteMakefileArgs{PREREQ_PM} = { - %{$WriteMakefileArgs{PREREQ_PM}}, - %{delete $WriteMakefileArgs{BUILD_REQUIRES}} -} if $eumm_version < 6.55_01; - -delete $WriteMakefileArgs{CONFIGURE_REQUIRES} - if $eumm_version < 6.51_03; - -delete $WriteMakefileArgs{MIN_PERL_VERSION} - if $eumm_version < 6.48; - -delete @WriteMakefileArgs{qw(META_ADD META_MERGE)} - if $eumm_version < 6.46; - -delete $WriteMakefileArgs{LICENSE} - if $eumm_version < 6.31; - -WriteMakefile(%WriteMakefileArgs); - +use Text::ParseWords; sub parse_args { # copied from EUMM - require ExtUtils::MakeMaker; - require Text::ParseWords; ExtUtils::MakeMaker::parse_args( my $tmp = {}, Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''), @@ -140,101 +94,45 @@ return $tmp->{ARGS} || {}; } -# can we locate a (the) C compiler -sub can_cc { - my @chunks = split(/ /, $Config::Config{cc}) or return; - - # $Config{cc} may contain args; try to find out the program part - while (@chunks) { - return can_run("@chunks") || (pop(@chunks), next); - } - - return; -} - -# check if we can run some command -sub can_run { - my ($cmd) = @_; - - return $cmd if -x $cmd; - if (my $found_cmd = MM->maybe_command($cmd)) { - return $found_cmd; - } - - require File::Spec; - for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { - next if $dir eq ''; - my $abs = File::Spec->catfile($dir, $cmd); - return $abs if (-x $abs or $abs = MM->maybe_command($abs)); - } - - return; -} +## BOILERPLATE ############################################################### +require ExtUtils::MakeMaker; +(do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; -# Can our C compiler environment build XS files -sub can_xs { - # Do we have the configure_requires checker? - local $@; - eval "require ExtUtils::CBuilder; ExtUtils::CBuilder->VERSION(0.27)"; - if ( $@ ) { - # They don't obey configure_requires, so it is - # someone old and delicate. Try to avoid hurting - # them by falling back to an older simpler test. - return can_cc(); - } - - # Do we have a working C compiler - my $builder = ExtUtils::CBuilder->new( - quiet => 1, - ); - unless ( $builder->have_compiler ) { - # No working C compiler - return 0; - } - - # Write a C file representative of what XS becomes - require File::Temp; - my ( $FH, $tmpfile ) = File::Temp::tempfile( - "compilexs-XXXXX", - SUFFIX => '.c', - ); - binmode $FH; - print $FH <<'END_C'; -#include "EXTERN.h" -#include "perl.h" -#include "XSUB.h" +# have to do this since old EUMM dev releases miss the eval $VERSION line +my $eumm_version = eval $ExtUtils::MakeMaker::VERSION; +my $mymeta = $eumm_version >= 6.57_02; +my $mymeta_broken = $mymeta && $eumm_version < 6.57_07; -int main(int argc, char **argv) { - return 0; -} +($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g; +($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g; +$META{license} = [ $META{license} ] + if $META{license} && !ref $META{license}; +$MM_ARGS{LICENSE} = $META{license}[0] + if $META{license} && $eumm_version >= 6.30; +$MM_ARGS{NO_MYMETA} = 1 + if $mymeta_broken; +$MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META } + unless -f 'META.yml'; -int boot_sanexs() { - return 1; +for (qw(configure build test runtime)) { + my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES'; + my $r = $MM_ARGS{$key} = { + %{$META{prereqs}{$_}{requires} || {}}, + %{delete $MM_ARGS{$key} || {}}, + }; + defined $r->{$_} or delete $r->{$_} for keys %$r; } -END_C - close $FH; - - # Can the C compiler access the same headers XS does - my @libs = (); - my $object = undef; - eval { - local $^W = 0; - $object = $builder->compile( - source => $tmpfile, - ); - @libs = $builder->link( - objects => $object, - module_name => 'sanexs', - ); - }; - my $result = $@ ? 0 : 1; +$MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0; - # Clean up all the build files - foreach ( $tmpfile, $object, @libs ) { - next unless defined $_; - 1 while unlink; - } +delete $MM_ARGS{MIN_PERL_VERSION} + if $eumm_version < 6.47_01; +$MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}} + if $eumm_version < 6.63_03; +$MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}} + if $eumm_version < 6.55_01; +delete $MM_ARGS{CONFIGURE_REQUIRES} + if $eumm_version < 6.51_03; - return $result; -} +ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS); +## END BOILERPLATE ########################################################### diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/README new/JSON-MaybeXS-1.003010/README --- old/JSON-MaybeXS-1.003009/README 2017-02-27 08:27:21.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/README 2018-01-28 02:42:22.000000000 +0100 @@ -9,7 +9,7 @@ my $json_output = encode_json($data_structure); - my $json = JSON->new; + my $json = JSON()->new; my $json_with_args = JSON::MaybeXS->new(utf8 => 1); # or { utf8 => 1 } @@ -75,12 +75,16 @@ The "JSON" constant returns the selected implementation module's name for use as a class name - so: - my $json_obj = JSON->new; # returns a Cpanel::JSON::XS or JSON::PP object + my $json_obj = JSON()->new; # returns a Cpanel::JSON::XS or JSON::PP object and that object can then be used normally: my $data_structure = $json_obj->decode($json_text); # etc. + The use of parentheses here is optional, and only used as a hint to the + reader that this use of "JSON" is a *subroutine* call, *not* a class + name. + is_bool $is_boolean = is_bool($scalar) @@ -115,8 +119,8 @@ To include JSON-aware booleans ("true", "false") in your data, just do: use JSON::MaybeXS; - my $true = JSON->true; - my $false = JSON->false; + my $true = JSON()->true; + my $false = JSON()->false; CONVERTING FROM JSON::Any JSON::Any used to be the favoured compatibility layer above the various diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/inc/ExtUtils/HasCompiler.pm new/JSON-MaybeXS-1.003010/inc/ExtUtils/HasCompiler.pm --- old/JSON-MaybeXS-1.003009/inc/ExtUtils/HasCompiler.pm 1970-01-01 01:00:00.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/inc/ExtUtils/HasCompiler.pm 2018-01-28 02:37:37.000000000 +0100 @@ -0,0 +1,304 @@ +package ExtUtils::HasCompiler; +$ExtUtils::HasCompiler::VERSION = '0.021'; +use strict; +use warnings; + +use base 'Exporter'; +our @EXPORT_OK = qw/can_compile_loadable_object can_compile_static_library can_compile_extension/; +our %EXPORT_TAGS = (all => \@EXPORT_OK); + +use Config; +use Carp 'carp'; +use File::Basename 'basename'; +use File::Spec::Functions qw/catfile catdir rel2abs/; +use File::Temp qw/tempdir tempfile/; + +my $tempdir = tempdir('HASCOMPILERXXXX', CLEANUP => 1, DIR => '.'); + +my $loadable_object_format = <<'END'; +#define PERL_NO_GET_CONTEXT +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#ifndef PERL_UNUSED_VAR +#define PERL_UNUSED_VAR(var) +#endif + +XS(exported) { +#ifdef dVAR + dVAR; +#endif + dXSARGS; + + PERL_UNUSED_VAR(cv); /* -W */ + PERL_UNUSED_VAR(items); /* -W */ + + XSRETURN_IV(42); +} + +#ifndef XS_EXTERNAL +#define XS_EXTERNAL(foo) XS(foo) +#endif + +/* we don't want to mess with .def files on mingw */ +#if defined(WIN32) && defined(__GNUC__) +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +EXPORT XS_EXTERNAL(boot_%s) { +#ifdef dVAR + dVAR; +#endif + dXSARGS; + + PERL_UNUSED_VAR(cv); /* -W */ + PERL_UNUSED_VAR(items); /* -W */ + + newXS("%s::exported", exported, __FILE__); +} + +END + +my $counter = 1; +my %prelinking = map { $_ => 1 } qw/MSWin32 VMS aix/; + +sub can_compile_loadable_object { + my %args = @_; + + my $output = $args{output} || \*STDOUT; + + my $config = $args{config} || 'ExtUtils::HasCompiler::Config'; + return if not $config->get('usedl'); + + my ($source_handle, $source_name) = tempfile('TESTXXXX', DIR => $tempdir, SUFFIX => '.c', UNLINK => 1); + my $basename = basename($source_name, '.c'); + my $abs_basename = catfile($tempdir, $basename); + + my ($cc, $ccflags, $optimize, $cccdlflags, $ld, $ldflags, $lddlflags, $libperl, $perllibs, $archlibexp, $_o, $dlext) = map { $config->get($_) } qw/cc ccflags optimize cccdlflags ld ldflags lddlflags libperl perllibs archlibexp _o dlext/; + + my $incdir = catdir($archlibexp, 'CORE'); + my $object_file = $abs_basename.$_o; + my $loadable_object = "$abs_basename.$dlext"; + + my @commands; + if ($^O eq 'MSWin32' && $cc =~ /^cl/) { + push @commands, qq{$cc $ccflags $cccdlflags $optimize /I "$incdir" /c $source_name /Fo$object_file}; + push @commands, qq{$ld $object_file $lddlflags $libperl $perllibs /out:$loadable_object /def:$abs_basename.def /pdb:$abs_basename.pdb}; + } + elsif ($^O eq 'VMS') { + # Mksymlists is only the beginning of the story. + open my $opt_fh, '>>', "$abs_basename.opt" or do { carp "Couldn't append to '$abs_basename.opt'"; return }; + print $opt_fh "PerlShr/Share\n"; + close $opt_fh; + + my $incdirs = $ccflags =~ s{ /inc[^=]+ (?:=)+ (?:\()? ( [^\/\)]* ) }{}xi ? "$1,$incdir" : $incdir; + push @commands, qq{$cc $ccflags $optimize /include=($incdirs) $cccdlflags $source_name /obj=$object_file}; + push @commands, qq{$ld $ldflags $lddlflags=$loadable_object $object_file,$abs_basename.opt/OPTIONS,${incdir}perlshr_attr.opt/OPTIONS' $perllibs}; + } + else { + my @extra; + if ($^O eq 'MSWin32') { + my $lib = '-l' . ($libperl =~ /lib([^.]+)\./)[0]; + push @extra, "$abs_basename.def", $lib, $perllibs; + } + elsif ($^O eq 'cygwin') { + push @extra, catfile($incdir, $config->get('useshrplib') ? 'libperl.dll.a' : 'libperl.a'); + } + elsif ($^O eq 'aix') { + $lddlflags =~ s/\Q$(BASEEXT)\E/$abs_basename/; + $lddlflags =~ s/\Q$(PERL_INC)\E/$incdir/; + } + elsif ($^O eq 'android') { + push @extra, qq{"-L$incdir"}, '-lperl', $perllibs; + } + push @commands, qq{$cc $ccflags $optimize "-I$incdir" $cccdlflags -c $source_name -o $object_file}; + push @commands, qq{$ld $object_file -o $loadable_object $lddlflags @extra}; + } + + if ($prelinking{$^O}) { + require ExtUtils::Mksymlists; + ExtUtils::Mksymlists::Mksymlists(NAME => $basename, FILE => $abs_basename, IMPORTS => {}); + } + + my $shortname = '_Loadable' . $counter++; + my $package = "ExtUtils::HasCompiler::$shortname"; + printf $source_handle $loadable_object_format, $basename, $package or do { carp "Couldn't write to $source_name: $!"; return }; + close $source_handle or do { carp "Couldn't close $source_name: $!"; return }; + + for my $command (@commands) { + print $output "$command\n" if not $args{quiet}; + system $command and do { carp "Couldn't execute $command: $!"; return }; + } + + # Skip loading when cross-compiling + return 1 if exists $args{skip_load} ? $args{skip_load} : $config->get('usecrosscompile'); + + require DynaLoader; + local @DynaLoader::dl_require_symbols = "boot_$basename"; + my $handle = DynaLoader::dl_load_file(rel2abs($loadable_object), 0); + if ($handle) { + my $symbol = DynaLoader::dl_find_symbol($handle, "boot_$basename") or do { carp "Couldn't find boot symbol for $basename"; return }; + my $compilet = DynaLoader::dl_install_xsub('__ANON__::__ANON__', $symbol, $source_name); + my $ret = eval { $compilet->(); $package->exported } or carp $@; + delete $ExtUtils::HasCompiler::{"$shortname\::"}; + eval { DynaLoader::dl_unload_file($handle) } or carp $@; + return defined $ret && $ret == 42; + } + else { + carp "Couldn't load $loadable_object: " . DynaLoader::dl_error(); + return; + } +} + +my %static_unsupported_on = map { $_ => 1 } qw/VMS aix MSWin32 cygwin/; +sub can_compile_static_library { + my %args = @_; + + my $output = $args{output} || \*STDOUT; + + my $config = $args{config} || 'ExtUtils::HasCompiler::Config'; + return if $config->get('useshrplib') eq 'true'; + + my ($source_handle, $source_name) = tempfile('TESTXXXX', DIR => $tempdir, SUFFIX => '.c', UNLINK => 1); + my $basename = basename($source_name, '.c'); + my $abs_basename = catfile($tempdir, $basename); + + my ($cc, $ccflags, $optimize, $ar, $full_ar, $ranlib, $archlibexp, $_o, $lib_ext) = map { $config->get($_) } qw/cc ccflags optimize ar full_ar ranlib archlibexp _o lib_ext/; + my $incdir = catdir($archlibexp, 'CORE'); + my $object_file = "$abs_basename$_o"; + my $static_library = $abs_basename.$lib_ext; + + my @commands; + if ($static_unsupported_on{$^O}) { + return; + } + else { + my $my_ar = length $full_ar ? $full_ar : $ar; + push @commands, qq{$cc $ccflags $optimize "-I$incdir" -c $source_name -o $object_file}; + push @commands, qq{$my_ar cr $static_library $object_file}; + push @commands, qq{$ranlib $static_library} if $ranlib ne ':'; + } + + my $shortname = '_Loadable' . $counter++; + my $package = "ExtUtils::HasCompiler::$shortname"; + printf $source_handle $loadable_object_format, $basename, $package or do { carp "Couldn't write to $source_name: $!"; return }; + close $source_handle or do { carp "Couldn't close $source_name: $!"; return }; + + for my $command (@commands) { + print $output "$command\n" if not $args{quiet}; + system $command and do { carp "Couldn't execute $command: $!"; return }; + } + return 1; +} + +sub can_compile_extension { + my %args = @_; + $args{config} ||= 'ExtUtils::HasCompiler::Config'; + my $linktype = $args{linktype} || ($args{config}->get('usedl') ? 'dynamic' : 'static'); + return $linktype eq 'static' ? can_compile_static_library(%args) : can_compile_loadable_object(%args); +} + +sub ExtUtils::HasCompiler::Config::get { + my (undef, $key) = @_; + return $ENV{uc $key} || $Config{$key}; +} + +1; + +# ABSTRACT: Check for the presence of a compiler + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +ExtUtils::HasCompiler - Check for the presence of a compiler + +=head1 VERSION + +version 0.021 + +=head1 SYNOPSIS + + use ExtUtils::HasCompiler 'can_compile_extension'; + if (can_compile_extension()) { + ... + } + else { + ... + } + +=head1 DESCRIPTION + +This module tries to check if the current system is capable of compiling, linking and loading an XS module. + +B<Notice>: this is an early release, interface stability isn't guaranteed yet. + +=head1 FUNCTIONS + +=head2 can_compile_loadable_object(%opts) + +This checks if the system can compile, link and load a perl loadable object. It may take the following options: + +=over 4 + +=item * quiet + +Do not output the executed compilation commands. + +=item * config + +An L<ExtUtils::Config|ExtUtils::Config> (compatible) object for configuration. + +=item * skip_load + +This causes can_compile_loadable_object to not try to load the generated object. This defaults to true on a cross-compiling perl. + +=back + +=head2 can_compile_static_library(%opts) + +This checks if the system can compile and link a perl static library. It does not check it it can compile a new perl with it. It may take the following options: + +=over 4 + +=item * quiet + +Do not output the executed compilation commands. + +=item * config + +An L<ExtUtils::Config|ExtUtils::Config> (compatible) object for configuration. + +=back + +=head2 can_compile_extension(%opts) + +This will call either C<can_compile_loadable_object>, or C<can_compile_static_library>, depending on which is the default on your configuration. In addition to the arguments listed above, it can take one more optional argument: + +=over 4 + +=item * linktype + +This will force the linktype to be either static or dynamic. Dynamic compilation on a static perl won't work, but static libraries can be viable on a dynamic perl. + +=back + +=head1 AUTHOR + +Leon Timmermans <[email protected]> + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2014 by Leon Timmermans. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/lib/JSON/MaybeXS.pm new/JSON-MaybeXS-1.003010/lib/JSON/MaybeXS.pm --- old/JSON-MaybeXS-1.003009/lib/JSON/MaybeXS.pm 2017-02-27 08:26:30.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/lib/JSON/MaybeXS.pm 2018-01-28 02:41:54.000000000 +0100 @@ -4,7 +4,7 @@ use warnings FATAL => 'all'; use base qw(Exporter); -our $VERSION = '1.003009'; +our $VERSION = '1.003010'; $VERSION = eval $VERSION; sub _choose_json_module { @@ -111,7 +111,7 @@ my $json_output = encode_json($data_structure); - my $json = JSON->new; + my $json = JSON()->new; my $json_with_args = JSON::MaybeXS->new(utf8 => 1); # or { utf8 => 1 } @@ -181,12 +181,15 @@ The C<JSON> constant returns the selected implementation module's name for use as a class name - so: - my $json_obj = JSON->new; # returns a Cpanel::JSON::XS or JSON::PP object + my $json_obj = JSON()->new; # returns a Cpanel::JSON::XS or JSON::PP object and that object can then be used normally: my $data_structure = $json_obj->decode($json_text); # etc. +The use of parentheses here is optional, and only used as a hint to the reader +that this use of C<JSON> is a I<subroutine> call, I<not> a class name. + =head2 is_bool $is_boolean = is_bool($scalar) @@ -223,8 +226,8 @@ To include JSON-aware booleans (C<true>, C<false>) in your data, just do: use JSON::MaybeXS; - my $true = JSON->true; - my $false = JSON->false; + my $true = JSON()->true; + my $false = JSON()->false; =head1 CONVERTING FROM JSON::Any diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/maint/Makefile.PL.include new/JSON-MaybeXS-1.003010/maint/Makefile.PL.include --- old/JSON-MaybeXS-1.003009/maint/Makefile.PL.include 2015-02-28 03:03:44.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/maint/Makefile.PL.include 2017-09-26 23:02:08.000000000 +0200 @@ -4,4 +4,6 @@ author 'mst - Matt S. Trout (cpan:MSTROUT) <[email protected]>'; +manifest_include inc => '.pm'; + 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/t/legacy.t new/JSON-MaybeXS-1.003010/t/legacy.t --- old/JSON-MaybeXS-1.003009/t/legacy.t 2016-06-29 00:15:32.000000000 +0200 +++ new/JSON-MaybeXS-1.003010/t/legacy.t 2017-09-26 23:02:08.000000000 +0200 @@ -3,8 +3,8 @@ # hide Cpanel::JSON::XS use lib map { - my ( $m, $c ) = ( $_, qq{die "Can't locate $_ (hidden)\n"} ); - sub { return unless $_[1] eq $m; open my $fh, "<", \$c; return $fh } + my $m = $_; + sub { return unless $_[1] eq $m; die "Can't locate $m in \@INC (hidden).\n" }; } qw{Cpanel/JSON/XS.pm}; use Test::More 0.88; @@ -42,7 +42,7 @@ This function call is functionally identical to: - $json_text = JSON->new->encode($perl_scalar) + $json_text = JSON()->new->encode($perl_scalar) from_json $perl_scalar = from_json($json_text) @@ -52,4 +52,4 @@ This function call is functionally identical to: - $perl_scalar = JSON->decode($json_text) + $perl_scalar = JSON()->decode($json_text) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/t/none.t new/JSON-MaybeXS-1.003010/t/none.t --- old/JSON-MaybeXS-1.003009/t/none.t 2016-06-29 00:15:35.000000000 +0200 +++ new/JSON-MaybeXS-1.003010/t/none.t 2017-09-26 23:02:08.000000000 +0200 @@ -3,8 +3,8 @@ # hide Cpanel::JSON::XS, JSON::XS, JSON::PP use lib map { - my ( $m, $c ) = ( $_, qq{die "Can't locate $_ (hidden)\n"} ); - sub { return unless $_[1] eq $m; open my $fh, "<", \$c; return $fh } + my $m = $_; + sub { return unless $_[1] eq $m; die "Can't locate $m in \@INC (hidden).\n" }; } qw{Cpanel/JSON/XS.pm JSON/XS.pm JSON/PP.pm}; use Test::More 0.88; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/t/pp.t new/JSON-MaybeXS-1.003010/t/pp.t --- old/JSON-MaybeXS-1.003009/t/pp.t 2017-02-27 08:26:30.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/t/pp.t 2017-09-26 23:02:08.000000000 +0200 @@ -3,8 +3,8 @@ # hide Cpanel::JSON::XS, JSON::XS use lib map { - my ( $m, $c ) = ( $_, qq{die "Can't locate $_ (hidden)\n"} ); - sub { return unless $_[1] eq $m; open my $fh, "<", \$c; return $fh } + my $m = $_; + sub { return unless $_[1] eq $m; die "Can't locate $m in \@INC (hidden).\n" }; } qw{Cpanel/JSON/XS.pm JSON/XS.pm}; use if !eval { require JSON::PP; 1; }, 'Test::More', skip_all => 'No JSON::PP'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/t/xs.t new/JSON-MaybeXS-1.003010/t/xs.t --- old/JSON-MaybeXS-1.003009/t/xs.t 2017-02-27 08:26:30.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/t/xs.t 2017-09-26 23:02:08.000000000 +0200 @@ -3,8 +3,8 @@ # hide Cpanel::JSON::XS use lib map { - my ( $m, $c ) = ( $_, qq{die "Can't locate $_ (hidden)\n"} ); - sub { return unless $_[1] eq $m; open my $fh, "<", \$c; return $fh } + my $m = $_; + sub { return unless $_[1] eq $m; die "Can't locate $m in \@INC (hidden).\n" }; } qw{Cpanel/JSON/XS.pm}; use Test::More 0.88; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/JSON-MaybeXS-1.003009/xt/json_pm.t new/JSON-MaybeXS-1.003010/xt/json_pm.t --- old/JSON-MaybeXS-1.003009/xt/json_pm.t 2015-03-08 09:07:51.000000000 +0100 +++ new/JSON-MaybeXS-1.003010/xt/json_pm.t 2017-09-26 23:02:08.000000000 +0200 @@ -6,7 +6,9 @@ plan skip_all => 'No JSON'; } -my $data = JSON->new->decode('{"foo": true, "bar": false, "baz": 1}'); +use JSON::MaybeXS; + +my $data = JSON()->new->decode('{"foo": true, "bar": false, "baz": 1}'); ok( JSON::is_bool($data->{foo}),
