WIP Try to compile zlib using meson.

This commit is contained in:
Matthieu Gautier 2018-06-20 18:13:33 +02:00
parent 781f6740f2
commit 4cb071ada3
3 changed files with 112 additions and 38 deletions

View File

@ -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
@ -13,39 +13,10 @@ class zlib(Dependency):
name = 'zlib' name = 'zlib'
class Source(ReleaseDownload): class Source(ReleaseDownload):
archive = Remotefile('zlib-1.2.8.tar.gz', archive = Remotefile('zlib-1.2.11.tar.gz',
'36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d') 'c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1',
patches = ['zlib_std_libname.patch'] 'http://zlib.net/fossils/zlib-1.2.11.tar.gz')
patches = ['zlib_meson.patch']
class Builder(MakeBuilder): class Builder(MesonBuilder):
dynamic_configure_options = ["--shared"] pass
static_configure_options = ["--static"]
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':
raise SkipCommand()
return super()._configure(context)
@property
def all_configure_options(self):
yield from self.configure_options
yield from self.static_configure_options if self.buildEnv.platformInfo.static else self.dynamic_configure_options
yield from ('--prefix', self.buildEnv.install_dir)
yield from ('--libdir', pj(self.buildEnv.install_dir, self.buildEnv.libprefix))
@property
def make_options(self):
if self.buildEnv.platformInfo.build == 'win32':
return
yield "--makefile"
yield "{}/Makefile.gcc".format(self.buildEnv.platformInfo.build)
yield "PREFIX={}-".format(self.buildEnv.platformInfo.arch_full)
yield "SHARED_MODE={}".format("0" if self.buildEnv.platformInfo.static else "1")
yield "INCLUDE_PATH={}".format(pj(self.buildEnv.install_dir, 'include'))
yield "LIBRARY_PATH={}".format(pj(self.buildEnv.install_dir, self.buildEnv.libprefix))
yield "BINARY_PATH={}".format(pj(self.buildEnv.install_dir, 'bin'))

View File

@ -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')

View File

@ -10,11 +10,11 @@ main_project_versions = {
# This is the "version" of the whole base_deps_versions dict. # This is the "version" of the whole base_deps_versions dict.
# Change this when you change base_deps_versions. # Change this when you change base_deps_versions.
base_deps_meta_version = '8' base_deps_meta_version = '9'
base_deps_versions = { base_deps_versions = {
'zlib' : '1.2.8', 'zlib' : '1.2.11',
'lzma' : '5.2.3', 'lzma' : '5.2.3',
'uuid' : '1.43.4', 'uuid' : '1.43.4',
'xapian-core' : '1.4.5', 'xapian-core' : '1.4.5',