From bd548eebae660ddc88e90538ef3f2b2d3a716368 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 7 Jun 2019 11:52:10 -0700 Subject: [PATCH 1/3] meson: fix name of library --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index e06b169..5fe98de 100644 --- a/meson.build +++ b/meson.build @@ -25,7 +25,7 @@ if cc.has_function_attribute('visibility') endif libbzip2 = library( - 'bzip2', + 'bz2', ['blocksort.c', 'huffman.c', 'crctable.c', 'randtable.c', 'compress.c', 'decompress.c', 'bzlib.c'], c_args : c_args, gnu_symbol_visibility : 'hidden', From 9e8d1644461928567065bfb997621e8049e00076 Mon Sep 17 00:00:00 2001 From: "Marty E. Plummer" Date: Thu, 26 Jul 2018 16:02:53 -0500 Subject: [PATCH 2/3] bzip2: fix mingw compilation https://bugs.gentoo.org/393573 Signed-off-by: Marty E. Plummer --- bzlib.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bzlib.h b/bzlib.h index 77e8a02..04d9711 100644 --- a/bzlib.h +++ b/bzlib.h @@ -81,6 +81,9 @@ typedef /* windows.h define small to char */ # undef small # endif +# ifndef WINAPI +# define WINAPI +# endif # ifdef BZ_EXPORT # define BZ_API(func) WINAPI func # define BZ_EXTERN extern From 6b3d675f7837d8d14477fedaff34b0de172f9a3f Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 7 Jun 2019 12:05:45 -0700 Subject: [PATCH 3/3] meson: Support dlls with msvc I've filed https://github.com/mesonbuild/meson/issues/5462 about the fact that vs_module_defs cannot accept an empty list (the usual way in meson to say "nothing" (like NULL, None, etc). This allows msvc to compile a bz2-1.dll that at least passes the tests provided. The .def file doesn't work for mingw due to (I think) differences in the way msvc and mingw define .def files. I *think*, but I'm not positive, it has to do with stdcall vs cdecl, but I'm just throwing stuff at the wall till it sticks. --- libbz2.def | 4 ++-- meson.build | 31 ++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/libbz2.def b/libbz2.def index 2dc0dd8..80fc2d1 100644 --- a/libbz2.def +++ b/libbz2.def @@ -1,5 +1,5 @@ -LIBRARY LIBBZ2 -DESCRIPTION "libbzip2: library for data compression" +LIBRARY bz2-1 +DESCRIPTION "bz2: library for data compression" EXPORTS BZ2_bzCompressInit BZ2_bzCompress diff --git a/meson.build b/meson.build index 5fe98de..3ea9e86 100644 --- a/meson.build +++ b/meson.build @@ -24,14 +24,27 @@ if cc.has_function_attribute('visibility') c_args += '-DBZ_EXTERN=__attribute__((__visibility__("default")))' endif -libbzip2 = library( - 'bz2', - ['blocksort.c', 'huffman.c', 'crctable.c', 'randtable.c', 'compress.c', 'decompress.c', 'bzlib.c'], - c_args : c_args, - gnu_symbol_visibility : 'hidden', - version : meson.project_version(), - install : true, -) +bz_sources = ['blocksort.c', 'huffman.c', 'crctable.c', 'randtable.c', 'compress.c', 'decompress.c', 'bzlib.c'] + +if ['msvc', 'clang-cl', 'intel-cl'].contains(cc.get_id()) + libbzip2 = library( + 'bz2', + bz_sources, + c_args : c_args, + vs_module_defs : 'libbz2.def', + version : meson.project_version(), + install : true, + ) +else + libbzip2 = library( + 'bz2', + bz_sources, + c_args : c_args, + gnu_symbol_visibility : 'hidden', + version : meson.project_version(), + install : true, + ) +endif bzip2 = executable( 'bzip2', @@ -66,4 +79,4 @@ install_headers('bzlib.h') subdir('man') subdir('docs') -subdir('tests') \ No newline at end of file +subdir('tests')