diff -r 1ce7a55b09d1 -r b1fb341d8a61 contrib/python-zstandard/make_cffi.py --- a/contrib/python-zstandard/make_cffi.py Sun Apr 08 01:08:43 2018 +0200 +++ b/contrib/python-zstandard/make_cffi.py Mon Apr 09 10:13:29 2018 -0700 @@ -27,6 +27,11 @@ 'compress/fse_compress.c', 'compress/huf_compress.c', 'compress/zstd_compress.c', + 'compress/zstd_double_fast.c', + 'compress/zstd_fast.c', + 'compress/zstd_lazy.c', + 'compress/zstd_ldm.c', + 'compress/zstd_opt.c', 'compress/zstdmt_compress.c', 'decompress/huf_decompress.c', 'decompress/zstd_decompress.c', @@ -38,7 +43,6 @@ # Headers whose preprocessed output will be fed into cdef(). HEADERS = [os.path.join(HERE, 'zstd', *p) for p in ( ('zstd.h',), - ('compress', 'zstdmt_compress.h'), ('dictBuilder', 'zdict.h'), )] @@ -80,7 +84,9 @@ def preprocess(path): with open(path, 'rb') as fh: lines = [] - for l in fh: + it = iter(fh) + + for l in it: # zstd.h includes , which is also included by cffi's # boilerplate. This can lead to duplicate declarations. So we strip # this include from the preprocessor invocation. @@ -137,18 +143,21 @@ ffi = cffi.FFI() +# zstd.h uses a possible undefined MIN(). Define it until +# https://github.com/facebook/zstd/issues/976 is fixed. # *_DISABLE_DEPRECATE_WARNINGS prevents the compiler from emitting a warning # when cffi uses the function. Since we statically link against zstd, even # if we use the deprecated functions it shouldn't be a huge problem. ffi.set_source('_zstd_cffi', ''' -#include "mem.h" +#define MIN(a,b) ((a)<(b) ? (a) : (b)) #define ZSTD_STATIC_LINKING_ONLY -#include "zstd.h" +#include #define ZDICT_STATIC_LINKING_ONLY #define ZDICT_DISABLE_DEPRECATE_WARNINGS -#include "zdict.h" -#include "zstdmt_compress.h" -''', sources=SOURCES, include_dirs=INCLUDE_DIRS) +#include +''', sources=SOURCES, + include_dirs=INCLUDE_DIRS, + extra_compile_args=['-DZSTD_MULTITHREAD']) DEFINE = re.compile(b'^\\#define ([a-zA-Z0-9_]+) ')