Move libzip to meson subproject wrap
* optionally depend on lzma, bzip2 and openssl for additional zip support * add use_sys_libzip_openssl meson option to choose if openssl should be used in libzip or not * avoid optional dependencies on windows to avoid troubles
This commit is contained in:
parent
130aed6582
commit
9349b2f3ed
12 changed files with 592 additions and 104 deletions
|
|
@ -71,7 +71,7 @@ You can override the version of Capstone Rizin will use by setting
|
|||
There are more bundled dependencies that can be swapped out for system versions.
|
||||
At time of writing these are:
|
||||
* `use_sys_magic`
|
||||
* `use_sys_zip`
|
||||
* `use_sys_libzip`
|
||||
* `use_sys_zlib`
|
||||
* `use_sys_lz4`
|
||||
* `use_sys_xxhash`
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ rz_io_deps = [
|
|||
gdb_dep,
|
||||
winkd_dep,
|
||||
qnx_dep,
|
||||
zip_dep,
|
||||
libzip_dep,
|
||||
ar_dep,
|
||||
pth,
|
||||
rz_util_dep,
|
||||
|
|
|
|||
|
|
@ -126,7 +126,9 @@ if cc.has_argument('-Werror=sizeof-pointer-memaccess')
|
|||
endif
|
||||
|
||||
if cc.get_id() == 'clang-cl'
|
||||
add_project_arguments('-fcommon', language: 'c')
|
||||
if cc.has_argument('-fcommon')
|
||||
add_project_arguments('-fcommon', language: 'c')
|
||||
endif
|
||||
add_project_arguments('-D__STDC__=1', language: 'c')
|
||||
add_project_arguments('-D_CRT_DECLARE_NONSTDC_NAMES ', language: 'c')
|
||||
add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c')
|
||||
|
|
@ -629,7 +631,7 @@ summary({
|
|||
'System tree-sitter library': tree_sitter_dep.found() and tree_sitter_dep.type_name() != 'internal',
|
||||
'System lz4 library': lz4_dep.found() and lz4_dep.type_name() != 'internal',
|
||||
'System zlib library': zlib_dep.found() and zlib_dep.type_name() != 'internal',
|
||||
'System zip library': zip_dep.found() and zip_dep.type_name() != 'internal',
|
||||
'System zip library': libzip_dep.found() and libzip_dep.type_name() != 'internal',
|
||||
'Use ptrace-wrap': use_ptrace_wrap,
|
||||
'Use RPATH': use_rpath,
|
||||
}, section: 'Configuration', bool_yn: true)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ option('checks_level', type: 'integer', value: 9999, description: 'Value between
|
|||
option('use_sys_capstone', type: 'feature', value: 'disabled')
|
||||
option('use_capstone_version', type: 'combo', choices: ['v3', 'v4', 'next', 'bundled'], value: 'bundled', description: 'Specify which version of capstone to use')
|
||||
option('use_sys_magic', type: 'feature', value: 'disabled')
|
||||
option('use_sys_zip', type: 'feature', value: 'disabled')
|
||||
option('use_sys_libzip', type: 'feature', value: 'disabled')
|
||||
option('use_sys_libzip_openssl', type: 'boolean', value: true, description: 'Whether to use or not system openssl dependency to build libzip')
|
||||
option('use_sys_zlib', type: 'feature', value: 'disabled')
|
||||
option('use_sys_lz4', type: 'feature', value: 'disabled')
|
||||
option('use_sys_xxhash', type: 'feature', value: 'disabled')
|
||||
|
|
|
|||
110
shlr/meson.build
110
shlr/meson.build
|
|
@ -165,105 +165,19 @@ endif
|
|||
|
||||
|
||||
# handle zip dependency
|
||||
zip_dep = dependency('libzip', required: get_option('use_sys_zip'), static: is_static_build)
|
||||
if not zip_dep.found()
|
||||
zip_files = [
|
||||
'zip/zip/zip_add.c',
|
||||
'zip/zip/zip_add_dir.c',
|
||||
'zip/zip/zip_add_entry.c',
|
||||
'zip/zip/zip_close.c',
|
||||
'zip/zip/zip_delete.c',
|
||||
'zip/zip/zip_dir_add.c',
|
||||
'zip/zip/zip_dirent.c',
|
||||
'zip/zip/zip_discard.c',
|
||||
'zip/zip/zip_entry.c',
|
||||
'zip/zip/zip_err_str.c',
|
||||
'zip/zip/zip_error.c',
|
||||
#'zip/zip/zip_error_clear.c',
|
||||
'zip/zip/zip_error_get.c',
|
||||
'zip/zip/zip_error_get_sys_type.c',
|
||||
'zip/zip/zip_error_strerror.c',
|
||||
'zip/zip/zip_error_to_str.c',
|
||||
'zip/zip/zip_extra_field.c',
|
||||
'zip/zip/zip_extra_field_api.c',
|
||||
'zip/zip/zip_fclose.c',
|
||||
'zip/zip/zip_fdopen.c',
|
||||
'zip/zip/zip_file_add.c',
|
||||
#'zip/zip/zip_file_error_clear.c',
|
||||
'zip/zip/zip_file_error_get.c',
|
||||
'zip/zip/zip_file_get_comment.c',
|
||||
'zip/zip/zip_file_get_offset.c',
|
||||
'zip/zip/zip_file_rename.c',
|
||||
'zip/zip/zip_file_replace.c',
|
||||
'zip/zip/zip_file_set_comment.c',
|
||||
'zip/zip/zip_file_strerror.c',
|
||||
'zip/zip/zip_filerange_crc.c',
|
||||
'zip/zip/zip_fopen.c',
|
||||
'zip/zip/zip_fopen_encrypted.c',
|
||||
'zip/zip/zip_fopen_index.c',
|
||||
'zip/zip/zip_fopen_index_encrypted.c',
|
||||
'zip/zip/zip_fread.c',
|
||||
'zip/zip/zip_get_archive_comment.c',
|
||||
'zip/zip/zip_get_archive_flag.c',
|
||||
'zip/zip/zip_get_compression_implementation.c',
|
||||
'zip/zip/zip_get_encryption_implementation.c',
|
||||
'zip/zip/zip_get_file_comment.c',
|
||||
'zip/zip/zip_get_name.c',
|
||||
'zip/zip/zip_get_num_entries.c',
|
||||
'zip/zip/zip_get_num_files.c',
|
||||
'zip/zip/zip_name_locate.c',
|
||||
'zip/zip/zip_new.c',
|
||||
'zip/zip/zip_open.c',
|
||||
'zip/zip/zip_rename.c',
|
||||
'zip/zip/zip_replace.c',
|
||||
'zip/zip/zip_set_archive_comment.c',
|
||||
'zip/zip/zip_set_archive_flag.c',
|
||||
'zip/zip/zip_set_default_password.c',
|
||||
'zip/zip/zip_set_file_comment.c',
|
||||
'zip/zip/zip_set_file_compression.c',
|
||||
'zip/zip/zip_set_name.c',
|
||||
'zip/zip/zip_source_buffer.c',
|
||||
'zip/zip/zip_source_close.c',
|
||||
'zip/zip/zip_source_crc.c',
|
||||
'zip/zip/zip_source_deflate.c',
|
||||
'zip/zip/zip_source_error.c',
|
||||
'zip/zip/zip_source_file.c',
|
||||
'zip/zip/zip_source_filep.c',
|
||||
'zip/zip/zip_source_free.c',
|
||||
'zip/zip/zip_source_function.c',
|
||||
'zip/zip/zip_source_layered.c',
|
||||
'zip/zip/zip_source_open.c',
|
||||
'zip/zip/zip_source_pkware.c',
|
||||
'zip/zip/zip_source_pop.c',
|
||||
'zip/zip/zip_source_read.c',
|
||||
'zip/zip/zip_source_stat.c',
|
||||
'zip/zip/zip_source_window.c',
|
||||
'zip/zip/zip_source_zip.c',
|
||||
'zip/zip/zip_source_zip_new.c',
|
||||
'zip/zip/zip_stat.c',
|
||||
'zip/zip/zip_stat_index.c',
|
||||
'zip/zip/zip_stat_init.c',
|
||||
'zip/zip/zip_strerror.c',
|
||||
'zip/zip/zip_string.c',
|
||||
'zip/zip/zip_unchange.c',
|
||||
'zip/zip/zip_unchange_all.c',
|
||||
'zip/zip/zip_unchange_archive.c',
|
||||
'zip/zip/zip_unchange_data.c',
|
||||
'zip/zip/zip_utf-8.c'
|
||||
]
|
||||
r = run_command(py3_exe, check_meson_subproject_py, 'libzip')
|
||||
if r.returncode() == 1 and get_option('subprojects_check')
|
||||
error('Subprojects are not updated. Please run `git clean -dxff subprojects/` to delete all local subprojects directories. If you want to compile against current subprojects then set option `subprojects_check=false`.')
|
||||
endif
|
||||
|
||||
zip_inc = [platform_inc, include_directories('zip/include')]
|
||||
|
||||
librzzip = static_library('rzzip', zip_files,
|
||||
include_directories: zip_inc,
|
||||
implicit_include_directories: false,
|
||||
dependencies: zlib_dep
|
||||
)
|
||||
|
||||
zip_dep = declare_dependency(
|
||||
link_with: librzzip,
|
||||
include_directories: zip_inc
|
||||
)
|
||||
libzip_dep = dependency('libzip', required: get_option('use_sys_libzip'), static: is_static_build)
|
||||
if not libzip_dep.found()
|
||||
libzip_proj = subproject('libzip', default_options: [
|
||||
'default_library=static',
|
||||
'static_runtime=@0@'.format(is_static_build),
|
||||
'use_sys_openssl=@0@'.format(get_option('use_sys_libzip_openssl')),
|
||||
])
|
||||
libzip_dep = libzip_proj.get_variable('libzip_dep')
|
||||
endif
|
||||
|
||||
# handle winkd dependency
|
||||
|
|
|
|||
6
subprojects/libzip.wrap
Normal file
6
subprojects/libzip.wrap
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[wrap-file]
|
||||
directory = libzip-1.7.3
|
||||
source_url = https://libzip.org/download/libzip-1.7.3.tar.gz
|
||||
source_filename = libzip-1.7.3.tar.gz
|
||||
source_hash = 0e2276c550c5a310d4ebf3a2c3dfc43fb3b4602a072ff625842ad4f3238cb9cc
|
||||
patch_directory = libzip-1.7.3
|
||||
62
subprojects/packagefiles/libzip-1.7.3/cmake-config.h.in
Normal file
62
subprojects/packagefiles/libzip-1.7.3/cmake-config.h.in
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#ifndef HAD_CONFIG_H
|
||||
#define HAD_CONFIG_H
|
||||
#ifndef _HAD_ZIPCONF_H
|
||||
#include "zipconf.h"
|
||||
#endif
|
||||
/* BEGIN DEFINES */
|
||||
#cmakedefine HAVE___PROGNAME
|
||||
#cmakedefine HAVE__CLOSE
|
||||
#cmakedefine HAVE__DUP
|
||||
#cmakedefine HAVE__FDOPEN
|
||||
#cmakedefine HAVE__FILENO
|
||||
#cmakedefine HAVE__SETMODE
|
||||
#cmakedefine HAVE__SNPRINTF
|
||||
#cmakedefine HAVE__STRDUP
|
||||
#cmakedefine HAVE__STRICMP
|
||||
#cmakedefine HAVE__STRTOI64
|
||||
#cmakedefine HAVE__STRTOUI64
|
||||
#cmakedefine HAVE__UMASK
|
||||
#cmakedefine HAVE__UNLINK
|
||||
#cmakedefine HAVE_ARC4RANDOM
|
||||
#cmakedefine HAVE_CLONEFILE
|
||||
#cmakedefine HAVE_COMMONCRYPTO
|
||||
#cmakedefine HAVE_CRYPTO
|
||||
#cmakedefine HAVE_FICLONERANGE
|
||||
#cmakedefine HAVE_FILENO
|
||||
#cmakedefine HAVE_FSEEKO
|
||||
#cmakedefine HAVE_FTELLO
|
||||
#cmakedefine HAVE_GETPROGNAME
|
||||
#cmakedefine HAVE_GNUTLS
|
||||
#cmakedefine HAVE_LIBBZ2
|
||||
#cmakedefine HAVE_LIBLZMA
|
||||
#cmakedefine HAVE_LOCALTIME_R
|
||||
#cmakedefine HAVE_MBEDTLS
|
||||
#cmakedefine HAVE_MKSTEMP
|
||||
#cmakedefine HAVE_NULLABLE
|
||||
#cmakedefine HAVE_OPENSSL
|
||||
#cmakedefine HAVE_SETMODE
|
||||
#cmakedefine HAVE_SNPRINTF
|
||||
#cmakedefine HAVE_STRCASECMP
|
||||
#cmakedefine HAVE_STRDUP
|
||||
#cmakedefine HAVE_STRICMP
|
||||
#cmakedefine HAVE_STRTOLL
|
||||
#cmakedefine HAVE_STRTOULL
|
||||
#cmakedefine HAVE_STRUCT_TM_TM_ZONE
|
||||
#cmakedefine HAVE_STDBOOL_H
|
||||
#cmakedefine HAVE_STRINGS_H
|
||||
#cmakedefine HAVE_UNISTD_H
|
||||
#cmakedefine HAVE_WINDOWS_CRYPTO
|
||||
#cmakedefine SIZEOF_OFF_T @SIZEOF_OFF_T@
|
||||
#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@
|
||||
#cmakedefine HAVE_DIRENT_H
|
||||
#cmakedefine HAVE_FTS_H
|
||||
#cmakedefine HAVE_NDIR_H
|
||||
#cmakedefine HAVE_SYS_DIR_H
|
||||
#cmakedefine HAVE_SYS_NDIR_H
|
||||
#cmakedefine WORDS_BIGENDIAN
|
||||
#cmakedefine HAVE_SHARED
|
||||
/* END DEFINES */
|
||||
#define PACKAGE "@CMAKE_PROJECT_NAME@"
|
||||
#define VERSION "@CMAKE_PROJECT_VERSION@"
|
||||
|
||||
#endif /* HAD_CONFIG_H */
|
||||
53
subprojects/packagefiles/libzip-1.7.3/cmake-zipconf.h.in
Normal file
53
subprojects/packagefiles/libzip-1.7.3/cmake-zipconf.h.in
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#ifndef _HAD_ZIPCONF_H
|
||||
#define _HAD_ZIPCONF_H
|
||||
|
||||
/*
|
||||
zipconf.h -- platform specific include file
|
||||
|
||||
This file was generated automatically by CMake
|
||||
based on ../cmake-zipconf.h.in.
|
||||
*/
|
||||
|
||||
#define LIBZIP_VERSION "${libzip_VERSION}"
|
||||
#define LIBZIP_VERSION_MAJOR ${libzip_VERSION_MAJOR}
|
||||
#define LIBZIP_VERSION_MINOR ${libzip_VERSION_MINOR}
|
||||
#define LIBZIP_VERSION_MICRO ${libzip_VERSION_PATCH}
|
||||
|
||||
#cmakedefine HAVE_LIMITS_H
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#cmakedefine ZIP_STATIC
|
||||
|
||||
${ZIP_NULLABLE_DEFINES}
|
||||
|
||||
${LIBZIP_TYPES_INCLUDE}
|
||||
|
||||
typedef ${ZIP_INT8_T} zip_int8_t;
|
||||
typedef ${ZIP_UINT8_T} zip_uint8_t;
|
||||
typedef ${ZIP_INT16_T} zip_int16_t;
|
||||
typedef ${ZIP_UINT16_T} zip_uint16_t;
|
||||
typedef ${ZIP_INT32_T} zip_int32_t;
|
||||
typedef ${ZIP_UINT32_T} zip_uint32_t;
|
||||
typedef ${ZIP_INT64_T} zip_int64_t;
|
||||
typedef ${ZIP_UINT64_T} zip_uint64_t;
|
||||
|
||||
#define ZIP_INT8_MIN (-ZIP_INT8_MAX-1)
|
||||
#define ZIP_INT8_MAX 0x7f
|
||||
#define ZIP_UINT8_MAX 0xff
|
||||
|
||||
#define ZIP_INT16_MIN (-ZIP_INT16_MAX-1)
|
||||
#define ZIP_INT16_MAX 0x7fff
|
||||
#define ZIP_UINT16_MAX 0xffff
|
||||
|
||||
#define ZIP_INT32_MIN (-ZIP_INT32_MAX-1L)
|
||||
#define ZIP_INT32_MAX 0x7fffffffL
|
||||
#define ZIP_UINT32_MAX 0xffffffffLU
|
||||
|
||||
#define ZIP_INT64_MIN (-ZIP_INT64_MAX-1LL)
|
||||
#define ZIP_INT64_MAX 0x7fffffffffffffffLL
|
||||
#define ZIP_UINT64_MAX 0xffffffffffffffffULL
|
||||
|
||||
#endif /* zipconf.h */
|
||||
42
subprojects/packagefiles/libzip-1.7.3/create_zip_err_str.py
Executable file
42
subprojects/packagefiles/libzip-1.7.3/create_zip_err_str.py
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
|
||||
TEMPLATE = '''/*
|
||||
This file was auto-generated by Meson from zip.h
|
||||
*/
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
const char * const _zip_err_str[] = {{
|
||||
{zip_err_strs}
|
||||
}};
|
||||
|
||||
const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]);
|
||||
|
||||
#define N ZIP_ET_NONE
|
||||
#define S ZIP_ET_SYS
|
||||
#define Z ZIP_ET_ZLIB
|
||||
|
||||
const int _zip_err_type[] = {{
|
||||
{zip_err_types}
|
||||
}};
|
||||
|
||||
'''
|
||||
|
||||
zip_err_str_c = sys.argv[1]
|
||||
zip_h = sys.argv[2]
|
||||
|
||||
def getcomment(x):
|
||||
return x[x.index('/* ') + 3:x.index('*/')]
|
||||
|
||||
def def2errstr(x):
|
||||
return getcomment(x).split(' ', 1)[1]
|
||||
|
||||
def def2errtype(x):
|
||||
return getcomment(x).split(' ', 1)[0]
|
||||
|
||||
defines = [l for l in open(zip_h, 'r').read().split('\n') if l.startswith('#define ZIP_ER')]
|
||||
zip_err_strs = '\n'.join(['"' + def2errstr(x) + '",' for x in defines])
|
||||
zip_err_types = '\n'.join([def2errtype(x) + ',' for x in defines])
|
||||
|
||||
open(zip_err_str_c, 'w').write(TEMPLATE.format(zip_err_strs=zip_err_strs, zip_err_types=zip_err_types))
|
||||
405
subprojects/packagefiles/libzip-1.7.3/meson.build
Normal file
405
subprojects/packagefiles/libzip-1.7.3/meson.build
Normal file
|
|
@ -0,0 +1,405 @@
|
|||
project('libzip', ['c'],
|
||||
default_options : ['c_std=c99', 'buildtype=release'],
|
||||
version: '1.7.3')
|
||||
|
||||
py3_exe = import('python').find_installation()
|
||||
cc = meson.get_compiler('c')
|
||||
is_static_build = get_option('static_runtime')
|
||||
|
||||
# Create config.h file
|
||||
conf_data = configuration_data()
|
||||
zlib_dep = dependency('zlib', required: get_option('use_sys_zlib'), static: is_static_build)
|
||||
if not zlib_dep.found()
|
||||
zlib_proj = subproject('zlib', default_options: ['default_library=static'])
|
||||
zlib_dep = zlib_proj.get_variable('zlib_dep')
|
||||
endif
|
||||
libzip_deps = [zlib_dep]
|
||||
|
||||
bzip2_dep = disabler()
|
||||
lzma_dep = disabler()
|
||||
have_crypto = false
|
||||
openssl_dep = disabler()
|
||||
if host_machine.system() == 'windows'
|
||||
conf_data.set10('HAVE_CRYPTO', true)
|
||||
conf_data.set10('HAVE_WINDOWS_CRYPTO', true)
|
||||
have_crypto = true
|
||||
libzip_deps += []
|
||||
else
|
||||
bzip2_dep = dependency('bzip2', required: false, static: is_static_build)
|
||||
if bzip2_dep.found()
|
||||
conf_data.set10('HAVE_LIBBZ2', true)
|
||||
libzip_deps += [bzip2_dep]
|
||||
endif
|
||||
lzma_dep = dependency('lzma', required: false, static: is_static_build)
|
||||
if not lzma_dep.found()
|
||||
lzma_dep = cc.find_library('lzma', required: false, static: is_static_build)
|
||||
endif
|
||||
if lzma_dep.found()
|
||||
conf_data.set10('HAVE_LIBLZMA', true)
|
||||
libzip_deps += [lzma_dep]
|
||||
endif
|
||||
if get_option('use_sys_openssl')
|
||||
openssl_dep = dependency('openssl', required: false, static: is_static_build)
|
||||
if openssl_dep.found()
|
||||
conf_data.set10('HAVE_OPENSSL', true)
|
||||
conf_data.set10('HAVE_CRYPTO', true)
|
||||
have_crypto = true
|
||||
libzip_deps += [openssl_dep]
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
underscore_functions = ['close', 'dup', 'fdopen', 'fileno', 'setmode', 'snprintf', 'strdup', 'stricmp', 'strtoi64', 'strtoui64', 'umask', 'unlink']
|
||||
functions = ['arc4random', 'clonefile', 'explicit_bzero', 'explicit_memset', 'fileno', 'fseeko', 'ftello', 'getprogname', 'localtime_r', 'mkstemp', 'setmode', 'snprintf', 'strdup', 'stricmp', 'strtoll', 'strtoull']
|
||||
headers = ['stdbool.h', 'strings.h', 'unistd.h', 'dirent.h', 'fts.h', 'ndir.h', 'sys/dir.h', 'sys/ndir.h', 'sys/attr.h']
|
||||
types = ['off_t', 'size_t']
|
||||
# special case because clang-cl finds strcasecmp but has problem while linking
|
||||
if cc.get_id() != 'clang-cl' and cc.has_function('strcasecmp')
|
||||
conf_data.set10('HAVE_STRCASECMP', true)
|
||||
have_strcasecmp = true
|
||||
endif
|
||||
foreach fcn : functions
|
||||
if cc.has_function(fcn) or cc.has_function(fcn, prefix: '#include <stdio.h>')
|
||||
conf_data.set10('HAVE_@0@'.format(fcn.to_upper()), true)
|
||||
set_variable('have_@0@'.format(fcn.to_lower()), true)
|
||||
endif
|
||||
endforeach
|
||||
foreach fcn : underscore_functions
|
||||
if (cc.has_function('_' + fcn) or cc.has_function('_' + fcn, prefix: '#include <stdio.h>')) and not get_variable('have_@0@'.format(fcn.to_lower()), false)
|
||||
conf_data.set10('HAVE__@0@'.format(fcn.to_upper()), true)
|
||||
endif
|
||||
endforeach
|
||||
foreach hdr : headers
|
||||
if cc.has_header(hdr)
|
||||
conf_data.set10('HAVE_@0@'.format(hdr.underscorify().to_upper()), true)
|
||||
endif
|
||||
endforeach
|
||||
foreach type : types
|
||||
sz = cc.sizeof(type)
|
||||
if sz == -1
|
||||
# Windows requires the header to find off_t
|
||||
sz = cc.sizeof(type, prefix: '#include <sys/types.h>')
|
||||
endif
|
||||
conf_data.set('SIZEOF_@0@'.format(type.underscorify().to_upper()), sz)
|
||||
endforeach
|
||||
|
||||
ok = cc.compiles('''#include <sys/ioctl.h>
|
||||
#include <linux/fs.h>
|
||||
int main(int argc, char *argv[]) { unsigned long x = FICLONERANGE; }''')
|
||||
if ok
|
||||
conf_data.set10('HAVE_FICLONERANGE', ok)
|
||||
endif
|
||||
|
||||
have_nullable = cc.compiles('''
|
||||
int foo(char * _Nullable bar);
|
||||
int main(int argc, char *argv[]) { }''')
|
||||
if have_nullable
|
||||
conf_data.set10('HAVE_NULLABLE', have_nullable)
|
||||
endif
|
||||
|
||||
is_big_endian = host_machine.endian() == 'big'
|
||||
if is_big_endian
|
||||
conf_data.set10('WORDS_BIGENDIAN', is_big_endian)
|
||||
endif
|
||||
if get_option('default_library') == 'shared'
|
||||
zipconf_data.set('HAVE_SHARED', true)
|
||||
endif
|
||||
conf_data.set('CMAKE_PROJECT_NAME', 'libzip')
|
||||
conf_data.set('CMAKE_PROJECT_VERSION', meson.project_version())
|
||||
|
||||
config_h = configure_file(
|
||||
input: 'cmake-config.h.in',
|
||||
output: 'config.h',
|
||||
configuration: conf_data,
|
||||
format: 'cmake@',
|
||||
)
|
||||
|
||||
# Create zipconf.h file
|
||||
version_split = meson.project_version().split('.')
|
||||
version_major = version_split[0].to_int()
|
||||
version_minor = version_split[1].to_int()
|
||||
version_patch = version_split[2].split('-')[0].to_int()
|
||||
|
||||
zipconf_data = configuration_data()
|
||||
zipconf_data.set('libzip_VERSION', meson.project_version())
|
||||
zipconf_data.set('libzip_VERSION_MAJOR', version_major)
|
||||
zipconf_data.set('libzip_VERSION_MINOR', version_minor)
|
||||
zipconf_data.set('libzip_VERSION_PATCH', version_patch)
|
||||
if cc.has_header('limits.h')
|
||||
zipconf_data.set10('HAVE_LIMITS_H', true)
|
||||
endif
|
||||
if get_option('default_library') == 'static'
|
||||
zipconf_data.set10('ZIP_STATIC', true)
|
||||
endif
|
||||
if have_nullable
|
||||
zipconf_data.set('ZIP_NULLABLE_DEFINES', '')
|
||||
else
|
||||
zipconf_data.set('ZIP_NULLABLE_DEFINES', '''#define _Nullable
|
||||
#define _Nonnull''')
|
||||
endif
|
||||
if cc.has_header('inttypes.h')
|
||||
types_header_prefix = '''#if !defined(__STDC_FORMAT_MACROS)
|
||||
#define __STDC_FORMAT_MACROS 1
|
||||
#endif
|
||||
#include <inttypes.h>'''
|
||||
zipconf_data.set('LIBZIP_TYPES_INCLUDE', types_header_prefix)
|
||||
elif cc.has_header('stdint.h')
|
||||
types_header_prefix = '#include <stdin.h>'
|
||||
zipconf_data.set('LIBZIP_TYPES_INCLUDE', types_header_prefix)
|
||||
elif cc.has_header('sys/types.h')
|
||||
types_header_prefix = '#include <sys/types.h>'
|
||||
zipconf_data.set('LIBZIP_TYPES_INCLUDE', types_header_prefix)
|
||||
endif
|
||||
|
||||
types = ['int8_t', 'uint8_t', 'int16_t', 'uint16_t', 'int32_t', 'uint32_t', 'int64_t', 'uint64_t']
|
||||
underscore_types = ['__int8', '__int16', '__int32', '__int64']
|
||||
foreach t : types + underscore_types
|
||||
set_variable('have_@0@'.format(t), cc.has_type(t, prefix: types_header_prefix))
|
||||
endforeach
|
||||
|
||||
if have_int8_t
|
||||
zipconf_data.set('ZIP_INT8_T', 'int8_t')
|
||||
elif have___int8
|
||||
zipconf_data.set('ZIP_INT8_T', '__int8')
|
||||
else
|
||||
zipconf_data.set('ZIP_INT8_T', 'signed char')
|
||||
endif
|
||||
if have_uint8_t
|
||||
zipconf_data.set('ZIP_UINT8_T', 'uint8_t')
|
||||
elif have___int8
|
||||
zipconf_data.set('ZIP_UINT8_T', 'unsigned __int8')
|
||||
else
|
||||
zipconf_data.set('ZIP_UINT8_T', 'unsigned char')
|
||||
endif
|
||||
if have_int16_t
|
||||
zipconf_data.set('ZIP_INT16_T', 'int16_t')
|
||||
elif have___int16
|
||||
zipconf_data.set('ZIP_INT16_T', '__int16')
|
||||
else
|
||||
zipconf_data.set('ZIP_INT16_T', 'short')
|
||||
endif
|
||||
if have_uint16_t
|
||||
zipconf_data.set('ZIP_UINT16_T', 'uint16_t')
|
||||
elif have___int16
|
||||
zipconf_data.set('ZIP_UINT16_T', 'unsigned __int16')
|
||||
else
|
||||
zipconf_data.set('ZIP_UINT16_T', 'unsigned short')
|
||||
endif
|
||||
if have_int32_t
|
||||
zipconf_data.set('ZIP_INT32_T', 'int32_t')
|
||||
elif have___int32
|
||||
zipconf_data.set('ZIP_INT32_T', '__int32')
|
||||
else
|
||||
zipconf_data.set('ZIP_INT32_T', 'long')
|
||||
endif
|
||||
if have_uint32_t
|
||||
zipconf_data.set('ZIP_UINT32_T', 'uint32_t')
|
||||
elif have___int32
|
||||
zipconf_data.set('ZIP_UINT32_T', 'unsigned __int32')
|
||||
else
|
||||
zipconf_data.set('ZIP_UINT32_T', 'unsigned long')
|
||||
endif
|
||||
if have_int64_t
|
||||
zipconf_data.set('ZIP_INT64_T', 'int64_t')
|
||||
elif have___int64
|
||||
zipconf_data.set('ZIP_INT64_T', '__int64')
|
||||
else
|
||||
zipconf_data.set('ZIP_INT64_T', 'long long')
|
||||
endif
|
||||
if have_uint64_t
|
||||
zipconf_data.set('ZIP_UINT64_T', 'uint64_t')
|
||||
elif have___int64
|
||||
zipconf_data.set('ZIP_UINT64_T', 'unsigned __int64')
|
||||
else
|
||||
zipconf_data.set('ZIP_UINT64_T', 'unsigned long long')
|
||||
endif
|
||||
|
||||
zipconf_h = configure_file(
|
||||
input: 'cmake-zipconf.h.in',
|
||||
output: 'zipconf.h',
|
||||
configuration: zipconf_data,
|
||||
format: 'cmake',
|
||||
)
|
||||
|
||||
|
||||
# Create zip_err_str.c file
|
||||
|
||||
zip_h = files('lib/zip.h')
|
||||
create_zip_err_str_py = files('./create_zip_err_str.py')
|
||||
zip_err_str_c = custom_target('zip_err_str',
|
||||
build_by_default: true,
|
||||
output: 'zip_err_str.c',
|
||||
input: zip_h,
|
||||
command: [
|
||||
py3_exe,
|
||||
create_zip_err_str_py,
|
||||
'@OUTPUT@',
|
||||
'@INPUT@',
|
||||
],
|
||||
install: false,
|
||||
)
|
||||
|
||||
# Build libzip library
|
||||
|
||||
zip_files = [
|
||||
'lib/zip_add.c',
|
||||
'lib/zip_add_dir.c',
|
||||
'lib/zip_add_entry.c',
|
||||
'lib/zip_algorithm_deflate.c',
|
||||
'lib/zip_buffer.c',
|
||||
'lib/zip_close.c',
|
||||
'lib/zip_delete.c',
|
||||
'lib/zip_dir_add.c',
|
||||
'lib/zip_dirent.c',
|
||||
'lib/zip_discard.c',
|
||||
'lib/zip_entry.c',
|
||||
'lib/zip_error.c',
|
||||
'lib/zip_error_clear.c',
|
||||
'lib/zip_error_get.c',
|
||||
'lib/zip_error_get_sys_type.c',
|
||||
'lib/zip_error_strerror.c',
|
||||
'lib/zip_error_to_str.c',
|
||||
'lib/zip_extra_field.c',
|
||||
'lib/zip_extra_field_api.c',
|
||||
'lib/zip_fclose.c',
|
||||
'lib/zip_fdopen.c',
|
||||
'lib/zip_file_add.c',
|
||||
'lib/zip_file_error_clear.c',
|
||||
'lib/zip_file_error_get.c',
|
||||
'lib/zip_file_get_comment.c',
|
||||
'lib/zip_file_get_external_attributes.c',
|
||||
'lib/zip_file_get_offset.c',
|
||||
'lib/zip_file_rename.c',
|
||||
'lib/zip_file_replace.c',
|
||||
'lib/zip_file_set_comment.c',
|
||||
'lib/zip_file_set_encryption.c',
|
||||
'lib/zip_file_set_external_attributes.c',
|
||||
'lib/zip_file_set_mtime.c',
|
||||
'lib/zip_file_strerror.c',
|
||||
'lib/zip_fopen.c',
|
||||
'lib/zip_fopen_encrypted.c',
|
||||
'lib/zip_fopen_index.c',
|
||||
'lib/zip_fopen_index_encrypted.c',
|
||||
'lib/zip_fread.c',
|
||||
'lib/zip_fseek.c',
|
||||
'lib/zip_ftell.c',
|
||||
'lib/zip_get_archive_comment.c',
|
||||
'lib/zip_get_archive_flag.c',
|
||||
'lib/zip_get_encryption_implementation.c',
|
||||
'lib/zip_get_file_comment.c',
|
||||
'lib/zip_get_name.c',
|
||||
'lib/zip_get_num_entries.c',
|
||||
'lib/zip_get_num_files.c',
|
||||
'lib/zip_hash.c',
|
||||
'lib/zip_io_util.c',
|
||||
'lib/zip_libzip_version.c',
|
||||
'lib/zip_memdup.c',
|
||||
'lib/zip_name_locate.c',
|
||||
'lib/zip_new.c',
|
||||
'lib/zip_open.c',
|
||||
'lib/zip_pkware.c',
|
||||
'lib/zip_progress.c',
|
||||
'lib/zip_rename.c',
|
||||
'lib/zip_replace.c',
|
||||
'lib/zip_set_archive_comment.c',
|
||||
'lib/zip_set_archive_flag.c',
|
||||
'lib/zip_set_default_password.c',
|
||||
'lib/zip_set_file_comment.c',
|
||||
'lib/zip_set_file_compression.c',
|
||||
'lib/zip_set_name.c',
|
||||
'lib/zip_source_accept_empty.c',
|
||||
'lib/zip_source_begin_write.c',
|
||||
'lib/zip_source_begin_write_cloning.c',
|
||||
'lib/zip_source_buffer.c',
|
||||
'lib/zip_source_call.c',
|
||||
'lib/zip_source_close.c',
|
||||
'lib/zip_source_commit_write.c',
|
||||
'lib/zip_source_compress.c',
|
||||
'lib/zip_source_crc.c',
|
||||
'lib/zip_source_error.c',
|
||||
'lib/zip_source_file_common.c',
|
||||
'lib/zip_source_file_stdio.c',
|
||||
'lib/zip_source_free.c',
|
||||
'lib/zip_source_function.c',
|
||||
'lib/zip_source_get_file_attributes.c',
|
||||
'lib/zip_source_is_deleted.c',
|
||||
'lib/zip_source_layered.c',
|
||||
'lib/zip_source_open.c',
|
||||
'lib/zip_source_pkware_decode.c',
|
||||
'lib/zip_source_pkware_encode.c',
|
||||
'lib/zip_source_read.c',
|
||||
'lib/zip_source_remove.c',
|
||||
'lib/zip_source_rollback_write.c',
|
||||
'lib/zip_source_seek.c',
|
||||
'lib/zip_source_seek_write.c',
|
||||
'lib/zip_source_stat.c',
|
||||
'lib/zip_source_supports.c',
|
||||
'lib/zip_source_tell.c',
|
||||
'lib/zip_source_tell_write.c',
|
||||
'lib/zip_source_window.c',
|
||||
'lib/zip_source_write.c',
|
||||
'lib/zip_source_zip.c',
|
||||
'lib/zip_source_zip_new.c',
|
||||
'lib/zip_stat.c',
|
||||
'lib/zip_stat_index.c',
|
||||
'lib/zip_stat_init.c',
|
||||
'lib/zip_strerror.c',
|
||||
'lib/zip_string.c',
|
||||
'lib/zip_unchange.c',
|
||||
'lib/zip_unchange_all.c',
|
||||
'lib/zip_unchange_archive.c',
|
||||
'lib/zip_unchange_data.c',
|
||||
'lib/zip_utf-8.c',
|
||||
]
|
||||
|
||||
if host_machine.system() == 'windows'
|
||||
zip_files += [
|
||||
'lib/zip_source_file_win32.c',
|
||||
'lib/zip_source_file_win32_named.c',
|
||||
'lib/zip_source_file_win32_utf16.c',
|
||||
'lib/zip_source_file_win32_utf8.c',
|
||||
'lib/zip_source_file_win32_ansi.c',
|
||||
'lib/zip_random_win32.c',
|
||||
]
|
||||
libzip_deps += [cc.find_library('advapi32')]
|
||||
else
|
||||
zip_files += [
|
||||
'lib/zip_mkstempm.c',
|
||||
'lib/zip_source_file_stdio_named.c',
|
||||
'lib/zip_random_unix.c'
|
||||
]
|
||||
endif
|
||||
|
||||
if bzip2_dep.found()
|
||||
zip_files += ['lib/zip_algorithm_bzip2.c']
|
||||
endif
|
||||
if lzma_dep.found()
|
||||
zip_files += ['lib/zip_algorithm_xz.c']
|
||||
endif
|
||||
if openssl_dep.found()
|
||||
zip_files += ['lib/zip_crypto_openssl.c']
|
||||
endif
|
||||
if host_machine.system() == 'windows' and have_crypto
|
||||
zip_files += ['lib/zip_crypto_win.c']
|
||||
libzip_deps += [cc.find_library('bcrypt')]
|
||||
endif
|
||||
if have_crypto
|
||||
zip_files += ['lib/zip_winzip_aes.c', 'lib/zip_source_winzip_aes_decode.c', 'lib/zip_source_winzip_aes_encode.c']
|
||||
endif
|
||||
|
||||
zip_files += [zip_err_str_c]
|
||||
|
||||
zip_inc = [include_directories('lib', '.')]
|
||||
|
||||
libzip = library('libzip', zip_files,
|
||||
dependencies: libzip_deps,
|
||||
include_directories: zip_inc,
|
||||
implicit_include_directories: true,
|
||||
install: false,
|
||||
)
|
||||
|
||||
libzip_dep = declare_dependency(
|
||||
link_with: libzip,
|
||||
include_directories: zip_inc,
|
||||
dependencies: libzip_deps,
|
||||
)
|
||||
3
subprojects/packagefiles/libzip-1.7.3/meson_options.txt
Normal file
3
subprojects/packagefiles/libzip-1.7.3/meson_options.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
option('use_sys_zlib', type: 'boolean', value: 'false', description: 'When true it looks for system zlib dependency, otherwise it embeds one')
|
||||
option('static_runtime', type: 'boolean', value: false, description: 'Set to true when you want static libraries/dependencies and runtime')
|
||||
option('use_sys_openssl', type: 'boolean', value: true, description: 'Whether to use or not system openssl dependency to build libzip')
|
||||
|
|
@ -17,7 +17,7 @@ if [ "${RZ_SYS_ZLIB}" != "" ] ; then
|
|||
OPTS="${OPTS} -D use_sys_zlib=${RZ_SYS_ZLIB}"
|
||||
fi
|
||||
if [ "${RZ_SYS_ZIP}" != "" ] ; then
|
||||
OPTS="${OPTS} -D use_sys_zip=${RZ_SYS_ZIP}"
|
||||
OPTS="${OPTS} -D use_sys_libzip=${RZ_SYS_ZIP}"
|
||||
fi
|
||||
if [ "${RZ_SYS_LZ4}" != "" ] ; then
|
||||
OPTS="${OPTS} -D use_sys_lz4=${RZ_SYS_LZ4}"
|
||||
|
|
|
|||
Loading…
Reference in a new issue