WIP Try to compile zlib using meson.
This commit is contained in:
parent
d3c275f349
commit
de6fa106bb
|
@ -3,7 +3,7 @@ import shutil
|
||||||
from .base import (
|
from .base import (
|
||||||
Dependency,
|
Dependency,
|
||||||
ReleaseDownload,
|
ReleaseDownload,
|
||||||
MakeBuilder)
|
MesonBuilder)
|
||||||
|
|
||||||
from kiwixbuild.utils import Remotefile, pj, SkipCommand
|
from kiwixbuild.utils import Remotefile, pj, SkipCommand
|
||||||
from kiwixbuild._global import neutralEnv
|
from kiwixbuild._global import neutralEnv
|
||||||
|
@ -15,32 +15,7 @@ class zlib(Dependency):
|
||||||
class Source(ReleaseDownload):
|
class Source(ReleaseDownload):
|
||||||
archive = Remotefile('zlib-1.2.12.tar.gz',
|
archive = Remotefile('zlib-1.2.12.tar.gz',
|
||||||
'91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9')
|
'91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9')
|
||||||
patches = ['zlib_std_libname.patch']
|
patches = ['zlib_meson.patch']
|
||||||
|
|
||||||
class Builder(MakeBuilder):
|
class Builder(MesonBuilder):
|
||||||
dynamic_configure_option = "--shared"
|
pass
|
||||||
static_configure_option = "--static"
|
|
||||||
make_install_target = 'install'
|
|
||||||
configure_option_template = "{dep_options} {static_option} --prefix {install_dir} --libdir {libdir}"
|
|
||||||
|
|
||||||
def _pre_build_script(self, context):
|
|
||||||
context.try_skip(self.build_path)
|
|
||||||
shutil.copytree(self.source_path, self.build_path)
|
|
||||||
|
|
||||||
|
|
||||||
def _configure(self, context):
|
|
||||||
if self.buildEnv.platformInfo.build == 'win32' or neutralEnv('distname') == 'Windows':
|
|
||||||
raise SkipCommand()
|
|
||||||
return super()._configure(context)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def make_option(self):
|
|
||||||
if self.buildEnv.platformInfo.build == 'win32' or neutralEnv('distname') == 'Windows':
|
|
||||||
return "--makefile win32/Makefile.gcc PREFIX={host}- SHARED_MODE={static} INCLUDE_PATH={include_path} LIBRARY_PATH={library_path} BINARY_PATH={binary_path}".format(
|
|
||||||
host='i686-w64-mingw32',
|
|
||||||
static="0" if self.buildEnv.platformInfo.static else "1",
|
|
||||||
include_path=pj(self.buildEnv.install_dir, 'include'),
|
|
||||||
library_path=pj(self.buildEnv.install_dir, self.buildEnv.libprefix),
|
|
||||||
binary_path=pj(self.buildEnv.install_dir, 'bin'),
|
|
||||||
)
|
|
||||||
return ""
|
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
diff -uNr zlib-1.2.11/LICENSE.build zlib-1.2.11.meson/LICENSE.build
|
||||||
|
--- zlib-1.2.11/LICENSE.build 1970-01-01 01:00:00.000000000 +0100
|
||||||
|
+++ zlib-1.2.11.meson/LICENSE.build 2018-05-29 15:10:02.000000000 +0200
|
||||||
|
@@ -0,0 +1,19 @@
|
||||||
|
+Copyright (c) 2018 The Meson development team
|
||||||
|
+
|
||||||
|
+Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
+of this software and associated documentation files (the "Software"), to deal
|
||||||
|
+in the Software without restriction, including without limitation the rights
|
||||||
|
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
+copies of the Software, and to permit persons to whom the Software is
|
||||||
|
+furnished to do so, subject to the following conditions:
|
||||||
|
+
|
||||||
|
+The above copyright notice and this permission notice shall be included in all
|
||||||
|
+copies or substantial portions of the Software.
|
||||||
|
+
|
||||||
|
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
+SOFTWARE.
|
||||||
|
diff -uNr zlib-1.2.11/meson.build zlib-1.2.11.meson/meson.build
|
||||||
|
--- zlib-1.2.11/meson.build 1970-01-01 01:00:00.000000000 +0100
|
||||||
|
+++ zlib-1.2.11.meson/meson.build 2018-06-20 18:09:04.498957829 +0200
|
||||||
|
@@ -0,0 +1,71 @@
|
||||||
|
+project('zlib', 'c', version : '1.2.11', license : 'zlib')
|
||||||
|
+
|
||||||
|
+cc = meson.get_compiler('c')
|
||||||
|
+
|
||||||
|
+link_args = []
|
||||||
|
+compile_args = []
|
||||||
|
+if cc.get_id() == 'msvc'
|
||||||
|
+ add_project_arguments('-D_CRT_SECURE_NO_DEPRECATE',
|
||||||
|
+ '-D_CRT_NONSTDC_NO_DEPRECATE', language : 'c')
|
||||||
|
+else
|
||||||
|
+ # Don't spam consumers of this wrap with these warnings
|
||||||
|
+ compile_args += cc.get_supported_arguments(['-Wno-implicit-fallthrough',
|
||||||
|
+ '-Wno-implicit-function-declaration'])
|
||||||
|
+ if cc.get_id() == 'gcc' and host_machine.system() != 'windows'
|
||||||
|
+ vflag = '-Wl,--version-script,@0@/zlib.map'.format(meson.current_source_dir())
|
||||||
|
+ link_args += [vflag]
|
||||||
|
+ endif
|
||||||
|
+endif
|
||||||
|
+
|
||||||
|
+src = files([
|
||||||
|
+ 'adler32.c',
|
||||||
|
+ 'crc32.c',
|
||||||
|
+ 'deflate.c',
|
||||||
|
+ 'infback.c',
|
||||||
|
+ 'inffast.c',
|
||||||
|
+ 'inflate.c',
|
||||||
|
+ 'inftrees.c',
|
||||||
|
+ 'trees.c',
|
||||||
|
+ 'zutil.c',
|
||||||
|
+ 'compress.c',
|
||||||
|
+ 'uncompr.c',
|
||||||
|
+ 'gzclose.c',
|
||||||
|
+ 'gzlib.c',
|
||||||
|
+ 'gzread.c',
|
||||||
|
+ 'gzwrite.c'])
|
||||||
|
+
|
||||||
|
+headers = files(['zconf.h', 'zlib.h'])
|
||||||
|
+
|
||||||
|
+if host_machine.system() == 'windows'
|
||||||
|
+ win = import('windows')
|
||||||
|
+ win_args = []
|
||||||
|
+ if cc.get_id() != 'msvc'
|
||||||
|
+ win_args += '-DGCC_WINDRES'
|
||||||
|
+ endif
|
||||||
|
+ src += win.compile_resources('win32/zlib1.rc', args : win_args)
|
||||||
|
+endif
|
||||||
|
+
|
||||||
|
+if get_option('solo')
|
||||||
|
+ compile_args += ['-DZ_SOLO']
|
||||||
|
+endif
|
||||||
|
+
|
||||||
|
+zlib = library('z', src,
|
||||||
|
+ c_args : compile_args,
|
||||||
|
+ link_args : link_args,
|
||||||
|
+ vs_module_defs : 'win32/zlib.def',
|
||||||
|
+ install : true)
|
||||||
|
+
|
||||||
|
+incdir = include_directories('.')
|
||||||
|
+
|
||||||
|
+zlib_dep = declare_dependency(
|
||||||
|
+ link_with : zlib,
|
||||||
|
+ include_directories : incdir)
|
||||||
|
+
|
||||||
|
+install_headers(headers)
|
||||||
|
+
|
||||||
|
+pkg = import('pkgconfig')
|
||||||
|
+
|
||||||
|
+pkg.generate(name: 'zlib',
|
||||||
|
+ description: 'zlib compression library',
|
||||||
|
+ version: '1.2.11',
|
||||||
|
+ libraries: zlib)
|
||||||
|
diff -uNr zlib-1.2.11/meson_options.txt zlib-1.2.11.meson/meson_options.txt
|
||||||
|
--- zlib-1.2.11/meson_options.txt 1970-01-01 01:00:00.000000000 +0100
|
||||||
|
+++ zlib-1.2.11.meson/meson_options.txt 2018-05-29 15:10:02.000000000 +0200
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+option('solo', type: 'boolean', value: false, description: 'Build a minimal zlib without file I/O API')
|
Loading…
Reference in New Issue