Commit 2e9bac35 authored by Nirbheek Chauhan's avatar Nirbheek Chauhan 🐜
Browse files

meson.recipe: Update to 0.48.1

parent 9ce0230b
......@@ -5,21 +5,15 @@ from pathlib import PurePath
class Recipe(recipe.Recipe):
name = 'meson'
version = '0.47.2'
version = '0.48.1'
licenses = [License.Apachev2]
btype = BuildType.CUSTOM
stype = SourceType.TARBALL
url = 'https://github.com/mesonbuild/meson/releases/download/%(version)s/meson-%(version)s.tar.gz'
tarball_checksum = '92d8afd921751261e36151643464efd3394162f69efbe8cd53e0a66b1cf395eb'
tarball_checksum = '425d12edbb81498314926afa93a3eb2fca4ca6929cbe0f8abeb6ab45d1d9fa8f'
patches = [
# https://github.com/mesonbuild/meson/pull/3985
'meson/0001-Don-t-require-an-import-library-for-shared-modules.patch',
# https://github.com/mesonbuild/meson/pull/3939
'meson/0002-Fix-linking-of-shared-static-libs-with-static-libs.patch',
# https://github.com/mesonbuild/meson/pull/4024
'meson/0003-gnome-Filter-CFLAGS-and-LDFLAGS-passed-to-g-ir-scann.patch',
# https://github.com/mesonbuild/meson/pull/4095
'meson/0004-Improve-support-for-macOS-dylib-versioning.patch',
]
deps = ['ninja']
......
From 98b396543eb4f8ce214b9e2767604d266a9b7ecb Mon Sep 17 00:00:00 2001
From: Nirbheek Chauhan <nirbheek@centricular.com>
Date: Tue, 7 Aug 2018 21:03:51 +0530
Subject: [PATCH 1/4] Don't require an import library for shared modules
Shared modules may be resource-only DLLs, or might automatically
self-initialize using C constructors or WinMain at DLL load time.
When an import library is not found for a shared module, just print
a message about it instead of erroring out.
---
mesonbuild/backend/backends.py | 3 ++-
mesonbuild/backend/ninjabackend.py | 3 ++-
mesonbuild/minstall.py | 7 +++++++
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 87da90d2..2e4fb728 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -55,7 +55,7 @@ class InstallData:
self.mesonintrospect = mesonintrospect
class TargetInstallData:
- def __init__(self, fname, outdir, aliases, strip, install_name_mappings, install_rpath, install_mode):
+ def __init__(self, fname, outdir, aliases, strip, install_name_mappings, install_rpath, install_mode, optional=False):
self.fname = fname
self.outdir = outdir
self.aliases = aliases
@@ -63,6 +63,7 @@ class TargetInstallData:
self.install_name_mappings = install_name_mappings
self.install_rpath = install_rpath
self.install_mode = install_mode
+ self.optional = optional
class ExecutableSerialisation:
def __init__(self, name, fname, cmd_args, env, is_cross, exe_wrapper,
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index b9473ec9..89784458 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -790,7 +790,8 @@ int dummy;
implib_install_dir = self.environment.get_import_lib_dir()
# Install the import library.
i = TargetInstallData(self.get_target_filename_for_linking(t),
- implib_install_dir, {}, False, {}, '', install_mode)
+ implib_install_dir, {}, False, {}, '', install_mode,
+ optional=isinstance(t, build.SharedModule))
d.targets.append(i)
# Install secondary outputs. Only used for Vala right now.
if num_outdirs > 1:
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index bef814bb..1d721795 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -432,6 +432,13 @@ class Installer:
def install_targets(self, d):
for t in d.targets:
+ if not os.path.exists(t.fname):
+ # For example, import libraries of shared modules are optional
+ if t.optional:
+ print('File {!r} not found, skipping'.format(t.fname))
+ continue
+ else:
+ raise RuntimeError('File {!r} could not be found'.format(t.fname))
fname = check_for_stampfile(t.fname)
outdir = get_destdir_path(d, t.outdir)
outname = os.path.join(outdir, os.path.basename(fname))
--
2.17.1
From 880ab2f77ddd8ea26f95513ec5908bd8b66851fc Mon Sep 17 00:00:00 2001
From: Nirbheek Chauhan <nirbheek@centricular.com>
Date: Tue, 14 Aug 2018 20:58:35 +0530
Subject: [PATCH 3/4] gnome: Filter CFLAGS and LDFLAGS passed to g-ir-scanner
g-ir-scanner is very picky about the flags that it can accept, so the
build fails on macOS if you have Framework dependencies, which add -F
and -framework arguments.
Also filter CFLAGS because that's also similarly restrictive.
https://github.com/mesonbuild/meson/pull/4024
---
mesonbuild/modules/gnome.py | 68 ++++++++++++++++++++++++++-----------
1 file changed, 49 insertions(+), 19 deletions(-)
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index cb69641e..dd8b555d 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -314,10 +314,13 @@ class GnomeModule(ExtensionModule):
return link_command
def _get_dependencies_flags(self, deps, state, depends, include_rpath=False,
- use_gir_args=False):
+ use_gir_args=False, separate_nodedup=False):
cflags = OrderedSet()
internal_ldflags = OrderedSet()
external_ldflags = OrderedSet()
+ # External linker flags that can't be de-duped reliably because they
+ # require two args in order, such as -framework AVFoundation
+ external_ldflags_nodedup = []
gi_includes = OrderedSet()
deps = mesonlib.listify(deps, unholder=True)
@@ -328,18 +331,21 @@ class GnomeModule(ExtensionModule):
if hasattr(lib, 'held_object'):
lib = lib.held_object
internal_ldflags.update(self._get_link_args(state, lib, depends, include_rpath))
- libdepflags = self._get_dependencies_flags(lib.get_external_deps(), state, depends, include_rpath,
- use_gir_args)
+ libdepflags = self._get_dependencies_flags(lib.get_external_deps(), state,
+ depends, include_rpath,
+ use_gir_args, True)
cflags.update(libdepflags[0])
internal_ldflags.update(libdepflags[1])
external_ldflags.update(libdepflags[2])
- gi_includes.update(libdepflags[3])
- extdepflags = self._get_dependencies_flags(dep.ext_deps, state, depends, include_rpath,
- use_gir_args)
+ external_ldflags_nodedup += libdepflags[3]
+ gi_includes.update(libdepflags[4])
+ extdepflags = self._get_dependencies_flags(dep.ext_deps, state, depends,
+ include_rpath, use_gir_args, True)
cflags.update(extdepflags[0])
internal_ldflags.update(extdepflags[1])
external_ldflags.update(extdepflags[2])
- gi_includes.update(extdepflags[3])
+ external_ldflags_nodedup += extdepflags[3]
+ gi_includes.update(extdepflags[4])
for source in dep.sources:
if hasattr(source, 'held_object'):
source = source.held_object
@@ -349,7 +355,8 @@ class GnomeModule(ExtensionModule):
# This should be any dependency other than an internal one.
elif isinstance(dep, Dependency):
cflags.update(dep.get_compile_args())
- for lib in dep.get_link_args(raw=True):
+ ldflags = iter(dep.get_link_args(raw=True))
+ for lib in ldflags:
if (os.path.isabs(lib) and
# For PkgConfigDependency only:
getattr(dep, 'is_libtool', False)):
@@ -362,10 +369,15 @@ class GnomeModule(ExtensionModule):
libname = libname[3:]
libname = libname.split(".so")[0]
lib = "-l%s" % libname
- # Hack to avoid passing some compiler options in
+ # FIXME: Hack to avoid passing some compiler options in
if lib.startswith("-W"):
continue
- external_ldflags.update([lib])
+ # If it's a framework arg, slurp the framework name too
+ # to preserve the order of arguments
+ if lib == '-framework':
+ external_ldflags_nodedup += [lib, next(ldflags)]
+ else:
+ external_ldflags.update([lib])
if isinstance(dep, PkgConfigDependency):
girdir = dep.get_pkgconfig_variable("girdir", {'default': ''})
@@ -380,16 +392,34 @@ class GnomeModule(ExtensionModule):
if gir_has_extra_lib_arg(self.interpreter) and use_gir_args:
def fix_ldflags(ldflags):
- fixed_ldflags = OrderedSet()
+ fixed_ldflags = OrderedSet()
for ldflag in ldflags:
if ldflag.startswith("-l"):
- fixed_ldflags.add(ldflag.replace('-l', '--extra-library=', 1))
- else:
- fixed_ldflags.add(ldflag)
+ ldflag = ldflag.replace('-l', '--extra-library=', 1)
+ fixed_ldflags.add(ldflag)
return fixed_ldflags
internal_ldflags = fix_ldflags(internal_ldflags)
external_ldflags = fix_ldflags(external_ldflags)
- return cflags, internal_ldflags, external_ldflags, gi_includes
+
+ if not separate_nodedup:
+ external_ldflags.update(external_ldflags_nodedup)
+ return cflags, internal_ldflags, external_ldflags, gi_includes
+ else:
+ return cflags, internal_ldflags, external_ldflags, external_ldflags_nodedup, gi_includes
+
+ @staticmethod
+ def _get_scanner_cflags(cflags):
+ 'g-ir-scanner only accepts -I/-D/-U; must ignore all other flags'
+ for f in cflags:
+ if f.startswith(('-D', '-U', '-I')):
+ yield f
+
+ @staticmethod
+ def _get_scanner_ldflags(ldflags):
+ 'g-ir-scanner only accepts -L/-l; must ignore -F and other linker flags'
+ for f in ldflags:
+ if f.startswith(('-L', '-l', '--extra-library')):
+ yield f
@FeatureNewKwargs('build target', '0.40.0', ['build_by_default'])
@permittedKwargs({'sources', 'nsversion', 'namespace', 'symbol_prefix', 'identifier_prefix',
@@ -574,12 +604,12 @@ class GnomeModule(ExtensionModule):
# are not used here.
dep_cflags, dep_internal_ldflags, dep_external_ldflags, gi_includes = \
self._get_dependencies_flags(deps, state, depends, use_gir_args=True)
- cflags += list(dep_cflags)
- internal_ldflags += list(dep_internal_ldflags)
- external_ldflags += list(dep_external_ldflags)
+ cflags += list(self._get_scanner_cflags(dep_cflags))
+ cflags += list(self._get_scanner_cflags(state.environment.coredata.get_external_args(lang)))
+ internal_ldflags += list(self._get_scanner_ldflags(dep_internal_ldflags))
+ external_ldflags += list(self._get_scanner_ldflags(dep_external_ldflags))
scan_command += ['--cflags-begin']
scan_command += cflags
- scan_command += state.environment.coredata.get_external_args(lang)
scan_command += ['--cflags-end']
# need to put our output directory first as we need to use the
# generated libraries instead of any possibly installed system/prefix
--
2.17.1
From 85acffb1904dfd1df94eaa50832f39539b47d742 Mon Sep 17 00:00:00 2001
From: Nirbheek Chauhan <nirbheek@centricular.com>
Date: Tue, 28 Aug 2018 15:17:00 +0530
Subject: [PATCH 4/4] Improve support for macOS dylib versioning
We now use the soversion to set compatibility_version and
current_version by default. This is the only sane thing we can do by
default because of the restrictions on the values that can be used for
compatibility and current version.
Users can override this value with the `darwin_versions:` kwarg, which
can be a single value or a two-element list of values. The first one
is the compatibility version and the second is the current version.
Fixes https://github.com/mesonbuild/meson/issues/3555
Fixes https://github.com/mesonbuild/meson/issues/1451
---
mesonbuild/backend/ninjabackend.py | 3 +-
mesonbuild/build.py | 47 +++++++++++++++++++++++++++++-
mesonbuild/compilers/compilers.py | 24 +++++++--------
mesonbuild/compilers/d.py | 4 +--
4 files changed, 62 insertions(+), 16 deletions(-)
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index bdaf8ed6..d7fa2d70 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2451,7 +2451,8 @@ rule FORTRAN_DEP_HACK%s
commands += linker.get_pic_args()
# Add -Wl,-soname arguments on Linux, -install_name on OS X
commands += linker.get_soname_args(target.prefix, target.name, target.suffix,
- target.soversion, isinstance(target, build.SharedModule))
+ target.soversion, target.darwin_versions,
+ isinstance(target, build.SharedModule))
# This is only visited when building for Windows using either GCC or Visual Studio
if target.vs_module_defs and hasattr(linker, 'gen_vs_module_defs_args'):
commands += linker.gen_vs_module_defs_args(target.vs_module_defs.rel_to_builddir(self.build_to_src))
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index c0cdb917..9b80c30a 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -82,7 +82,7 @@ known_build_target_kwargs = (
cs_kwargs)
known_exe_kwargs = known_build_target_kwargs | {'implib', 'export_dynamic'}
-known_shlib_kwargs = known_build_target_kwargs | {'version', 'soversion', 'vs_module_defs'}
+known_shlib_kwargs = known_build_target_kwargs | {'version', 'soversion', 'vs_module_defs', 'darwin_versions'}
known_shmod_kwargs = known_build_target_kwargs
known_stlib_kwargs = known_build_target_kwargs | {'pic'}
known_jar_kwargs = known_exe_kwargs | {'main_class'}
@@ -1412,6 +1412,8 @@ class SharedLibrary(BuildTarget):
def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs):
self.soversion = None
self.ltversion = None
+ # Max length 2, first element is compatibility_version, second is current_version
+ self.darwin_versions = []
self.vs_module_defs = None
# The import library this target will generate
self.import_filename = None
@@ -1518,6 +1520,44 @@ class SharedLibrary(BuildTarget):
self.filename = self.filename_tpl.format(self)
self.outputs = [self.filename]
+ @staticmethod
+ def _validate_darwin_versions(darwin_versions):
+ try:
+ if isinstance(darwin_versions, int):
+ darwin_versions = str(darwin_versions)
+ if isinstance(darwin_versions, str):
+ darwin_versions = 2 * [darwin_versions]
+ if not isinstance(darwin_versions, list):
+ raise InvalidArguments('Shared library darwin_versions: must be a string, integer,'
+ 'or a list, not {!r}'.format(darwin_versions))
+ if len(darwin_versions) > 2:
+ raise InvalidArguments('Shared library darwin_versions: list must contain 2 or fewer elements')
+ if len(darwin_versions) == 1:
+ darwin_versions = 2 * darwin_versions
+ for i, v in enumerate(darwin_versions[:]):
+ if isinstance(v, int):
+ v = str(v)
+ if not isinstance(v, str):
+ raise InvalidArguments('Shared library darwin_versions: list elements '
+ 'must be strings or integers, not {!r}'.format(v))
+ if not re.fullmatch(r'[0-9]+(\.[0-9]+){0,2}', v):
+ raise InvalidArguments('Shared library darwin_versions: must be X.Y.Z where '
+ 'X, Y, Z are numbers, and Y and Z are optional')
+ parts = v.split('.')
+ if len(parts) in (1, 2, 3) and int(parts[0]) > 65535:
+ raise InvalidArguments('Shared library darwin_versions: must be X.Y.Z '
+ 'where X is [0, 65535] and Y, Z are optional')
+ if len(parts) in (2, 3) and int(parts[1]) > 255:
+ raise InvalidArguments('Shared library darwin_versions: must be X.Y.Z '
+ 'where Y is [0, 255] and Y, Z are optional')
+ if len(parts) == 3 and int(parts[2]) > 255:
+ raise InvalidArguments('Shared library darwin_versions: must be X.Y.Z '
+ 'where Z is [0, 255] and Y, Z are optional')
+ darwin_versions[i] = v
+ except ValueError:
+ raise InvalidArguments('Shared library darwin_versions: value is invalid')
+ return darwin_versions
+
def process_kwargs(self, kwargs, environment):
super().process_kwargs(kwargs, environment)
@@ -1566,6 +1604,13 @@ class SharedLibrary(BuildTarget):
# We replicate what Autotools does here and take the first
# number of the version by default.
self.soversion = self.ltversion.split('.')[0]
+ # macOS and iOS dylib compatibility_version and current_version
+ if 'darwin_versions' in kwargs:
+ self.darwin_versions = self._validate_darwin_versions(kwargs['darwin_versions'])
+ elif self.soversion:
+ # If unspecified, pick the soversion
+ self.darwin_versions = 2 * [self.soversion]
+
# Visual Studio module-definitions file
if 'vs_module_defs' in kwargs:
path = kwargs['vs_module_defs']
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index a047f7dd..d05d9d59 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -1056,14 +1056,14 @@ class Compiler:
return None
def build_osx_rpath_args(self, build_dir, rpath_paths, build_rpath):
+ # Ensure that there is enough space for large RPATHs and install_name
+ args = ['-Wl,-headerpad_max_install_names']
if not rpath_paths and not build_rpath:
- return []
+ return args
# On OSX, rpaths must be absolute.
abs_rpaths = [os.path.join(build_dir, p) for p in rpath_paths]
if build_rpath != '':
abs_rpaths.append(build_rpath)
- # Ensure that there is enough space for large RPATHs
- args = ['-Wl,-headerpad_max_install_names']
args += ['-Wl,-rpath,' + rp for rp in abs_rpaths]
return args
@@ -1100,12 +1100,9 @@ def get_macos_dylib_install_name(prefix, shlib_name, suffix, soversion):
install_name += '.dylib'
return '@rpath/' + install_name
-def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, soversion, is_shared_module):
- if soversion is None:
- sostr = ''
- else:
- sostr = '.' + soversion
+def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, soversion, darwin_versions, is_shared_module):
if gcc_type == GCC_STANDARD:
+ sostr = '' if soversion is None else '.' + soversion
return ['-Wl,-soname,%s%s.%s%s' % (prefix, shlib_name, suffix, sostr)]
elif gcc_type in (GCC_MINGW, GCC_CYGWIN):
# For PE/COFF the soname argument has no effect with GNU LD
@@ -1114,7 +1111,10 @@ def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, soversion, is_shar
if is_shared_module:
return []
name = get_macos_dylib_install_name(prefix, shlib_name, suffix, soversion)
- return ['-install_name', name]
+ args = ['-install_name', name]
+ if darwin_versions:
+ args += ['-compatibility_version', darwin_versions[0], '-current_version', darwin_versions[1]]
+ return args
else:
raise RuntimeError('Not implemented yet.')
@@ -1254,8 +1254,8 @@ class GnuCompiler:
def split_shlib_to_parts(self, fname):
return os.path.dirname(fname), fname
- def get_soname_args(self, prefix, shlib_name, suffix, soversion, is_shared_module):
- return get_gcc_soname_args(self.gcc_type, prefix, shlib_name, suffix, soversion, is_shared_module)
+ def get_soname_args(self, *args):
+ return get_gcc_soname_args(self.gcc_type, *args)
def get_std_shared_lib_link_args(self):
return ['-shared']
@@ -1373,7 +1373,7 @@ class ClangCompiler:
# so it might change semantics at any time.
return ['-include-pch', os.path.join(pch_dir, self.get_pch_name(header))]
- def get_soname_args(self, prefix, shlib_name, suffix, soversion, is_shared_module):
+ def get_soname_args(self, *args):
if self.clang_type == CLANG_STANDARD:
gcc_type = GCC_STANDARD
elif self.clang_type == CLANG_OSX:
@@ -1382,7 +1382,7 @@ class ClangCompiler:
gcc_type = GCC_MINGW
else:
raise MesonException('Unreachable code when converting clang type to gcc type.')
- return get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, soversion, is_shared_module)
+ return get_gcc_soname_args(gcc_type, *args)
def has_multi_arguments(self, args, env):
myargs = ['-Werror=unknown-warning-option', '-Werror=unused-command-line-argument']
@@ -1539,7 +1539,7 @@ class IntelCompiler:
def split_shlib_to_parts(self, fname):
return os.path.dirname(fname), fname
- def get_soname_args(self, prefix, shlib_name, suffix, soversion, is_shared_module):
+ def get_soname_args(self, *args):
if self.icc_type == ICC_STANDARD:
gcc_type = GCC_STANDARD
elif self.icc_type == ICC_OSX:
@@ -1548,7 +1548,7 @@ class IntelCompiler:
gcc_type = GCC_MINGW
else:
raise MesonException('Unreachable code when converting icc type to gcc type.')
- return get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, soversion, is_shared_module)
+ return get_gcc_soname_args(gcc_type, *args)
# TODO: centralise this policy more globally, instead
# of fragmenting it into GnuCompiler and ClangCompiler
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index f0f3d54b..59099707 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -89,9 +89,9 @@ class DCompiler(Compiler):
def get_std_shared_lib_link_args(self):
return ['-shared']
- def get_soname_args(self, prefix, shlib_name, suffix, soversion, is_shared_module):
+ def get_soname_args(self, *args):
# FIXME: Make this work for Windows, MacOS and cross-compiling
- return get_gcc_soname_args(GCC_STANDARD, prefix, shlib_name, suffix, soversion, is_shared_module)
+ return get_gcc_soname_args(GCC_STANDARD, *args)
def get_feature_args(self, kwargs, build_to_src):
res = []
--
2.17.1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment