Imported Upstream version 3.003
authorgregor herrmann <gregoa@debian.org>
Mon, 20 Oct 2014 16:18:46 +0000 (18:18 +0200)
committergregor herrmann <gregoa@debian.org>
Mon, 20 Oct 2014 16:18:46 +0000 (18:18 +0200)
Changes
INSTALL [new file with mode: 0644]
MANIFEST
META.json
META.yml
Makefile.PL
inc/Sereal/BuildTools.pm
lib/Sereal/Encoder.pm
snappy/csnappy.h
srl_encoder.c

diff --git a/Changes b/Changes
index 100a37dcb3f6f6300743ddb9860f6e018f7283cb..c6fb20fc7a51fdfb9632d90fbf2342c52b66093c 100644 (file)
--- a/Changes
+++ b/Changes
@@ -3,11 +3,13 @@ Revision history for Perl extension Sereal-Encoder
 * Warning: For a seamless upgrade, upgrade to version 3
 *          of the decoder before upgrading to version 3 of the
 *          encoder!
-3.002_001 Sept 26, 2014
+3.003 Oct 19 2014
   * Niko Tyni fixed the 64-bit big endian Sereal bug! (Yay Niko!)
   * Setup META.yml correctly so that certain dependencies are
     marked as being test dependencies and not build or run-time
     dependencies.
+  * Allow one to build against an externally supplied version
+    of csnappy or miniz. Thanks to Petr Písař <ppisar@redhat.com>
 
 3.002 Aug 20 2014
   Summary of changes from 3.001 - 3.002
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..7a21163
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,18 @@
+Install with
+
+    perl Makefile.PL
+    make
+    make test
+    make instal
+
+By default the module will detect and use system versions of the miniz
+and csnappy libraries during build and install. You can override this
+by setting the SEREAL_USE_BUNDLED_LIBS to true, or you can override
+it on a case by case basis by setting SEREAL_USE_BUNDLED_MINIZ or
+SEREAL_USE_BUNDLED_CSNAPPY env vars. Eg:
+
+    SEREAL_USE_BUNDLED_LIBS=1 perl Makefile.PL
+    SEREAL_USE_BUNDLED_CSNAPPY=1 perl Makefile.PL
+    SEREAL_USE_BUNDLED_MINIZ=1 perl Makefile.PL
+
+
index c976cbd9be281c38d25052ea07a318f9ad629bb9..2732e974b31284f60174e384332308d6a9949630 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -12,6 +12,7 @@ const-xs.inc
 Encoder.xs
 inc/Devel/CheckLib.pm
 inc/Sereal/BuildTools.pm
+INSTALL
 lib/Sereal/Encoder.pm
 lib/Sereal/Encoder/Constants.pm
 Makefile.PL
index 13f07cd957cf81179a1d009b95a693281c38c9b7..287cd256bca160a5df967c2504b239ed19179ec5 100644 (file)
--- a/META.json
+++ b/META.json
@@ -50,7 +50,7 @@
          }
       }
    },
-   "release_status" : "testing",
+   "release_status" : "stable",
    "resources" : {
       "bugtracker" : {
          "web" : "https://github.com/Sereal/Sereal/issues"
@@ -60,5 +60,5 @@
          "url" : "git://github.com/Sereal/Sereal.git"
       }
    },
-   "version" : "3.002_001"
+   "version" : "3.003"
 }
index c28fe065a79c7b65fcc2cdf87e83a5e35c1ac4fa..4d1a7649e40da63ff94f17f3f030c39d983fe217 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -32,4 +32,4 @@ requires:
 resources:
   bugtracker: https://github.com/Sereal/Sereal/issues
   repository: git://github.com/Sereal/Sereal.git
-version: 3.002_001
+version: '3.003'
index 65d92921e4205765422f721b203688e580bb20c1..a3bf8bd9836212b748354fcb980bdd374158d7f4 100644 (file)
@@ -25,6 +25,8 @@ inc::Sereal::BuildTools::generate_constant_includes($module) if $in_source_repo;
 
 our $OPTIMIZE;
 
+my $libs = '';
+my $objects = '$(BASEEXT)$(OBJ_EXT) srl_encoder$(OBJ_EXT)';
 my $defines = join " ", map "-D$_", grep exists $ENV{$_},
               qw(NOINLINE DEBUG MEMDEBUG NDEBUG ENABLE_DANGEROUS_HACKS);
 
@@ -56,13 +58,18 @@ if ($Config{osname} eq 'hpux' && not $Config{gccversion}) {
   $defines .= " -Dinline= ";
 }
 
-# from Compress::Snappy
-require Devel::CheckLib;
-my $ctz = Devel::CheckLib::check_lib(
-    lib      => 'c',
-    function => 'return (__builtin_ctzll(0x100000000LL) != 32);'
-) ? '-DHAVE_BUILTIN_CTZ' : '';
-$defines .= " $ctz" if $ctz;
+# Prefer external libraries over the bundled one.
+inc::Sereal::BuildTools::check_external_libraries(\$libs, \$defines, \$objects);
+
+if ($defines !~ /HAVE_CSNAPPY/) {
+    # from Compress::Snappy
+    require Devel::CheckLib;
+    my $ctz = Devel::CheckLib::check_lib(
+        lib      => 'c',
+        function => 'return (__builtin_ctzll(0x100000000LL) != 32);'
+    ) ? '-DHAVE_BUILTIN_CTZ' : '';
+    $defines .= " $ctz" if $ctz;
+}
 
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
 # the contents of the Makefile that is written.
@@ -101,11 +108,11 @@ WriteMakefile1(
     LICENSE => 'perl',
     ABSTRACT_FROM => 'lib/Sereal/Encoder.pm',
     AUTHOR => 'Steffen Mueller <smueller@cpan.org>, Yves Orton <yves@cpan.org>',
-    LIBS              => [''], # e.g., '-lm'
+    LIBS              => [$libs], # e.g., '-lm'
     DEFINE            => $defines,
     INC               => '-I.', # e.g., '-I. -I/usr/include/other'
     OPTIMIZE          => $OPTIMIZE,
-    OBJECT            => '$(O_FILES)',
+    OBJECT            => $objects,
     test              => {
         TESTS => "t/*.t t/*/*/*.t",
     },
index a36e1e9fda4a5c07f28b65acd8e78041f37dfe89..f5eb15da92b9a7096a51db951cd72978a6db94a5 100644 (file)
@@ -1264,6 +1264,40 @@ HERE
   }
 }
 
+# Prefer external csnappy and miniz libraries over the bundled ones.
+sub check_external_libraries {
+  my ($libs, $defines, $objects) = @_;
+  require Devel::CheckLib;
+
+  if (
+    !$ENV{SEREAL_USE_BUNDLED_LIBS} &&
+    !$ENV{SEREAL_USE_BUNDLED_CSNAPPY} &&
+    Devel::CheckLib::check_lib(
+      lib      => 'csnappy',
+      header   => 'csnappy.h'
+  )) {
+    print "Using installed csnappy library\n";
+    $$libs .= ' -lcsnappy';
+    $$defines .= ' -DHAVE_CSNAPPY';
+  } else {
+    print "Using bundled csnappy code\n";
+  }
+
+  if (
+    !$ENV{SEREAL_USE_BUNDLED_LIBS} &&
+    !$ENV{SEREAL_USE_BUNDLED_MINIZ} &&
+    Devel::CheckLib::check_lib(
+      lib      => 'miniz',
+      header   => 'miniz.h'
+  )) {
+    print "Using installed miniz library\n";
+    $$libs .= ' -lminiz';
+    $$defines .= ' -DHAVE_MINIZ';
+  } else {
+    print "Using bundled miniz code\n";
+    $$objects .= ' miniz$(OBJ_EXT)';
+  }
+}
 
 1;
 
index 45232e5f9b48d8f011f7c19a6a9f9f2d978edf64..c87655d62b4b460bad8ccefa0939b884f99c4557 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 use Carp qw/croak/;
 use XSLoader;
 
-our $VERSION = '3.002_001'; # Don't forget to update the TestCompat set for testing against installed decoders!
+our $VERSION = '3.003'; # Don't forget to update the TestCompat set for testing against installed decoders!
 our $XS_VERSION = $VERSION; $VERSION= eval $VERSION;
 
 # not for public consumption, just for testing.
@@ -587,7 +587,7 @@ into a special one byte ARRAYREF tag. This is a very significant optimization
 for common cases. This, however, does mean that most arrays up to 15 elements
 could be represented in two different, yet perfectly valid forms. ARRAYREF would
 have to be outlawed for a properly canonical form. The exact same logic
-applies to HASH vs. HASHREF. This behavior can be overriden by the
+applies to HASH vs. HASHREF. This behavior can be overridden by the
 C<canonical_refs> option, which disables use of HASHREF and ARRAYREF.
 
 =item Numeric representation
index d8c128cbebfba016226cc172a893a3db712b63d1..a905ac058d183f816cc8b650b80c2c8d02263a96 100644 (file)
@@ -8,14 +8,15 @@ Zeev Tarantov <zeev.tarantov@gmail.com>
 extern "C" {
 #endif
 
-#define CSNAPPY_VERSION        4
+#define CSNAPPY_VERSION        5
 
-#define CSNAPPY_WORKMEM_BYTES_POWER_OF_TWO 15
+#define CSNAPPY_WORKMEM_BYTES_POWER_OF_TWO 16
 #define CSNAPPY_WORKMEM_BYTES (1 << CSNAPPY_WORKMEM_BYTES_POWER_OF_TWO)
 
 #ifndef __GNUC__
 #define __attribute__(x) /*NOTHING*/
 #endif
+#include <stdint.h>
 
 /*
  * Returns the maximal size of the compressed representation of
index 780748fb280cdb4a83146377f5cccafd0f9ab39c..7756b03a510c5f73ce5aa573bd27e664ca2e49fb 100644 (file)
@@ -52,8 +52,17 @@ extern "C" {
 #include "ptable.h"
 #include "srl_buffer.h"
 
+#if defined(HAVE_CSNAPPY)
+#include <csnappy.h>
+#else
 #include "snappy/csnappy_compress.c"
+#endif
+
+#if defined(HAVE_MINIZ)
+#include <miniz.h>
+#else
 #include "miniz.h"
+#endif
 
 /* The ENABLE_DANGEROUS_HACKS (passed through from ENV via Makefile.PL) enables
  * optimizations that may make the code so cozy with a particular version of the