Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mesonbuild/dependencies/pkgconfig.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2013-2021 The Meson development team
# Copyright 2013-2025 The Meson development team

from __future__ import annotations

Expand Down Expand Up @@ -423,11 +423,11 @@ def _search_libs(self, libs_in: ImmutableListProtocol[str], raw_libs_in: Immutab
if not os.path.isabs(path):
# Resolve the path as a compiler in the build directory would
path = os.path.join(self.env.get_build_dir(), path)
prefix_libpaths.add(path)
prefix_libpaths.add(Path(path).resolve().as_posix())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why .as_posix()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On windows, Meson chooses to keep prefix_libpaths as posix. I don't know why. Sorry, I don't know much about windows. The honest answer is that the windows tests in the CI failed without this, and looking at the difference from what was expected, this fix was obvious.
If it's worth anything, I see .as_posix() used in line 276 of the same file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also the following comment on line 219: # pkg-config paths follow Unix conventions, even on Windows

# Library paths are not always ordered in a meaningful way
#
# Instead of relying on pkg-config or pkgconf to provide -L flags in a
# specific order, we reorder library paths ourselves, according to th
# specific order, we reorder library paths ourselves, according to the
# order specified in PKG_CONFIG_PATH. See:
# https://github.com/mesonbuild/meson/issues/4271
#
Expand Down
2 changes: 1 addition & 1 deletion unittests/allplatformstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,7 @@ def test_pkgconfig_gen_escaping(self):
kwargs = {'required': True, 'silent': True}
foo_dep = PkgConfigDependency('libanswer', env, kwargs)
# Ensure link_args are properly quoted
libdir = PurePath(prefix) / PurePath(libdir)
libdir = Path(prefix, libdir).resolve()
link_args = ['-L' + libdir.as_posix(), '-lanswer']
self.assertEqual(foo_dep.get_link_args(), link_args)
# Ensure include args are properly quoted
Expand Down
4 changes: 3 additions & 1 deletion unittests/internaltests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2016-2021 The Meson development team
# Copyright 2016-2025 The Meson development team

from configparser import ConfigParser
from pathlib import Path
Expand Down Expand Up @@ -669,6 +669,8 @@ def _call_pkgbin(self, args, env=None):
instance_method.return_value = FakeInstance(env, MachineChoice.HOST, silent=True)
kwargs = {'required': True, 'silent': True}
foo_dep = PkgConfigDependency('foo', env, kwargs)
p1 = p1.resolve()
p2 = p2.resolve()
self.assertEqual(foo_dep.get_link_args(),
[(p1 / 'libfoo.a').as_posix(), (p2 / 'libbar.a').as_posix()])
bar_dep = PkgConfigDependency('bar', env, kwargs)
Expand Down
4 changes: 2 additions & 2 deletions unittests/linuxliketests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2016-2022 The Meson development team
# Copyright 2016-2025 The Meson development team

import stat
import subprocess
Expand Down Expand Up @@ -1150,7 +1150,7 @@ def test_pkgconfig_relative_paths(self):
self.assertTrue(relative_path_dep.found())

# Ensure link_args are properly quoted
libpath = Path(self.builddir) / '../relativepath/lib'
libpath = Path(self.builddir).parent / 'relativepath/lib'
link_args = ['-L' + libpath.as_posix(), '-lrelativepath']
self.assertEqual(relative_path_dep.get_link_args(), link_args)

Expand Down
Loading