Can build Python extension on OSX.
This commit is contained in:
parent
98d3fb5372
commit
a04c33e125
|
@ -46,6 +46,7 @@ known_shlib_kwargs = known_basic_kwargs.copy()
|
||||||
known_shlib_kwargs.update({'version' : True,
|
known_shlib_kwargs.update({'version' : True,
|
||||||
'soversion' : True,
|
'soversion' : True,
|
||||||
'name_prefix' : True,
|
'name_prefix' : True,
|
||||||
|
'name_suffix' : True,
|
||||||
})
|
})
|
||||||
|
|
||||||
backslash_explanation = \
|
backslash_explanation = \
|
||||||
|
@ -415,9 +416,20 @@ class BuildTarget():
|
||||||
self.resources = resources
|
self.resources = resources
|
||||||
if 'name_prefix' in kwargs:
|
if 'name_prefix' in kwargs:
|
||||||
name_prefix = kwargs['name_prefix']
|
name_prefix = kwargs['name_prefix']
|
||||||
if not isinstance(name_prefix, str):
|
if isinstance(name_prefix, list):
|
||||||
|
if len(name_prefix) != 0:
|
||||||
|
raise InvalidArguments('Array must be empty to signify null.')
|
||||||
|
elif not isinstance(name_prefix, str):
|
||||||
raise InvalidArguments('Name prefix must be a string.')
|
raise InvalidArguments('Name prefix must be a string.')
|
||||||
self.prefix = name_prefix
|
self.prefix = name_prefix
|
||||||
|
if 'name_suffix' in kwargs:
|
||||||
|
name_suffix = kwargs['name_suffix']
|
||||||
|
if isinstance(name_suffix, list):
|
||||||
|
if len(name_suffix) != 0:
|
||||||
|
raise InvalidArguments('Array must be empty to signify null.')
|
||||||
|
elif not isinstance(name_suffix, str):
|
||||||
|
raise InvalidArguments('Name suffix must be a string.')
|
||||||
|
self.suffix = name_suffix
|
||||||
|
|
||||||
def get_subdir(self):
|
def get_subdir(self):
|
||||||
return self.subdir
|
return self.subdir
|
||||||
|
@ -684,14 +696,17 @@ class SharedLibrary(BuildTarget):
|
||||||
super().__init__(name, subdir, subproject, is_cross, sources, objects, environment, kwargs);
|
super().__init__(name, subdir, subproject, is_cross, sources, objects, environment, kwargs);
|
||||||
if len(self.sources) > 0 and self.sources[0].endswith('.cs'):
|
if len(self.sources) > 0 and self.sources[0].endswith('.cs'):
|
||||||
prefix = 'lib'
|
prefix = 'lib'
|
||||||
self.suffix = 'dll'
|
suffix = 'dll'
|
||||||
else:
|
else:
|
||||||
prefix = environment.get_shared_lib_prefix()
|
prefix = environment.get_shared_lib_prefix()
|
||||||
self.suffix = environment.get_shared_lib_suffix()
|
suffix = environment.get_shared_lib_suffix()
|
||||||
if not hasattr(self, 'prefix'):
|
if not hasattr(self, 'prefix'):
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
if len(self.sources) > 0 and self.sources[0].endswith('.rs'):
|
if not hasattr(self, 'suffix'):
|
||||||
self.suffix = 'rlib'
|
if len(self.sources) > 0 and self.sources[0].endswith('.rs'):
|
||||||
|
self.suffix = 'rlib'
|
||||||
|
else:
|
||||||
|
self.suffix = suffix
|
||||||
self.importsuffix = environment.get_import_lib_suffix()
|
self.importsuffix = environment.get_import_lib_suffix()
|
||||||
self.filename = self.prefix + self.name + '.' + self.suffix
|
self.filename = self.prefix + self.name + '.' + self.suffix
|
||||||
|
|
||||||
|
|
|
@ -1077,6 +1077,7 @@ class ThreadDependency(Dependency):
|
||||||
class Python3Dependency(Dependency):
|
class Python3Dependency(Dependency):
|
||||||
def __init__(self, environment, kwargs):
|
def __init__(self, environment, kwargs):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.name = 'python3'
|
||||||
self.is_found = False
|
self.is_found = False
|
||||||
try:
|
try:
|
||||||
pkgdep = PkgConfigDependency('python3', environment, kwargs)
|
pkgdep = PkgConfigDependency('python3', environment, kwargs)
|
||||||
|
@ -1100,6 +1101,14 @@ class Python3Dependency(Dependency):
|
||||||
self.libs = ['-L{}/libs'.format(basedir),
|
self.libs = ['-L{}/libs'.format(basedir),
|
||||||
'-lpython{}'.format(vernum)]
|
'-lpython{}'.format(vernum)]
|
||||||
self.is_found = True
|
self.is_found = True
|
||||||
|
elif mesonlib.is_osx():
|
||||||
|
# In OSX the Python 3 framework does not have a version
|
||||||
|
# number in its name.
|
||||||
|
fw = ExtraFrameworkDependency('python', False)
|
||||||
|
if fw.found():
|
||||||
|
self.cargs = fw.get_compile_args()
|
||||||
|
self.libs = fw.get_link_args()
|
||||||
|
self.is_found = True
|
||||||
if self.is_found:
|
if self.is_found:
|
||||||
mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.green('YES'))
|
mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.green('YES'))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
|
if host_machine.system() == 'darwin'
|
||||||
|
# Default suffix is 'dylib' but Python does not use for extensions.
|
||||||
|
suffix = 'so'
|
||||||
|
else
|
||||||
|
suffix = []
|
||||||
|
endif
|
||||||
|
|
||||||
pylib = shared_library('tachyon',
|
pylib = shared_library('tachyon',
|
||||||
'tachyon_module.c',
|
'tachyon_module.c',
|
||||||
dependencies : py3_dep,
|
dependencies : py3_dep,
|
||||||
name_prefix : '')
|
name_prefix : '',
|
||||||
|
name_suffix : suffix)
|
||||||
|
|
||||||
pypathdir = meson.current_build_dir()
|
pypathdir = meson.current_build_dir()
|
||||||
|
|
Loading…
Reference in New Issue