build,vfs,rwops: add compatibility with older libzip

This commit is contained in:
Andrei Alexeyev 2021-04-19 02:20:42 +03:00
parent e23a720034
commit 26ee23d04d
No known key found for this signature in database
GPG key ID: 72D26128040B9690
5 changed files with 39 additions and 5 deletions

View file

@ -21,7 +21,7 @@ Dependencies
- freetype2
- libpng >= 1.5.0
- libwebpdecoder >= 0.5 or libwebp >= 0.5
- libzip >= 1.7
- libzip >= 1.5.0 (>= 1.7.0 recommended)
- libzstd >= 1.3.0
- opusfile
- zlib

View file

@ -156,7 +156,7 @@ dep_webp = dependency('libwebp', version : '>=0.5', required : t
dep_webpdecoder = dependency('libwebpdecoder', version : '>=0.5', required : false, static : static)
dep_zlib = dependency('zlib', required : true, static : static, fallback : ['zlib', 'zlib_dep'])
dep_zstd = dependency('libzstd', version : '>=1.3.0', required : true, static : static, fallback : ['libzstd', 'libzstd_dep'])
dep_zip = dependency('libzip', version : '>=1.7', required : false, static : static, fallback : ['libzip', 'libzip_dep'])
dep_zip = dependency('libzip', version : '>=1.5.0', required : false, static : static, fallback : ['libzip', 'libzip_dep'])
dep_cglm = dependency('cglm', version : '>=0.7.8', required : true, static : static, fallback : ['cglm', 'cglm_dep'])
dep_crypto = dependency('libcrypto', required : false, static : static)
dep_gamemode = dependency('gamemode', required : false, static : static)
@ -273,6 +273,10 @@ config.set('TAISEI_BUILDCONF_USE_GNU_EXTENSIONS', get_option('use_gnu_ext'))
config.set('TAISEI_BUILDCONF_HAVE_BUILTIN_POPCOUNTLL', cc.has_function('__builtin_popcountll'))
config.set('TAISEI_BUILDCONF_HAVE_BUILTIN_POPCOUNT', cc.has_function('__builtin_popcount'))
config.set('TAISEI_BUILDCONF_HAVE_ZIP_COMPRESSION_METHOD_SUPPORTED',
enable_zip and cc.has_function('zip_compression_method_supported', dependencies : dep_zip)
)
prefer_relpath_systems = [
'windows',
]

View file

@ -11,7 +11,9 @@
#include "rwops_zipfile.h"
#include "rwops_util.h"
#include "rwops_zstd.h"
#include "util.h"
#include "util/libzip_compat.h"
#define FORCE_MANUAL_DECOMPRESSION (0)

30
src/util/libzip_compat.h Normal file
View file

@ -0,0 +1,30 @@
/*
* This software is licensed under the terms of the MIT License.
* See COPYING for further information.
* ---
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
*/
#ifndef IGUARD_util_libzip_compat_h
#define IGUARD_util_libzip_compat_h
#include "taisei.h"
#include <zip.h>
#ifndef TAISEI_BUILDCONF_HAVE_ZIP_COMPRESSION_METHOD_SUPPORTED
#define zip_compression_method_supported _taisei_zip_compression_method_supported
static int _taisei_zip_compression_method_supported(zip_int32_t method, int compress) {
// assume bare minimum
return (method == ZIP_CM_DEFLATE || method == ZIP_CM_STORE);
}
#endif
#ifndef ZIP_CM_ZSTD
#define ZIP_CM_ZSTD 93
#endif
#endif // IGUARD_util_libzip_compat_h

View file

@ -17,9 +17,7 @@ DIAGNOSTIC_CLANG(ignored "-Wnullability-extension")
#include <zip.h>
DIAGNOSTIC_CLANG(pop)
#ifndef ZIP_CM_ZSTD
#define ZIP_CM_ZSTD 93
#endif
#include "util/libzip_compat.h"
#include "private.h"
#include "hashtable.h"