From 6a2faacdf9e5dff25c7a467d102811e3e7d1cf08 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Tue, 2 Apr 2019 10:08:27 +0200 Subject: [PATCH] cmake: minor code fixes --- mesonbuild/dependencies/base.py | 4 ++-- mesonbuild/dependencies/dev.py | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 447a635dc..b45836d46 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -971,10 +971,10 @@ class CMakeDependency(ExternalDependency): def _gen_exception(self, msg): return DependencyException('Dependency {} not found: {}'.format(self.name, msg)) - def _main_cmake_file(self): + def _main_cmake_file(self) -> str: return 'CMakeLists.txt' - def _extra_cmake_opts(self): + def _extra_cmake_opts(self) -> List[str]: return [] def _map_module_list(self, modules: List[Tuple[str, bool]]) -> List[Tuple[str, bool]]: diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index 8f0c2c5cd..deb7ef128 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -28,6 +28,8 @@ from .base import ( ) from .misc import ThreadDependency +from typing import List, Tuple + def get_shared_library_suffix(environment, native): """This is only gauranteed to work for languages that compile to machine @@ -406,28 +408,28 @@ class LLVMDependencyCMake(CMakeDependency): super().__init__(name='LLVM', environment=env, language='cpp', kwargs=kwargs) # Extract extra include directories and definitions - incDirs = self.get_cmake_var('PACKAGE_INCLUDE_DIRS') + inc_dirs = self.get_cmake_var('PACKAGE_INCLUDE_DIRS') defs = self.get_cmake_var('PACKAGE_DEFINITIONS') - temp = list(map(lambda x: '-I{}'.format(x), incDirs)) + defs + temp = ['-I' + x for x in inc_dirs] + defs self.compile_args += [x for x in temp if x not in self.compile_args] - def _main_cmake_file(self): + def _main_cmake_file(self) -> str: # Use a custom CMakeLists.txt for LLVM return 'CMakeListsLLVM.txt' - def _extra_cmake_opts(self): + def _extra_cmake_opts(self) -> List[str]: return ['-DLLVM_MESON_MODULES={}'.format(';'.join(self.llvm_modules)), '-DLLVM_MESON_OPT_MODULES={}'.format(';'.join(self.llvm_opt_modules))] - def _map_module_list(self, modules): + def _map_module_list(self, modules: List[Tuple[str, bool]]) -> List[Tuple[str, bool]]: modules = [(x, True) for x in self.get_cmake_var('MESON_RESOLVED_LLVM_MODULES')] modules += [(x, False) for x in self.get_cmake_var('MESON_RESOLVED_LLVM_MODULES_OPT')] return modules - def need_threads(self): + def need_threads(self) -> bool: return True - def log_details(self): + def log_details(self) -> str: modules = self.get_cmake_var('MESON_RESOLVED_LLVM_MODULES') if modules: return 'modules: ' + ', '.join(modules)