Toggle diff (390 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 26dfb6afe2..ccfcfde2e6 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1511,6 +1511,7 @@ dist_patch_DATA = \
%D%/packages/patches/mingw-w64-6.0.0-gcc.patch \
%D%/packages/patches/mingw-w64-dlltool-temp-prefix.patch \
%D%/packages/patches/mingw-w64-reproducible-gendef.patch \
+ %D%/packages/patches/miniz-cpp-fixed-duplicated-symbols.patch \
%D%/packages/patches/minisat-friend-declaration.patch \
%D%/packages/patches/minisat-install.patch \
%D%/packages/patches/mit-krb5-hurd.patch \
diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index e6d734010d..3e5cf9451f 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -1905,3 +1905,30 @@ (define-public cpp-mustache
templated string type for compatibility with any STL-like string (std::string,
std::wstring, etc).")
(license license:boost1.0)))
+
+(define-public miniz-cpp
+ (let ((commit "052335e4f7773368df07b26d2baedb0e6d4dbd38")
+ (revision "1"))
+ (package
+ (name "miniz-cpp")
+ (version (git-version "0.0.0" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tfussell/miniz-cpp.git")
+ (commit commit)))
+ (sha256
+ (base32
+ "1y8wzplyq2910fms2l9z1k6xrxb2x4w3gryykqkj11rwpkadw7b9"))
+ (patches (search-patches
+ ;; To be removed once https://github.com/tfussell/miniz-cpp/pull/11
+ ;; gets merged.
+ "miniz-cpp-fixed-duplicated-symbols.patch"))))
+ (build-system copy-build-system)
+ (home-page "https://github.com/tfussell/miniz-cpp/")
+ (synopsis
+ "A header-only C++14 library for reading and writing ZIP files")
+ (description
+ "@code{miniz-cpp} is a cross-platform header-only library for reading and
+writing ZIP files using a nice simple API similar to Python's @code{zipfile}.")
+ (license license:expat))))
diff --git a/gnu/packages/patches/miniz-cpp-fixed-duplicated-symbols.patch b/gnu/packages/patches/miniz-cpp-fixed-duplicated-symbols.patch
new file mode 100644
index 0000000000..035f989767
--- /dev/null
+++ b/gnu/packages/patches/miniz-cpp-fixed-duplicated-symbols.patch
@@ -0,0 +1,2734 @@
+commit 64f974213ac16f78c008bd148c8a2a07e902f148
+Author: Kay Stenschke <info@stenschke.com>
+Date: Mon Apr 27 12:13:34 2020 +0200
+
+ Fixed duplicated symbols
+
+ Using miniz-cpp from multiple translation units caused linker error.
+ Done: marked declarations as static for correct linking from multiple translation units.
+
+diff --git a/zip_file.hpp b/zip_file.hpp
+index c324f70..3aff33c 100644
+--- a/zip_file.hpp
++++ b/zip_file.hpp
+@@ -226,12 +226,12 @@
+ //#define MINIZ_NO_MALLOC
+
+ #if defined(__TINYC__) && (defined(__linux) || defined(__linux__))
+- // TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux
++// TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux
+ #define MINIZ_NO_TIME
+ #endif
+
+ #if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS)
+- #include <time.h>
++#include <time.h>
+ #endif
+
+ #if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__)
+@@ -272,15 +272,15 @@ extern "C" {
+ typedef unsigned long mz_ulong;
+
+ // mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap.
+-void mz_free(void *p);
++static void mz_free(void *p);
+
+ #define MZ_ADLER32_INIT (1)
+ // mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL.
+-mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);
++static mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);
+
+ #define MZ_CRC32_INIT (0)
+ // mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL.
+-mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
++static mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
+
+ // Compression strategies.
+ enum { MZ_DEFAULT_STRATEGY = 0, MZ_FILTERED = 1, MZ_HUFFMAN_ONLY = 2, MZ_RLE = 3, MZ_FIXED = 4 };
+@@ -343,7 +343,7 @@ typedef struct mz_stream_s
+ typedef mz_stream *mz_streamp;
+
+ // Returns the version string of miniz.c.
+-const char *mz_version(void);
++static const char *mz_version(void);
+
+ // mz_deflateInit() initializes a compressor with default options:
+ // Parameters:
+@@ -356,17 +356,17 @@ const char *mz_version(void);
+ // MZ_STREAM_ERROR if the stream is bogus.
+ // MZ_PARAM_ERROR if the input parameters are bogus.
+ // MZ_MEM_ERROR on out of memory.
+-int mz_deflateInit(mz_streamp pStream, int level);
++static int mz_deflateInit(mz_streamp pStream, int level);
+
+ // mz_deflateInit2() is like mz_deflate(), except with more control:
+ // Additional parameters:
+ // method must be MZ_DEFLATED
+ // window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no header or footer)
+ // mem_level must be between [1, 9] (it's checked but ignored by miniz.c)
+-int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy);
++static int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy);
+
+ // Quickly resets a compressor without having to reallocate anything. Same as calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2().
+-int mz_deflateReset(mz_streamp pStream);
++static int mz_deflateReset(mz_streamp pStream);
+
+ // mz_deflate() compresses the input to output, consuming as much of the input and producing as much output as possible.
+ // Parameters:
+@@ -378,31 +378,31 @@ int mz_deflateReset(mz_streamp pStream);
+ // MZ_STREAM_ERROR if the stream is bogus.
+ // MZ_PARAM_ERROR if one of the parameters is invalid.
+ // MZ_BUF_ERROR if no forward progress is possible because the input and/or output buffers are empty. (Fill up the input buffer or free up some output space and try again.)
+-int mz_deflate(mz_streamp pStream, int flush);
++static int mz_deflate(mz_streamp pStream, int flush);
+
+ // mz_deflateEnd() deinitializes a compressor:
+ // Return values:
+ // MZ_OK on success.
+ // MZ_STREAM_ERROR if the stream is bogus.
+-int mz_deflateEnd(mz_streamp pStream);
++static int mz_deflateEnd(mz_streamp pStream);
+
+ // mz_deflateBound() returns a (very) conservative upper bound on the amount of data that could be generated by deflate(), assuming flush is set to only MZ_NO_FLUSH or MZ_FINISH.
+-mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len);
++static mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len);
+
+ // Single-call compression functions mz_compress() and mz_compress2():
+ // Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure.
+-int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
+-int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level);
++static int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
++static int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level);
+
+ // mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress().
+-mz_ulong mz_compressBound(mz_ulong source_len);
++static mz_ulong mz_compressBound(mz_ulong source_len);
+
+ // Initializes a decompressor.
+-int mz_inflateInit(mz_streamp pStream);
++static int mz_inflateInit(mz_streamp pStream);
+
+ // mz_inflateInit2() is like mz_inflateInit() with an additional option that controls the window size and whether or not the stream has been wrapped with a zlib header/footer:
+ // window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate).
+-int mz_inflateInit2(mz_streamp pStream, int window_bits);
++static int mz_inflateInit2(mz_streamp pStream, int window_bits);
+
+ // Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible.
+ // Parameters:
+@@ -418,91 +418,91 @@ int mz_inflateInit2(mz_streamp pStream, int window_bits);
+ // MZ_PARAM_ERROR if one of the parameters is invalid.
+ // MZ_BUF_ERROR if no forward progress is possible because the input buffer is empty but the inflater needs more input to continue, or if the output buffer is not large enough. Call mz_inflate() again
+ // with more input data, or with more room in the output buffer (except when using single call decompression, described above).
+-int mz_inflate(mz_streamp pStream, int flush);
++static int mz_inflate(mz_streamp pStream, int flush);
+
+ // Deinitializes a decompressor.
+-int mz_inflateEnd(mz_streamp pStream);
++static int mz_inflateEnd(mz_streamp pStream);
+
+ // Single-call decompression.
+ // Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure.
+-int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
++static int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
+
+ // Returns a string description of the specified error code, or NULL if the error code is invalid.
+-const char *mz_error(int err);
++static const char *mz_error(int err);
+
+ // Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports.
+ // Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project.
+ #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES
+- typedef unsigned char Byte;
+- typedef unsigned int uInt;
+- typedef mz_ulong uLong;
+- typedef Byte Bytef;
+- typedef uInt uIntf;
+- typedef char charf;
+- typedef int intf;
+- typedef void *voidpf;
+- typedef uLong uLongf;
+- typedef void *voidp;
+- typedef void *const voidpc;
+- #define Z_NULL 0
+- #define Z_NO_FLUSH MZ_NO_FLUSH
+- #define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH
+- #define Z_SYNC_FLUSH MZ_SYNC_FLUSH
+- #define Z_FULL_FLUSH MZ_FULL_FLUSH
+- #define Z_FINISH MZ_FINISH
+- #define Z_BLOCK MZ_BLOCK
+- #define Z_OK MZ_OK
+- #define Z_STREAM_END MZ_STREAM_END
+- #define Z_NEED_DICT MZ_NEED_DICT
+- #define Z_ERRNO MZ_ERRNO
+- #define Z_STREAM_ERROR MZ_STREAM_ERROR
+- #define Z_DATA_ERROR MZ_DATA_ERROR
+- #define Z_MEM_ERROR MZ_MEM_ERROR
+- #define Z_BUF_ERROR MZ_BUF_ERROR
+- #define Z_VERSION_ERROR MZ_VERSION_ERROR
+- #define Z_PARAM_ERROR MZ_PARAM_ERROR
+- #define Z_NO_COMPRESSION MZ_NO_COMPRESSION
+- #define Z_BEST_SPEED MZ_BEST_SPEED
+- #define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION
+- #define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION
+- #define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY
+- #define Z_FILTERED MZ_FILTERED
+- #define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY
+- #define Z_RLE MZ_RLE
+- #define Z_FIXED MZ_FIXED
+- #define Z_DEFLATED MZ_DEFLATED
+- #define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS
+- #define alloc_func mz_alloc_func
+- #define free_func mz_free_func
+- #define internal_state mz_internal_state
+- #define z_stream mz_stream
+- #define deflateInit mz_deflateInit
+- #define deflateInit2 mz_deflateInit2
+- #define deflateReset mz_deflateReset
+- #define deflate mz_deflate
+- #define deflateEnd mz_deflateEnd
+- #define deflateBound mz_deflateBound
+- #define compress mz_compress
+- #define compress2 mz_compress2
+- #define compressBound mz_compressBound
+- #define inflateInit mz_inflateInit
+- #define inflateInit2 mz_inflateInit2
+- #define inflate mz_inflate
+- #define inflateEnd mz_inflateEnd
+- #define uncompress mz_uncompress
+- #define crc32 mz_crc32
+- #define adler32 mz_adler32
+- #define MAX_WBITS 15
+- #define MAX_MEM_LEVEL 9
+- #define zError mz_error
+- #define ZLIB_VERSION MZ_VERSION
+- #define ZLIB_VERNUM MZ_VERNUM
+- #define ZLIB_VER_MAJOR MZ_VER_MAJOR
+- #define ZLIB_VER_MINOR MZ_VER_MINOR
+- #define ZLIB_VER_REVISION MZ_VER_REVISION
+- #define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION
+- #define zlibVersion mz_version
+- #define zlib_version mz_version()
++typedef unsigned char Byte;
++typedef unsigned int uInt;
++typedef mz_ulong uLong;
++typedef Byte Bytef;
++typedef uInt uIntf;
++typedef char charf;
++typedef int intf;
++typedef void *voidpf;
++typedef uLong uLongf;
++typedef void *voidp;
++typedef void *const voidpc;
++#define Z_NULL 0
++#define Z_NO_FLUSH MZ_NO_FLUSH
++#define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH
++#define Z_SYNC_FLUSH MZ_SYNC_FLUSH
++#define Z_FULL_FLUSH MZ_FULL_FLUSH
++#define Z_FINISH MZ_FINISH
++#define Z_BLOCK MZ_BLOCK
++#define Z_OK MZ_OK
++#define Z_STREAM_END MZ_STREAM_END
++#define Z_NEED_DICT MZ_NEED_DICT
++#define Z_ERRNO MZ_ERRNO
++#define Z_STREAM_ERROR MZ_STREAM_ERROR
++#define Z_DATA_ERROR MZ_DATA_ERROR
++#define Z_MEM_ERROR MZ_MEM_ERROR
++#define Z_BUF_ERROR MZ_BUF_ERROR
++#define Z_VERSION_ERROR MZ_VERSION_ERROR
++#define Z_PARAM_ERROR MZ_PARAM_ERROR
++#define Z_NO_COMPRESSION MZ_NO_COMPRESSION
++#define Z_BEST_SPEED MZ_BEST_SPEED
++#define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION
++#define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION
++#define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY
++#define Z_FILTERED MZ_FILTERED
++#define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY
++#define Z_RLE MZ_RLE
++#define Z_FIXED MZ_FIXED
++#define Z_DEFLATED MZ_DEFLATED
++#define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS
++#define alloc_func mz_alloc_func
++#define free_func mz_free_func
++#define internal_state mz_internal_state
++#define z_stream mz_stream
++#define deflateInit mz_deflateInit
++#define deflateInit2 mz_deflateInit2
++#define deflateReset mz_deflateReset
++#define deflate mz_deflate
++#define deflateEnd mz_deflateEnd
++#define deflateBound mz_deflateBound
++#define compress mz_compress
++#define compress2 mz_compress2
++#define compressBound mz_compressBound
++#define inflateInit mz_inflateInit
++#define inflateInit2 mz_inflateInit2
++#define inflate mz_inflate
++#define inflateEnd mz_inflateEnd
++#define uncompress mz_uncompress
++#define crc32 mz_crc32
++#define adler32 mz_adler32
++#define MAX_WBITS 15
++#define MAX_MEM_LEVEL 9
++#define zError mz_error
++#define ZLIB_VERSION MZ_VERSION
++#define ZLIB_VERNUM MZ_VERNUM
++#define ZLIB_VER_MAJOR MZ_VER_MAJOR
++#define ZLIB_VER_MINOR MZ_VER_MINOR
++#define ZLIB_VER_REVISION MZ_VER_REVISION
++#define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION
++#define zlibVersion mz_version
++#define zlib_version mz_version()
+ #endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES
+
+ #endif // MINIZ_NO_ZLIB_APIS
+@@ -523,9 +523,9 @@ typedef int mz_bool;
+
+ // An attempt to work around MSVC's spammy "warning C4127: conditional expression is constant" message.
+ #ifdef _MSC_VER
+- #define MZ_MACRO_END while (0, 0)
++#define MZ_MACRO_END while (0, 0)
+ #else
+- #define MZ_MACRO_END while (0)
++#define MZ_MACRO_END while (0)
+ #endif
+
+ // ------------------- ZIP archive reading/writing
+@@ -609,68 +609,68 @@ typedef enum
+
+ // Inits a ZIP archive reader.
+ // These functions read and validate the archive's central directory.
+-mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags);
+-mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags);
++static mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags);
++static mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags);
+
+ #ifndef MINIZ_NO_STDIO
+-mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags);
++static mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags);
+ #endif
+
+ // Returns the total number of files in the archive.
+-mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip);
++static mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip);
+
+ // Returns detailed information about an archive file entry.
+-mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat);
++static mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat);
+
+ // Determines if an archive file entry is a directory entry.
+-mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index);
+-mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index);
++static mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index);
++static mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index);
+
+ // Retrieves the filename of an archive file entry.
+ // Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename.
+-mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size);
++static mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size);
+
+ // Attempts to locates a file in the archive's central directory.
+ // Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH
+ // Returns -1 if the file cannot be found.
+-int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
++static int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
+
+ // Extracts a archive file to a memory buffer using no memory allocation.
+-mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
+-mz_b