aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2018-06-01 11:55:18 +0100
committerJon Turney <jon.turney@dronecode.org.uk>2018-08-01 14:25:59 +0100
commit01118ce2a45ec3111b29f2de70bc127b3400ebb2 (patch)
treed7fe56b12c7fad4f8434be064125fa3d0fa4512c
parent82bdf07a9d1ca6c62d4645a8c996975a5cef2989 (diff)
downloadmeson-01118ce2a45ec3111b29f2de70bc127b3400ebb2.zip
meson-01118ce2a45ec3111b29f2de70bc127b3400ebb2.tar.gz
meson-01118ce2a45ec3111b29f2de70bc127b3400ebb2.tar.bz2
Add a finish_init callback to ConfigToolDependency()
Give ConfigToolDependency() a finish_init callback, so that tool-specific initialization can be called from the constructor, rather than after construction in the factory class. v2: finalize -> finish_init for clarity
-rw-r--r--mesonbuild/dependencies/base.py6
-rw-r--r--mesonbuild/dependencies/misc.py38
-rw-r--r--mesonbuild/dependencies/ui.py10
3 files changed, 32 insertions, 22 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index c34146f..6af11f0 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -297,6 +297,8 @@ class ConfigToolDependency(ExternalDependency):
self.config = None
return
self.version = version
+ if getattr(self, 'finish_init', None):
+ self.finish_init(self)
def _sanitize_version(self, version):
"""Remove any non-numeric, non-point version suffixes."""
@@ -308,7 +310,7 @@ class ConfigToolDependency(ExternalDependency):
return version
@classmethod
- def factory(cls, name, environment, language, kwargs, tools, tool_name):
+ def factory(cls, name, environment, language, kwargs, tools, tool_name, finish_init=None):
"""Constructor for use in dependencies that can be found multiple ways.
In addition to the standard constructor values, this constructor sets
@@ -323,7 +325,7 @@ class ConfigToolDependency(ExternalDependency):
def reduce(self):
return (cls._unpickle, (), self.__dict__)
sub = type('{}Dependency'.format(name.capitalize()), (cls, ),
- {'tools': tools, 'tool_name': tool_name, '__reduce__': reduce})
+ {'tools': tools, 'tool_name': tool_name, '__reduce__': reduce, 'finish_init': staticmethod(finish_init)})
return sub(name, environment, language, kwargs)
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index 6076433..bf60186 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -444,16 +444,20 @@ class PcapDependency(ExternalDependency):
if DependencyMethods.CONFIG_TOOL in methods:
candidates.append(functools.partial(ConfigToolDependency.factory,
- 'pcap', environment, None, kwargs, ['pcap-config'], 'pcap-config'))
-# if ctdep.found():
-# ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args')
-# ctdep.link_args = ctdep.get_config_value(['--libs'], 'link_args')
-# ctdep.version = cls.get_pcap_lib_version(ctdep)
-# return ctdep
+ 'pcap', environment, None,
+ kwargs, ['pcap-config'],
+ 'pcap-config',
+ PcapDependency.tool_finish_init))
return candidates
@staticmethod
+ def tool_finish_init(ctdep):
+ ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args')
+ ctdep.link_args = ctdep.get_config_value(['--libs'], 'link_args')
+ ctdep.version = PcapDependency.get_pcap_lib_version(ctdep)
+
+ @staticmethod
def get_methods():
return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL]
@@ -479,10 +483,7 @@ class CupsDependency(ExternalDependency):
candidates.append(functools.partial(ConfigToolDependency.factory,
'cups', environment, None,
kwargs, ['cups-config'],
- 'cups-config'))
-# if ctdep.found():
-# ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args')
-# ctdep.link_args = ctdep.get_config_value(['--ldflags', '--libs'], 'link_args')
+ 'cups-config', CupsDependency.tool_finish_init))
if DependencyMethods.EXTRAFRAMEWORK in methods:
if mesonlib.is_osx():
@@ -493,6 +494,11 @@ class CupsDependency(ExternalDependency):
return candidates
@staticmethod
+ def tool_finish_init(ctdep):
+ ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args')
+ ctdep.link_args = ctdep.get_config_value(['--ldflags', '--libs'], 'link_args')
+
+ @staticmethod
def get_methods():
if mesonlib.is_osx():
return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK]
@@ -514,15 +520,15 @@ class LibWmfDependency(ExternalDependency):
if DependencyMethods.CONFIG_TOOL in methods:
candidates.append(functools.partial(ConfigToolDependency.factory,
- 'libwmf', environment, None, kwargs, ['libwmf-config'], 'libwmf-config'))
-
-# if ctdep.found():
-# ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args')
-# ctdep.link_args = ctdep.get_config_value(['--libs'], 'link_args')
-# return ctdep
+ 'libwmf', environment, None, kwargs, ['libwmf-config'], 'libwmf-config', LibWmfDependency.tool_finish_init))
return candidates
@staticmethod
+ def tool_finish_init(ctdep):
+ ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args')
+ ctdep.link_args = ctdep.get_config_value(['--libs'], 'link_args')
+
+ @staticmethod
def get_methods():
return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL]
diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py
index e25d135..ca7db3f 100644
--- a/mesonbuild/dependencies/ui.py
+++ b/mesonbuild/dependencies/ui.py
@@ -464,10 +464,7 @@ class SDL2Dependency(ExternalDependency):
candidates.append(functools.partial(ConfigToolDependency.factory,
'sdl2', environment, None,
kwargs, ['sdl2-config'],
- 'sdl2-config'))
-# if ctdep.found():
-# ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args')
-# ctdep.link_args = ctdep.get_config_value(['--libs'], 'link_args')
+ 'sdl2-config', SDL2Dependency.tool_finish_init))
if DependencyMethods.EXTRAFRAMEWORK in methods:
if mesonlib.is_osx():
@@ -478,6 +475,11 @@ class SDL2Dependency(ExternalDependency):
return candidates
@staticmethod
+ def tool_finish_init(ctdep):
+ ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args')
+ ctdep.link_args = ctdep.get_config_value(['--libs'], 'link_args')
+
+ @staticmethod
def get_methods():
if mesonlib.is_osx():
return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK]