diff options
-rw-r--r-- | mesonbuild/interpreter/compiler.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py index d75883a..b46e502 100644 --- a/mesonbuild/interpreter/compiler.py +++ b/mesonbuild/interpreter/compiler.py @@ -190,13 +190,9 @@ class CompilerHolder(ObjectHolder['Compiler']): def compiler(self) -> 'Compiler': return self.held_object - def _dep_msg(self, deps: T.List['dependencies.Dependency'], endl: str) -> str: + def _dep_msg(self, deps: T.List['dependencies.Dependency'], compile_only: bool, endl: str) -> str: msg_single = 'with dependency {}' msg_many = 'with dependencies {}' - if not deps: - return endl - if endl is None: - endl = '' names = [] for d in deps: if isinstance(d, dependencies.InternalDependency): @@ -204,13 +200,17 @@ class CompilerHolder(ObjectHolder['Compiler']): location=self.current_node) continue if isinstance(d, dependencies.ExternalLibrary): + if compile_only: + continue name = '-l' + d.name else: name = d.name names.append(name) if not names: - return None + return endl tpl = msg_many if len(names) > 1 else msg_single + if endl is None: + endl = '' return tpl.format(', '.join(names)) + endl @noPosargs @@ -239,9 +239,9 @@ class CompilerHolder(ObjectHolder['Compiler']): args.extend(extra_args) return args - def _determine_dependencies(self, deps: T.List['dependencies.Dependency'], endl: str = ':') -> T.Tuple[T.List['dependencies.Dependency'], str]: + def _determine_dependencies(self, deps: T.List['dependencies.Dependency'], compile_only: bool = False, endl: str = ':') -> T.Tuple[T.List['dependencies.Dependency'], str]: deps = dependencies.get_leaf_external_dependencies(deps) - return deps, self._dep_msg(deps, endl) + return deps, self._dep_msg(deps, compile_only, endl) @typed_pos_args('compiler.alignment', str) @typed_kwargs( @@ -252,7 +252,7 @@ class CompilerHolder(ObjectHolder['Compiler']): ) def alignment_method(self, args: T.Tuple[str], kwargs: 'AlignmentKw') -> int: typename = args[0] - deps, msg = self._determine_dependencies(kwargs['dependencies']) + deps, msg = self._determine_dependencies(kwargs['dependencies'], compile_only=self.compiler.is_cross) result = self.compiler.alignment(typename, kwargs['prefix'], self.environment, extra_args=kwargs['args'], dependencies=deps) @@ -269,7 +269,7 @@ class CompilerHolder(ObjectHolder['Compiler']): code.rel_to_builddir(self.environment.source_dir)) testname = kwargs['name'] extra_args = functools.partial(self._determine_args, kwargs['no_builtin_args'], kwargs['include_directories'], kwargs['args']) - deps, msg = self._determine_dependencies(kwargs['dependencies'], endl=None) + deps, msg = self._determine_dependencies(kwargs['dependencies'], compile_only=False, endl=None) result = self.compiler.run(code, self.environment, extra_args=extra_args, dependencies=deps) if testname: @@ -346,7 +346,7 @@ class CompilerHolder(ObjectHolder['Compiler']): def has_function_method(self, args: T.Tuple[str], kwargs: 'CommonKW') -> bool: funcname = args[0] extra_args = self._determine_args(kwargs['no_builtin_args'], kwargs['include_directories'], kwargs['args']) - deps, msg = self._determine_dependencies(kwargs['dependencies']) + deps, msg = self._determine_dependencies(kwargs['dependencies'], compile_only=False) had, cached = self.compiler.has_function(funcname, kwargs['prefix'], self.environment, extra_args=extra_args, dependencies=deps) @@ -386,7 +386,7 @@ class CompilerHolder(ObjectHolder['Compiler']): def compute_int_method(self, args: T.Tuple[str], kwargs: 'CompupteIntKW') -> int: expression = args[0] extra_args = functools.partial(self._determine_args, kwargs['no_builtin_args'], kwargs['include_directories'], kwargs['args']) - deps, msg = self._determine_dependencies(kwargs['dependencies']) + deps, msg = self._determine_dependencies(kwargs['dependencies'], compile_only=self.compiler.is_cross) res = self.compiler.compute_int(expression, kwargs['low'], kwargs['high'], kwargs['guess'], kwargs['prefix'], self.environment, extra_args=extra_args, @@ -399,7 +399,7 @@ class CompilerHolder(ObjectHolder['Compiler']): def sizeof_method(self, args: T.Tuple[str], kwargs: 'CommonKW') -> int: element = args[0] extra_args = functools.partial(self._determine_args, kwargs['no_builtin_args'], kwargs['include_directories'], kwargs['args']) - deps, msg = self._determine_dependencies(kwargs['dependencies']) + deps, msg = self._determine_dependencies(kwargs['dependencies'], compile_only=self.compiler.is_cross) esize = self.compiler.sizeof(element, kwargs['prefix'], self.environment, extra_args=extra_args, dependencies=deps) mlog.log('Checking for size of', mlog.bold(element, True), msg, esize) @@ -465,7 +465,7 @@ class CompilerHolder(ObjectHolder['Compiler']): testname = kwargs['name'] extra_args = functools.partial(self._determine_args, kwargs['no_builtin_args'], kwargs['include_directories'], kwargs['args']) - deps, msg = self._determine_dependencies(kwargs['dependencies']) + deps, msg = self._determine_dependencies(kwargs['dependencies'], compile_only=False) result, cached = self.compiler.links(code, self.environment, compiler=compiler, extra_args=extra_args, |