Skip to content

Commit

Permalink
minizip-ng: add
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Aug 14, 2022
1 parent 55c762a commit df836df
Show file tree
Hide file tree
Showing 6 changed files with 397 additions and 0 deletions.
8 changes: 8 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,14 @@
"2.1.0-1"
]
},
"minizip-ng": {
"dependency_names": [
"minizip-ng"
],
"versions": [
"3.0.6-1"
]
},
"mocklibc": {
"versions": [
"1.0-2"
Expand Down
9 changes: 9 additions & 0 deletions subprojects/minizip-ng.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[wrap-file]
directory = minizip-ng-3.0.6
source_url = https://github.com/zlib-ng/minizip-ng/archive/refs/tags/3.0.6.tar.gz
source_filename = 3.0.6.tar.gz
source_hash = 383fa1bdc28c482828a8a8db53f758dbd44291b641182724fda5df5b59cce543
patch_directory = minizip-ng

[provide]
minizip-ng = minizip_ng_dep
187 changes: 187 additions & 0 deletions subprojects/packagefiles/minizip-ng/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
project('minizip-ng', 'c',
version: '3.0.6',
default_options: ['warning_level=1'],
)

if host_machine.system() == 'windows' and get_option('buildtype') != 'static'
add_project_arguments('-DMZ_EXPORTS', language: 'c')
endif

cc = meson.get_compiler('c')
if cc.has_header('stdint.h')
add_project_arguments('-DHAVE_STDINT_H', language: 'c')
endif

if cc.has_header('inttypes.h')
add_project_arguments('-DHAVE_INTTYPES_H', language: 'c')
endif

if cc.has_function('getrandom')
add_project_arguments('-DHAVE_GETRANDOM', language: 'c')
endif

if not cc.has_function('fseeko')
add_project_arguments('-DNO_FSEEKO', language: 'c')
endif

sources = files(
'mz_crypt.c',
'mz_os.c',
'mz_strm.c',
'mz_strm_buf.c',
'mz_strm_mem.c',
'mz_strm_split.c',
'mz_zip.c',
'mz_zip_rw.c',
)

if host_machine.system() == 'windows'
sources += files('mz_os_win32.c', 'mz_strm_os_win32.c')
else
sources += files('mz_os_posix.c', 'mz_strm_os_posix.c')
endif

compat = get_option('compat')
if compat
sources += files('mz_compat.c')
add_project_arguments('-DHAVE_COMPAT', language: 'c')
endif

bsd_dep = dependency('libbsd', required: get_option('bsd'))
if bsd_dep.found()
add_project_arguments('-DHAVE_LIBBSD', language: 'c')
endif

if cc.has_function('arc4random_buf', dependencies: bsd_dep)
add_project_arguments('-DHAVE_ARC4RANDOM_BUF', language: 'c')
endif

if cc.has_function('arc4random', dependencies: bsd_dep)
add_project_arguments('-DHAVE_ARC4RANDOM', language: 'c')
endif

crypt_dep = dependency('openssl', required: get_option('wzaes'))
if crypt_dep.found()
sources += files('mz_crypt_openssl.c')
elif host_machine.system() == 'windows'
crypt_dep = cc.find_library('crypt32', required: get_option('wzaes'))
if crypt_dep.found()
sources += files('mz_crypt_win32.c')
endif
elif host_machine.system() == 'darwin'
crypt_dep = dependency('appleframeworks', modules : [ 'CoreFoundation', 'Security' ], required: get_option('wzaes'))
if crypt_dep.found()
sources += files('mz_crypt_apple.c')
endif
endif

if crypt_dep.found()
sources += files('mz_strm_wzaes.c')
add_project_arguments('-DHAVE_WZAES', language: 'c')
add_project_arguments('-DMZ_ZIP_SIGNING', language: 'c')
else
add_project_arguments('-DMZ_ZIP_NO_ENCRYPTION', language: 'c')
add_project_arguments('-DMZ_ZIP_NO_CRYPTO', language: 'c')
endif

iconv_dep = dependency('iconv', required: get_option('iconv'))
if iconv_dep.found()
add_project_arguments('-DHAVE_ICONV', language: 'c')
endif

bzip2_dep = dependency('bzip2', required: get_option('bzip2'))
if bzip2_dep.found()
sources += files('mz_strm_bzip.c')
add_project_arguments('-DHAVE_BZIP2', language: 'c')
endif

lzma_dep = dependency('liblzma', required: get_option('lzma'))
if lzma_dep.found()
sources += files('mz_strm_lzma.c')
add_project_arguments('-DHAVE_LZMA', language: 'c')
endif

zlib_dep = dependency('zlib-ng', required: get_option('zlib'))
if not zlib_dep.found()
zlib_dep = dependency('zlib', required: get_option('zlib'))
if zlib_dep.found()
add_project_arguments('-DZLIB_COMPAT', language: 'c')
endif
endif
if zlib_dep.found()
sources += files('mz_strm_zlib.c')
add_project_arguments('-DHAVE_ZLIB', language: 'c')
endif

zstd_dep = dependency('libzstd', required: get_option('zstd'))
if zstd_dep.found()
sources += files('mz_strm_zstd.c')
add_project_arguments('-DHAVE_ZSTD', language: 'c')
endif

if not zlib_dep.found() and not zstd_dep.found() and not bzip2_dep.found() and not lzma_dep.found()
add_project_arguments('-DMZ_ZIP_NO_DECOMPRESSION', language: 'c')
add_project_arguments('-DMZ_ZIP_NO_COMPRESSION', language: 'c')
endif

minizip_ng = library(compat ? 'minizip' : 'minizip-ng',
sources,
version: meson.project_version(),
soversion: host_machine.system() == 'windows' ? '' : '3',
vs_module_defs: 'mz.def',
dependencies: [ bsd_dep, crypt_dep, iconv_dep, bzip2_dep, lzma_dep, zlib_dep, zstd_dep, ],
install: true,
)

minizip_ng_dep = declare_dependency(
include_directories: '.',
link_with: minizip_ng,
)

pconf = import('pkgconfig')
pconf.generate(minizip_ng,
description: 'Minizip zip file manipulation library',
)

headers = files(
'mz.h',
'mz_crypt.h',
'mz_os.h',
'mz_strm.h',
'mz_strm_buf.h',
'mz_strm_bzip.h',
'mz_strm_lzma.h',
'mz_strm_mem.h',
'mz_strm_os.h',
'mz_strm_pkcrypt.h',
'mz_strm_split.h',
'mz_strm_wzaes.h',
'mz_strm_zlib.h',
'mz_strm_zstd.h',
'mz_zip.h',
'mz_zip_rw.h',
)

if compat
zip_h = configure_file(
input: 'mz_compat_shim.h.in',
output: 'zip.h',
format: 'cmake@',
configuration: {'MZ_COMPAT_FILE': 'MZ_COMPAT_ZIP', 'FILE_H': 'zip.h'},
)

unzip_h = configure_file(
input: 'mz_compat_shim.h.in',
output: 'unzip.h',
format: 'cmake@',
configuration: {'MZ_COMPAT_FILE': 'MZ_COMPAT_UNZIP', 'FILE_H': 'unzip.h'},
)

headers += files('mz_compat.h')
headers += zip_h
headers += unzip_h
endif

install_headers(
headers,
)
32 changes: 32 additions & 0 deletions subprojects/packagefiles/minizip-ng/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
option('bsd', type: 'feature',
description: 'Build with libbsd arc4random',
)

option('iconv', type: 'feature',
description: 'Build with iconv support',
)

option('compat', type : 'boolean',
description : 'Build with compatibility support for traditional minizip',
value: false,
)

option('bzip2', type : 'feature',
description : 'Build with bzip2 support',
)

option('lzma', type : 'feature',
description : 'Build with lzma support',
)

option('wzaes', type: 'feature',
description: 'Buid with WinZip AES support',
)

option('zlib', type : 'feature',
description : 'Build with zlib/zlib-ng support',
)

option('zstd', type : 'feature',
description : 'Build with zstd support',
)
Loading

0 comments on commit df836df

Please sign in to comment.