aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-02-26 21:21:53 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2016-02-26 21:21:53 +0200
commitea60a22cd5a2613652942e48e143d7a3da68bbc0 (patch)
treeae351eb81558c49dd7fc76c5ca380e6b6fc99774 /mesonbuild
parent003696fc27e1f560a8448cc5998443696a162927 (diff)
parentefceac497fa2702124398b2712761015d9a1c78a (diff)
downloadmeson-ea60a22cd5a2613652942e48e143d7a3da68bbc0.zip
meson-ea60a22cd5a2613652942e48e143d7a3da68bbc0.tar.gz
meson-ea60a22cd5a2613652942e48e143d7a3da68bbc0.tar.bz2
Merge Python 3 module support.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/build.py42
-rw-r--r--mesonbuild/dependencies.py48
2 files changed, 82 insertions, 8 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index f9e628d..e2dd7ca 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -44,7 +44,10 @@ known_basic_kwargs = {'install' : True,
known_shlib_kwargs = known_basic_kwargs.copy()
known_shlib_kwargs.update({'version' : True,
- 'soversion' : True})
+ 'soversion' : True,
+ 'name_prefix' : True,
+ 'name_suffix' : True,
+ })
backslash_explanation = \
'''Compiler arguments have a backslash "\\" character. This is unfortunately not
@@ -411,6 +414,23 @@ class BuildTarget():
if not os.path.isfile(trial):
raise InvalidArguments('Tried to add non-existing resource %s.' % r)
self.resources = resources
+ if 'name_prefix' in kwargs:
+ name_prefix = kwargs['name_prefix']
+ 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.')
+ 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.')
+ else:
+ if not isinstance(name_suffix, str):
+ raise InvalidArguments('Name suffix must be a string.')
+ self.suffix = name_suffix
def get_subdir(self):
return self.subdir
@@ -654,7 +674,8 @@ class StaticLibrary(BuildTarget):
super().__init__(name, subdir, subproject, is_cross, sources, objects, environment, kwargs)
if len(self.sources) > 0 and self.sources[0].endswith('.cs'):
raise InvalidArguments('Static libraries not supported for C#.')
- self.prefix = environment.get_static_lib_prefix()
+ if not hasattr(self, 'prefix'):
+ self.prefix = environment.get_static_lib_prefix()
self.suffix = environment.get_static_lib_suffix()
if len(self.sources) > 0 and self.sources[0].endswith('.rs'):
self.suffix = 'rlib'
@@ -675,13 +696,18 @@ class SharedLibrary(BuildTarget):
self.soversion = None
super().__init__(name, subdir, subproject, is_cross, sources, objects, environment, kwargs);
if len(self.sources) > 0 and self.sources[0].endswith('.cs'):
- self.suffix = 'dll'
- self.prefix = 'lib'
+ prefix = 'lib'
+ suffix = 'dll'
else:
- self.prefix = environment.get_shared_lib_prefix()
- self.suffix = environment.get_shared_lib_suffix()
- if len(self.sources) > 0 and self.sources[0].endswith('.rs'):
- self.suffix = 'rlib'
+ prefix = environment.get_shared_lib_prefix()
+ suffix = environment.get_shared_lib_suffix()
+ if not hasattr(self, 'prefix'):
+ self.prefix = prefix
+ if not hasattr(self, 'suffix'):
+ 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.filename = self.prefix + self.name + '.' + self.suffix
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py
index b89bc11..ca5fa89 100644
--- a/mesonbuild/dependencies.py
+++ b/mesonbuild/dependencies.py
@@ -21,6 +21,7 @@
import re
import os, stat, glob, subprocess, shutil
+import sysconfig
from . coredata import MesonException
from . import mlog
from . import mesonlib
@@ -1073,6 +1074,52 @@ class ThreadDependency(Dependency):
def need_threads(self):
return True
+class Python3Dependency(Dependency):
+ def __init__(self, environment, kwargs):
+ super().__init__()
+ self.name = 'python3'
+ self.is_found = False
+ try:
+ pkgdep = PkgConfigDependency('python3', environment, kwargs)
+ if pkgdep.found():
+ self.cargs = pkgdep.cargs
+ self.libs = pkgdep.libs
+ self.is_found = True
+ return
+ except Exception:
+ pass
+ if not self.is_found:
+ if mesonlib.is_windows():
+ inc = sysconfig.get_path('include')
+ platinc = sysconfig.get_path('platinclude')
+ self.cargs = ['-I' + inc]
+ if inc != platinc:
+ self.cargs.append('-I' + platinc)
+ # Nothing exposes this directly that I coulf find
+ basedir = sysconfig.get_config_var('base')
+ vernum = sysconfig.get_config_var('py_version_nodot')
+ self.libs = ['-L{}/libs'.format(basedir),
+ '-lpython{}'.format(vernum)]
+ 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:
+ mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.green('YES'))
+ else:
+ mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.red('NO'))
+
+ def get_compile_args(self):
+ return self.cargs
+
+ def get_link_args(self):
+ return self.libs
+
def get_dep_identifier(name, kwargs):
elements = [name]
modlist = kwargs.get('modules', [])
@@ -1123,4 +1170,5 @@ packages = {'boost': BoostDependency,
'sdl2' : SDL2Dependency,
'gl' : GLDependency,
'threads' : ThreadDependency,
+ 'python3' : Python3Dependency,
}