Fix duplicate pkg_config_path entries

Previously builds would *potentially* get sammed with messaging at
configure time that duplicate entries in an array would be an error in
the future, and the cause was because the same entries were getting
added over and over to pkg_config_path.p
0.57
Tristan Partin 4 years ago committed by Nirbheek Chauhan
parent 28f41cb84e
commit 5a367d1135
  1. 4
      mesonbuild/dependencies/base.py
  2. 12
      run_unittests.py

@ -669,8 +669,8 @@ class PkgConfigDependency(ExternalDependency):
@staticmethod
def setup_env(env: T.MutableMapping[str, str], environment: 'Environment', for_machine: MachineChoice,
extra_path: T.Optional[str] = None) -> None:
extra_paths: T.List[str] = environment.coredata.options[OptionKey('pkg_config_path', machine=for_machine)].value
if extra_path:
extra_paths: T.List[str] = environment.coredata.options[OptionKey('pkg_config_path', machine=for_machine)].value[:]
if extra_path and extra_path not in extra_paths:
extra_paths.append(extra_path)
sysroot = environment.properties[for_machine].get_sys_root()
if sysroot:

@ -7264,6 +7264,18 @@ class LinuxlikeTests(BasePlatformTests):
link_args = ['-L' + libpath.as_posix(), '-lrelativepath']
self.assertEqual(relative_path_dep.get_link_args(), link_args)
@skipIfNoPkgconfig
def test_pkgconfig_duplicate_path_entries(self):
testdir = os.path.join(self.unit_test_dir, '111 pkgconfig duplicate path entries')
pkg_dir = os.path.join(testdir, 'pkgconfig')
env = get_fake_env(testdir, self.builddir, self.prefix)
env.coredata.set_options({OptionKey('pkg_config_path'): pkg_dir}, subproject='')
PkgConfigDependency.setup_env({}, env, MachineChoice.HOST, pkg_dir)
pkg_config_path = env.coredata.options[OptionKey('pkg_config_path')].value
self.assertTrue(len(pkg_config_path) == 1)
@skipIfNoPkgconfig
def test_pkgconfig_internal_libraries(self):
'''

Loading…
Cancel
Save