prevent lib prefix warning from pkg-config

pull/11536/head
Charles Brunet 2 years ago committed by Eli Schwartz
parent ef5da765af
commit a5a7b29a66
  1. 2
      mesonbuild/compilers/compilers.py
  2. 2
      mesonbuild/compilers/cuda.py
  3. 4
      mesonbuild/compilers/fortran.py
  4. 12
      mesonbuild/compilers/mixins/clike.py
  5. 4
      mesonbuild/compilers/mixins/emscripten.py
  6. 2
      mesonbuild/compilers/vala.py
  7. 3
      mesonbuild/dependencies/pkgconfig.py
  8. 2
      unittests/internaltests.py

@ -752,7 +752,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
return args.copy()
def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
libtype: LibType = LibType.PREFER_SHARED) -> T.Optional[T.List[str]]:
libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True) -> T.Optional[T.List[str]]:
raise EnvironmentException(f'Language {self.get_display_language()} does not support library finding.')
def get_library_naming(self, env: 'Environment', libtype: LibType,

@ -749,7 +749,7 @@ class CudaCompiler(Compiler):
return self._to_host_flags(self.host_compiler.get_std_exe_link_args(), _Phase.LINKER)
def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
libtype: LibType = LibType.PREFER_SHARED) -> T.Optional[T.List[str]]:
libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True) -> T.Optional[T.List[str]]:
return ['-l' + libname] # FIXME
def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]:

@ -117,9 +117,9 @@ class FortranCompiler(CLikeCompiler, Compiler):
return filename
def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
libtype: LibType = LibType.PREFER_SHARED) -> T.Optional[T.List[str]]:
libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True) -> T.Optional[T.List[str]]:
code = 'stop; end program'
return self._find_library_impl(libname, env, extra_dirs, code, libtype)
return self._find_library_impl(libname, env, extra_dirs, code, libtype, lib_prefix_warning)
def has_multi_arguments(self, args: T.List[str], env: 'Environment') -> T.Tuple[bool, bool]:
return self._has_multi_arguments(args, env, 'stop; end program')

@ -1121,7 +1121,7 @@ class CLikeCompiler(Compiler):
'''
return self.sizeof('void *', '', env)[0] == 8
def _find_library_real(self, libname: str, env: 'Environment', extra_dirs: T.List[str], code: str, libtype: LibType) -> T.Optional[T.List[str]]:
def _find_library_real(self, libname: str, env: 'Environment', extra_dirs: T.List[str], code: str, libtype: LibType, lib_prefix_warning: bool) -> T.Optional[T.List[str]]:
# First try if we can just add the library as -l.
# Gcc + co seem to prefer builtin lib dirs to -L dirs.
# Only try to find std libs if no extra dirs specified.
@ -1160,13 +1160,13 @@ class CLikeCompiler(Compiler):
trial = self._get_file_from_list(env, trials)
if not trial:
continue
if libname.startswith('lib') and trial.name.startswith(libname):
if libname.startswith('lib') and trial.name.startswith(libname) and lib_prefix_warning:
mlog.warning(f'find_library({libname!r}) starting in "lib" only works by accident and is not portable')
return [trial.as_posix()]
return None
def _find_library_impl(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
code: str, libtype: LibType) -> T.Optional[T.List[str]]:
code: str, libtype: LibType, lib_prefix_warning: bool) -> T.Optional[T.List[str]]:
# These libraries are either built-in or invalid
if libname in self.ignore_libs:
return []
@ -1174,7 +1174,7 @@ class CLikeCompiler(Compiler):
extra_dirs = [extra_dirs]
key = (tuple(self.exelist), libname, tuple(extra_dirs), code, libtype)
if key not in self.find_library_cache:
value = self._find_library_real(libname, env, extra_dirs, code, libtype)
value = self._find_library_real(libname, env, extra_dirs, code, libtype, lib_prefix_warning)
self.find_library_cache[key] = value
else:
value = self.find_library_cache[key]
@ -1183,9 +1183,9 @@ class CLikeCompiler(Compiler):
return value.copy()
def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
libtype: LibType = LibType.PREFER_SHARED) -> T.Optional[T.List[str]]:
libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True) -> T.Optional[T.List[str]]:
code = 'int main(void) { return 0; }\n'
return self._find_library_impl(libname, env, extra_dirs, code, libtype)
return self._find_library_impl(libname, env, extra_dirs, code, libtype, lib_prefix_warning)
def find_framework_paths(self, env: 'Environment') -> T.List[str]:
'''

@ -86,9 +86,9 @@ class EmscriptenMixin(Compiler):
return wrap_js_includes(super().get_dependency_link_args(dep))
def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
libtype: LibType = LibType.PREFER_SHARED) -> T.Optional[T.List[str]]:
libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True) -> T.Optional[T.List[str]]:
if not libname.endswith('.js'):
return super().find_library(libname, env, extra_dirs, libtype)
return super().find_library(libname, env, extra_dirs, libtype, lib_prefix_warning)
if os.path.isabs(libname):
if os.path.exists(libname):
return [libname]

@ -111,7 +111,7 @@ class ValaCompiler(Compiler):
return []
def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
libtype: LibType = LibType.PREFER_SHARED) -> T.Optional[T.List[str]]:
libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True) -> T.Optional[T.List[str]]:
if extra_dirs and isinstance(extra_dirs, str):
extra_dirs = [extra_dirs]
# Valac always looks in the default vapi dir, so only search there if

@ -323,7 +323,8 @@ class PkgConfigDependency(ExternalDependency):
continue
if self.clib_compiler:
args = self.clib_compiler.find_library(lib[2:], self.env,
libpaths, self.libtype)
libpaths, self.libtype,
lib_prefix_warning=False)
# If the project only uses a non-clib language such as D, Rust,
# C#, Python, etc, all we can do is limp along by adding the
# arguments as-is and then adding the libpaths at the end.

@ -551,7 +551,7 @@ class InternalTests(unittest.TestCase):
for i in ['libfoo.so.6.0', 'libfoo.so.5.0', 'libfoo.so.54.0', 'libfoo.so.66a.0b', 'libfoo.so.70.0.so.1']:
libpath = Path(tmpdir) / i
libpath.write_text('', encoding='utf-8')
found = cc._find_library_real('foo', env, [tmpdir], '', LibType.PREFER_SHARED)
found = cc._find_library_real('foo', env, [tmpdir], '', LibType.PREFER_SHARED, lib_prefix_warning=True)
self.assertEqual(os.path.basename(found[0]), 'libfoo.so.54.0')
def test_find_library_patterns(self):

Loading…
Cancel
Save