diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-01-09 11:33:06 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-01-29 09:11:24 -0800 |
commit | fbad73c939a3c7f7f27994a81d68f4a9082c06a0 (patch) | |
tree | 3e568c07a44961b5cbfa70e49859d841ba882533 /mesonbuild/dependencies/misc.py | |
parent | 5d630c663c125b1e62cb88bd01054f1253c92bbe (diff) | |
download | meson-fbad73c939a3c7f7f27994a81d68f4a9082c06a0.zip meson-fbad73c939a3c7f7f27994a81d68f4a9082c06a0.tar.gz meson-fbad73c939a3c7f7f27994a81d68f4a9082c06a0.tar.bz2 |
dependencies: Use a DependencyFactory for threads
This lets us make a number of uses of threads safer, because we can use
the threads_factory instead of the ThreadDependency
Diffstat (limited to 'mesonbuild/dependencies/misc.py')
-rw-r--r-- | mesonbuild/dependencies/misc.py | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 6a05ef1..7eba808 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -105,33 +105,17 @@ class OpenMPDependency(ExternalDependency): class ThreadDependency(ExternalDependency): - def __init__(self, environment, kwargs): - super().__init__('threads', environment, kwargs) - self.name = 'threads' - self.is_found = False - methods = listify(self.methods) - if DependencyMethods.AUTO in methods: - self.is_found = True - # Happens if you are using a language with threads - # concept without C, such as plain Cuda. - if self.clib_compiler is None: - self.compile_args = [] - self.link_args = [] - else: - self.compile_args = self.clib_compiler.thread_flags(environment) - self.link_args = self.clib_compiler.thread_link_flags(environment) - return - - if DependencyMethods.CMAKE in methods: - # for unit tests and for those who simply want - # dependency('threads', method: 'cmake') - cmakedep = CMakeDependency('Threads', environment, kwargs) - if cmakedep.found(): - self.compile_args = cmakedep.get_compile_args() - self.link_args = cmakedep.get_link_args() - self.version = cmakedep.get_version() - self.is_found = True - return + def __init__(self, name: str, environment, kwargs): + super().__init__(name, environment, kwargs) + self.is_found = True + # Happens if you are using a language with threads + # concept without C, such as plain Cuda. + if self.clib_compiler is None: + self.compile_args = [] + self.link_args = [] + else: + self.compile_args = self.clib_compiler.thread_flags(environment) + self.link_args = self.clib_compiler.thread_link_flags(environment) @staticmethod def get_methods(): @@ -508,3 +492,10 @@ python3_factory = DependencyFactory( # Python 3 will always be in /Library extra_kwargs={'paths': ['/Library/Frameworks']}, ) + +threads_factory = DependencyFactory( + 'threads', + [DependencyMethods.SYSTEM, DependencyMethods.CMAKE], + cmake_name='Threads', + system_class=ThreadDependency, +) |