diff options
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/dependencies/base.py | 25 | ||||
-rw-r--r-- | mesonbuild/dependencies/dev.py | 20 |
2 files changed, 34 insertions, 11 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index b45836d..486f523 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -984,6 +984,11 @@ class CMakeDependency(ExternalDependency): # CMakeLists.txt can be accessed here. return modules + def _original_module_name(self, module: str) -> str: + # Reverse the module mapping done by _map_module_list for + # one module + return module + def __init__(self, name: str, environment: Environment, kwargs, language=None): super().__init__('cmake', environment, language, kwargs) self.name = name @@ -1003,6 +1008,9 @@ class CMakeDependency(ExternalDependency): # Where all CMake "build dirs" are located self.cmake_root_dir = environment.scratch_dir + # List of successfully found modules + self.found_modules = [] + # When finding dependencies for cross-compiling, we don't care about # the 'native' CMake binary # TODO: Test if this works as expected @@ -1339,6 +1347,7 @@ class CMakeDependency(ExternalDependency): # Post-process module list. Used in derived classes to modify the # module list (append prepend a string, etc.). modules = self._map_module_list(modules) + autodetected_module_list = False # Try guessing a CMake target if none is provided if len(modules) == 0: @@ -1348,6 +1357,7 @@ class CMakeDependency(ExternalDependency): if '{}::{}'.format(lname, lname) == tg or lname == tg.replace('::', ''): mlog.debug('Guessed CMake target \'{}\''.format(i)) modules = [(i, True)] + autodetected_module_list = True break # Failed to guess a target --> try the old-style method @@ -1378,13 +1388,16 @@ class CMakeDependency(ExternalDependency): for i, required in modules: if i not in self.targets: if not required: - mlog.warning('CMake: Optional CMake target', mlog.bold(i), 'for', mlog.bold(name), 'was not found') + mlog.warning('CMake: Optional module', mlog.bold(self._original_module_name(i)), 'for', mlog.bold(name), 'was not found') continue - raise self._gen_exception('CMake: invalid CMake target {} for {}.\n' + raise self._gen_exception('CMake: invalid module {} for {}.\n' 'Try to explicitly specify one or more targets with the "modules" property.\n' - 'Valid targets are:\n{}'.format(i, name, list(self.targets.keys()))) + 'Valid targets are:\n{}'.format(self._original_module_name(i), name, list(self.targets.keys()))) targets = [i] + if not autodetected_module_list: + self.found_modules += [i] + while len(targets) > 0: curr = targets.pop(0) @@ -1764,6 +1777,12 @@ set(CMAKE_SIZEOF_VOID_P "{}") def log_tried(self): return self.type_name + def log_details(self) -> str: + modules = [self._original_module_name(x) for x in self.found_modules] + if modules: + return 'modules: ' + ', '.join(modules) + return '' + class DubDependency(ExternalDependency): class_dubbin = None diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index deb7ef1..2ad506e 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -405,6 +405,7 @@ class LLVMDependencyCMake(CMakeDependency): def __init__(self, env, kwargs): self.llvm_modules = stringlistify(extract_as_list(kwargs, 'modules')) self.llvm_opt_modules = stringlistify(extract_as_list(kwargs, 'optional_modules')) + self.module_map = {} super().__init__(name='LLVM', environment=env, language='cpp', kwargs=kwargs) # Extract extra include directories and definitions @@ -422,19 +423,22 @@ class LLVMDependencyCMake(CMakeDependency): '-DLLVM_MESON_OPT_MODULES={}'.format(';'.join(self.llvm_opt_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')] + res_modules = self.get_cmake_var('MESON_RESOLVED_LLVM_MODULES') + res_opt_modules = self.get_cmake_var('MESON_RESOLVED_LLVM_MODULES_OPT') + modules = [(x, True) for x in res_modules] + modules += [(x, False) for x in res_opt_modules] + self.module_map = { + **dict(zip(res_modules, self.llvm_modules)), + **dict(zip(res_opt_modules, self.llvm_opt_modules)) + } return modules + def _original_module_name(self, module: str) -> str: + return self.module_map.get(module, module) + def need_threads(self) -> bool: return True - def log_details(self) -> str: - modules = self.get_cmake_var('MESON_RESOLVED_LLVM_MODULES') - if modules: - return 'modules: ' + ', '.join(modules) - return '' - class LLVMDependency(ExternalDependency): def __init__(self, env, kwargs): super().__init__('LLVM', env, 'cpp', kwargs) |