diff options
Diffstat (limited to 'mesonbuild/dependencies/misc.py')
-rw-r--r-- | mesonbuild/dependencies/misc.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 23a283fae..c62f49f83 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -412,6 +412,39 @@ class ThreadDependency(ExternalDependency): self.link_args = self.clib_compiler.thread_link_flags(environment) +class BlocksDependency(ExternalDependency): + def __init__(self, environment, kwargs): + super().__init__('blocks', environment, None, kwargs) + self.name = 'blocks' + self.is_found = False + + if self.env.machines[self.for_machine].is_darwin(): + self.compile_args = [] + self.link_args = [] + else: + self.compile_args = ['-fblocks'] + self.link_args = ['-lBlocksRuntime'] + + if not self.clib_compiler.has_header('Block.h', '', environment, disable_cache=True) or \ + not self.clib_compiler.find_library('BlocksRuntime', environment, []): + mlog.log(mlog.red('ERROR:'), 'BlocksRuntime not found.') + return + + source = ''' + int main(int argc, char **argv) + { + int (^callback)(void) = ^ int (void) { return 0; }; + return callback(); + }''' + + with self.clib_compiler.compile(source, extra_args=self.compile_args + self.link_args) as p: + if p.returncode != 0: + mlog.log(mlog.red('ERROR:'), 'Compiler does not support blocks extension.') + return + + self.is_found = True + + class Python3Dependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('python3', environment, None, kwargs) |