aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/base.py
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 /mesonbuild/dependencies/base.py
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
Diffstat (limited to 'mesonbuild/dependencies/base.py')
-rw-r--r--mesonbuild/dependencies/base.py6
1 files changed, 4 insertions, 2 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)