Skip to content
Permalink
Browse files
Merge pull request #10888 from shuffle2/zlib-ng
replace zlib with zlib-ng
  • Loading branch information
AdmiralCurtiss committed Jul 26, 2022
2 parents bfd03cd + b2f8456 commit e4ff497
Show file tree
Hide file tree
Showing 44 changed files with 742 additions and 13,643 deletions.
@@ -28,3 +28,7 @@
url = https://github.com/libsdl-org/SDL.git
branch = main
shallow = true
[submodule "Externals/zlib-ng/zlib-ng"]
path = Externals/zlib-ng/zlib-ng
url = https://github.com/zlib-ng/zlib-ng.git
shallow = true
@@ -1,7 +1,10 @@
########################################
# General setup
#
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.13)

cmake_policy(SET CMP0079 NEW) # let target_link_libraries() link to a target defined in a different directory
cmake_policy(SET CMP0080 OLD) # allow using BundleUtilities at configure time

# Weird chicken-and-egg problem: We can't check the compiler before the project() call, but we have to set the policies before it.
# So we do this in two steps: Set the policies if they exist, then error out afterwards if we end up being MSVC and they don't exist.
@@ -782,14 +785,7 @@ else()
add_subdirectory(Externals/zstd)
endif()

find_package(ZLIB)
if(ZLIB_FOUND)
message(STATUS "Using shared zlib")
else()
check_vendoring_approved(zlib)
message(STATUS "Shared zlib not found, falling back to the static library")
add_subdirectory(Externals/zlib)
endif()
add_subdirectory(Externals/zlib-ng)

pkg_check_modules(MINIZIP minizip-ng>=3.0.0)
if(MINIZIP_FOUND)
@@ -91,8 +91,8 @@
<ProjectReference Include="$(ExternalsDir)xxhash\xxhash.vcxproj">
<Project>{677ea016-1182-440c-9345-dc88d1e98c0c}</Project>
</ProjectReference>
<ProjectReference Include="$(ExternalsDir)zlib\zlib.vcxproj">
<Project>{ff213b23-2c26-4214-9f88-85271e557e87}</Project>
<ProjectReference Include="$(ExternalsDir)zlib-ng\zlib-ng.vcxproj">
<Project>{F6EA7144-8D64-4EBB-A13E-76DFBD911EAE}</Project>
</ProjectReference>
<ProjectReference Include="$(ExternalsDir)zstd\zstd.vcxproj">
<Project>{1bea10f3-80ce-4bc4-9331-5769372cdf99}</Project>
@@ -14,5 +14,5 @@ add_library(
)
dolphin_disable_warnings_msvc(curl)

target_link_libraries(curl ${MBEDTLS_LIBRARIES} z)
target_link_libraries(curl ${MBEDTLS_LIBRARIES} zlibstatic)
target_compile_definitions(curl PUBLIC CURL_STATICLIB PRIVATE CURL_DISABLE_LDAP)
@@ -74,7 +74,7 @@ Dolphin includes or links code of the following third-party software projects:
[MIT](https://github.com/microsoft/wil/blob/master/LICENSE)
- [xxHash](https://github.com/Cyan4973/xxHash):
[2-clause BSD](https://github.com/Cyan4973/xxHash/blob/master/LICENSE)
- [zlib](http://www.zlib.net/):
[zlib license](http://www.zlib.net/zlib_license.html)
- [zlib-ng](https://github.com/zlib-ng/zlib-ng):
[zlib license](https://github.com/zlib-ng/zlib-ng/blob/develop/LICENSE.md)
- [Zstandard](https://facebook.github.io/zstd/):
[3-clause BSD](https://github.com/facebook/zstd/blob/dev/LICENSE) or [GPLv2](https://github.com/facebook/zstd/blob/dev/COPYING)
@@ -3,6 +3,9 @@ set(USE_LZMA ON)
add_subdirectory(mgba EXCLUDE_FROM_ALL)
dolphin_disable_warnings_msvc(mgba)

target_compile_definitions(mgba PUBLIC HAVE_CRC32)
target_link_libraries(mgba ZLIB::ZLIB)

if(NOT MSVC)
target_compile_options(mgba PRIVATE -Wno-unused-parameter -Wno-unused-result -Wno-unused-variable)
endif()
@@ -18,7 +18,7 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>mgba\include;mgba\src;mgba\src\third-party\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BUILD_STATIC;M_CORE_GB;M_CORE_GBA;USE_LZMA;_7ZIP_PPMD_SUPPPORT;HAVE_STRDUP;HAVE_SETLOCALE;HAVE_CHMOD;HAVE_UMASK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>BUILD_STATIC;M_CORE_GB;M_CORE_GBA;USE_LZMA;_7ZIP_PPMD_SUPPPORT;HAVE_STRDUP;HAVE_SETLOCALE;HAVE_CHMOD;HAVE_UMASK;HAVE_CRC32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<PreBuildEvent>
<Command>"$(CScript)" /nologo /E:JScript "make_version.c.js"</Command>
@@ -0,0 +1,14 @@
set(ZLIB_ENABLE_TESTS OFF)
set(ZLIB_COMPAT ON)

option(BUILD_SHARED_LIBS "Build shared library" OFF)

add_subdirectory(zlib-ng)

# Set ZLIB variables for find_package used by other projects
set(ZLIB_INCLUDE_DIR ${CMAKE_BINARY_DIR}/zlib-ng CACHE STRING "Path to zlib include directory")
set(ZLIB_LIBRARY ZLIB::ZLIB CACHE STRING "Path to zlib library")

# Setup zlib alias project so FindZLIB doesn't recreate it
add_library(ZLIB::ZLIB ALIAS zlib)
dolphin_disable_warnings_msvc(zlib)
@@ -0,0 +1,195 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

#ifndef ZCONF_H
#define ZCONF_H

#include "zlib_name_mangling.h"

#if !defined(_WIN32) && defined(__WIN32__)
# define _WIN32
#endif

/* Clang macro for detecting declspec support
* https://clang.llvm.org/docs/LanguageExtensions.html#has-declspec-attribute
*/
#ifndef __has_declspec_attribute
# define __has_declspec_attribute(x) 0
#endif

#if defined(ZLIB_CONST) && !defined(z_const)
# define z_const const
#else
# define z_const
#endif

/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# define MAX_MEM_LEVEL 9
#endif

/* Maximum value for windowBits in deflateInit2 and inflateInit2.
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
* created by gzip. (Files created by minigzip can still be extracted by
* gzip.)
*/
#ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */
#endif

/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
for small objects.
*/

/* Type declarations */


#ifndef OF /* function prototypes */
# define OF(args) args
#endif

#ifdef ZLIB_INTERNAL
# define Z_INTERNAL ZLIB_INTERNAL
#endif

/* If building or using zlib as a DLL, define ZLIB_DLL.
* This is not mandatory, but it offers a little performance increase.
*/
#if defined(ZLIB_DLL) && (defined(_WIN32) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)))
# ifdef Z_INTERNAL
# define Z_EXTERN extern __declspec(dllexport)
# else
# define Z_EXTERN extern __declspec(dllimport)
# endif
#endif

/* If building or using zlib with the WINAPI/WINAPIV calling convention,
* define ZLIB_WINAPI.
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/
#if defined(ZLIB_WINAPI) && defined(_WIN32)
# include <windows.h>
/* No need for _export, use ZLIB.DEF instead. */
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
# define Z_EXPORT WINAPI
# define Z_EXPORTVA WINAPIV
#endif

#ifndef Z_EXTERN
# define Z_EXTERN extern
#endif
#ifndef Z_EXPORT
# define Z_EXPORT
#endif
#ifndef Z_EXPORTVA
# define Z_EXPORTVA
#endif

/* Conditional exports */
#define ZNG_CONDEXPORT Z_INTERNAL

/* For backwards compatibility */

#ifndef ZEXTERN
# define ZEXTERN Z_EXTERN
#endif
#ifndef ZEXPORT
# define ZEXPORT Z_EXPORT
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA Z_EXPORTVA
#endif

/* Fallback for something that includes us. */
typedef unsigned char Byte;
typedef Byte Bytef;

typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */

typedef char charf;
typedef int intf;
typedef uInt uIntf;
typedef uLong uLongf;

typedef void const *voidpc;
typedef void *voidpf;
typedef void *voidp;

typedef uint32_t z_crc_t;

#if 0 /* was set to #if 0 by configure/cmake/etc */
# define Z_HAVE_UNISTD_H
#endif

#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by configure/cmake/etc */
typedef PTRDIFF_TYPE ptrdiff_t;
#endif

#include <sys/types.h> /* for off_t */

#include <stddef.h> /* for wchar_t and NULL */

/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
* though the former does not conform to the LFS document), but considering
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
* equivalently requesting no 64-bit operations
*/
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
# undef _LARGEFILE64_SOURCE
#endif

#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
# ifndef z_off_t
# define z_off_t off_t
# endif
#endif

#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
# define Z_LFS64
#endif

#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
# define Z_LARGE64
#endif

#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
# define Z_WANT64
#endif

#if !defined(SEEK_SET)
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif

#ifndef z_off_t
# define z_off_t long
#endif

#if !defined(_WIN32) && defined(Z_LARGE64)
# define z_off64_t off64_t
#else
# if defined(__MSYS__)
# define z_off64_t _off64_t
# elif defined(_WIN32) && !defined(__GNUC__)
# define z_off64_t __int64
# else
# define z_off64_t z_off_t
# endif
#endif

#endif /* ZCONF_H */
Submodule zlib-ng added at a40628

0 comments on commit e4ff497

Please sign in to comment.