diff options
author | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-08-17 20:49:01 +0300 |
---|---|---|
committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-08-18 23:05:41 +0300 |
commit | a604bb34ed5aab514865588c1647775b2eeea2c0 (patch) | |
tree | 2a939a37c2555ae664bafba6035e79106dc3627b | |
parent | a3437c4c81a96b41576f810c51c9b0b5ce5631c2 (diff) | |
download | meson-a604bb34ed5aab514865588c1647775b2eeea2c0.zip meson-a604bb34ed5aab514865588c1647775b2eeea2c0.tar.gz meson-a604bb34ed5aab514865588c1647775b2eeea2c0.tar.bz2 |
Revert "backends: Use POSIX paths for target paths"
This reverts commit 12563f74a9f3dda70dcd4778aa958de355d1fae7.
-rw-r--r-- | mesonbuild/backend/backends.py | 10 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 4 | ||||
-rw-r--r-- | mesonbuild/mintro.py | 11 | ||||
-rw-r--r-- | unittests/allplatformstests.py | 75 |
4 files changed, 49 insertions, 51 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index d4de240..8fe696e 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -150,7 +150,7 @@ class TargetInstallData: def __post_init__(self, outdir_name: T.Optional[str]) -> None: if outdir_name is None: outdir_name = os.path.join('{prefix}', self.outdir) - self.out_name = Path(outdir_name, os.path.basename(self.fname)).as_posix() + self.out_name = os.path.join(outdir_name, os.path.basename(self.fname)) @dataclass(eq=False) class InstallEmptyDir: @@ -306,16 +306,16 @@ class Backend: else: assert isinstance(t, build.BuildTarget), t filename = t.get_filename() - return Path(self.get_target_dir(t), filename).as_posix() + return os.path.join(self.get_target_dir(t), filename) def get_target_filename_abs(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str: - return Path(self.environment.get_build_dir(), self.get_target_filename(target)).as_posix() + return os.path.join(self.environment.get_build_dir(), self.get_target_filename(target)) def get_target_debug_filename(self, target: build.BuildTarget) -> T.Optional[str]: assert isinstance(target, build.BuildTarget), target if target.get_debug_filename(): debug_filename = target.get_debug_filename() - return Path(self.get_target_dir(target), debug_filename).as_posix() + return os.path.join(self.get_target_dir(target), debug_filename) else: return None @@ -323,7 +323,7 @@ class Backend: assert isinstance(target, build.BuildTarget), target if not target.get_debug_filename(): return None - return Path(self.environment.get_build_dir(), self.get_target_debug_filename(target)).as_posix() + return os.path.join(self.environment.get_build_dir(), self.get_target_debug_filename(target)) def get_source_dir_include_args(self, target: build.BuildTarget, compiler: 'Compiler', *, absolute_path: bool = False) -> T.List[str]: curdir = target.get_subdir() diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 76f1606..d93e8c9 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -3388,7 +3388,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) def get_target_shsym_filename(self, target): # Always name the .symbols file after the primary build output because it always exists targetdir = self.get_target_private_dir(target) - return Path(targetdir, target.get_filename() + '.symbols').as_posix() + return os.path.join(targetdir, target.get_filename() + '.symbols') def generate_shsym(self, target) -> None: target_file = self.get_target_filename(target) @@ -3407,7 +3407,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) self.add_build(elem) def get_import_filename(self, target) -> str: - return Path(self.get_target_dir(target), target.import_filename).as_posix() + return os.path.join(self.get_target_dir(target), target.import_filename) def get_target_type_link_args(self, target, linker): commands = [] diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index e19e528..9f7eb33 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -128,7 +128,7 @@ def list_installed(installdata: backends.InstallData) -> T.Dict[str, str]: def list_install_plan(installdata: backends.InstallData) -> T.Dict[str, T.Dict[str, T.Dict[str, T.Union[str, T.List[str], None]]]]: plan: T.Dict[str, T.Dict[str, T.Dict[str, T.Union[str, T.List[str], None]]]] = { 'targets': { - Path(installdata.build_dir, target.fname).as_posix(): { + os.path.join(installdata.build_dir, target.fname): { 'destination': target.out_name, 'tag': target.tag or None, 'subproject': target.subproject or None, @@ -146,14 +146,13 @@ def list_install_plan(installdata: backends.InstallData) -> T.Dict[str, T.Dict[s }.items(): # Mypy doesn't recognize SubdirInstallData as a subclass of InstallDataBase for data in data_list: # type: ignore[attr-defined] - data_path = Path(data.path).as_posix() data_type = data.data_type or key - install_path_name = Path(data.install_path_name) + install_path_name = data.install_path_name if key == 'headers': # in the headers, install_path_name is the directory - install_path_name = install_path_name / os.path.basename(data.path) + install_path_name = os.path.join(install_path_name, os.path.basename(data.path)) entry = { - 'destination': install_path_name.as_posix(), + 'destination': install_path_name, 'tag': data.tag or None, 'subproject': data.subproject or None, } @@ -164,7 +163,7 @@ def list_install_plan(installdata: backends.InstallData) -> T.Dict[str, T.Dict[s entry['exclude_files'] = list(exclude_files) plan[data_type] = plan.get(data_type, {}) - plan[data_type][data_path] = entry + plan[data_type][data.path] = entry return plan diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 5e54466..8ebbab5 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -4826,144 +4826,143 @@ class AllPlatformTests(BasePlatformTests): shared_lib_name = lambda name: output_name(name, SharedLibrary) static_lib_name = lambda name: output_name(name, StaticLibrary) exe_name = lambda name: output_name(name, Executable) - get_path = lambda f: Path(f).as_posix() expected = { 'targets': { - get_path(f'{self.builddir}/out1-notag.txt'): { + f'{self.builddir}/out1-notag.txt': { 'build_rpaths': [], 'destination': '{datadir}/out1-notag.txt', 'install_rpath': None, 'tag': None, 'subproject': None, }, - get_path(f'{self.builddir}/out2-notag.txt'): { + f'{self.builddir}/out2-notag.txt': { 'build_rpaths': [], 'destination': '{datadir}/out2-notag.txt', 'install_rpath': None, 'tag': None, 'subproject': None, }, - get_path(f'{self.builddir}/libstatic.a'): { + f'{self.builddir}/libstatic.a': { 'build_rpaths': [], 'destination': '{libdir_static}/libstatic.a', 'install_rpath': None, 'tag': 'devel', 'subproject': None, }, - get_path(f'{self.builddir}/' + exe_name('app')): { + f'{self.builddir}/' + exe_name('app'): { 'build_rpaths': [], 'destination': '{bindir}/' + exe_name('app'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, - get_path(f'{self.builddir}/' + exe_name('app-otherdir')): { + f'{self.builddir}/' + exe_name('app-otherdir'): { 'build_rpaths': [], 'destination': '{prefix}/otherbin/' + exe_name('app-otherdir'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, - get_path(f'{self.builddir}/subdir/' + exe_name('app2')): { + f'{self.builddir}/subdir/' + exe_name('app2'): { 'build_rpaths': [], 'destination': '{bindir}/' + exe_name('app2'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, - get_path(f'{self.builddir}/' + shared_lib_name('shared')): { + f'{self.builddir}/' + shared_lib_name('shared'): { 'build_rpaths': [], 'destination': '{libdir_shared}/' + shared_lib_name('shared'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, - get_path(f'{self.builddir}/' + shared_lib_name('both')): { + f'{self.builddir}/' + shared_lib_name('both'): { 'build_rpaths': [], 'destination': '{libdir_shared}/' + shared_lib_name('both'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, - get_path(f'{self.builddir}/' + static_lib_name('both')): { + f'{self.builddir}/' + static_lib_name('both'): { 'build_rpaths': [], 'destination': '{libdir_static}/' + static_lib_name('both'), 'install_rpath': None, 'tag': 'devel', 'subproject': None, }, - get_path(f'{self.builddir}/' + shared_lib_name('bothcustom')): { + f'{self.builddir}/' + shared_lib_name('bothcustom'): { 'build_rpaths': [], 'destination': '{libdir_shared}/' + shared_lib_name('bothcustom'), 'install_rpath': None, 'tag': 'custom', 'subproject': None, }, - get_path(f'{self.builddir}/' + static_lib_name('bothcustom')): { + f'{self.builddir}/' + static_lib_name('bothcustom'): { 'build_rpaths': [], 'destination': '{libdir_static}/' + static_lib_name('bothcustom'), 'install_rpath': None, 'tag': 'custom', 'subproject': None, }, - get_path(f'{self.builddir}/subdir/' + shared_lib_name('both2')): { + f'{self.builddir}/subdir/' + shared_lib_name('both2'): { 'build_rpaths': [], 'destination': '{libdir_shared}/' + shared_lib_name('both2'), 'install_rpath': None, 'tag': 'runtime', 'subproject': None, }, - get_path(f'{self.builddir}/subdir/' + static_lib_name('both2')): { + f'{self.builddir}/subdir/' + static_lib_name('both2'): { 'build_rpaths': [], 'destination': '{libdir_static}/' + static_lib_name('both2'), 'install_rpath': None, 'tag': 'devel', 'subproject': None, }, - get_path(f'{self.builddir}/out1-custom.txt'): { + f'{self.builddir}/out1-custom.txt': { 'build_rpaths': [], 'destination': '{datadir}/out1-custom.txt', 'install_rpath': None, 'tag': 'custom', 'subproject': None, }, - get_path(f'{self.builddir}/out2-custom.txt'): { + f'{self.builddir}/out2-custom.txt': { 'build_rpaths': [], 'destination': '{datadir}/out2-custom.txt', 'install_rpath': None, 'tag': 'custom', 'subproject': None, }, - get_path(f'{self.builddir}/out3-custom.txt'): { + f'{self.builddir}/out3-custom.txt': { 'build_rpaths': [], 'destination': '{datadir}/out3-custom.txt', 'install_rpath': None, 'tag': 'custom', 'subproject': None, }, - get_path(f'{self.builddir}/subdir/out1.txt'): { + f'{self.builddir}/subdir/out1.txt': { 'build_rpaths': [], 'destination': '{datadir}/out1.txt', 'install_rpath': None, 'tag': None, 'subproject': None, }, - get_path(f'{self.builddir}/subdir/out2.txt'): { + f'{self.builddir}/subdir/out2.txt': { 'build_rpaths': [], 'destination': '{datadir}/out2.txt', 'install_rpath': None, 'tag': None, 'subproject': None, }, - get_path(f'{self.builddir}/out-devel.h'): { + f'{self.builddir}/out-devel.h': { 'build_rpaths': [], 'destination': '{includedir}/out-devel.h', 'install_rpath': None, 'tag': 'devel', 'subproject': None, }, - get_path(f'{self.builddir}/out3-notag.txt'): { + f'{self.builddir}/out3-notag.txt': { 'build_rpaths': [], 'destination': '{datadir}/out3-notag.txt', 'install_rpath': None, @@ -4972,80 +4971,80 @@ class AllPlatformTests(BasePlatformTests): }, }, 'configure': { - get_path(f'{self.builddir}/foo-notag.h'): { + f'{self.builddir}/foo-notag.h': { 'destination': '{datadir}/foo-notag.h', 'tag': None, 'subproject': None, }, - get_path(f'{self.builddir}/foo2-devel.h'): { + f'{self.builddir}/foo2-devel.h': { 'destination': '{includedir}/foo2-devel.h', 'tag': 'devel', 'subproject': None, }, - get_path(f'{self.builddir}/foo-custom.h'): { + f'{self.builddir}/foo-custom.h': { 'destination': '{datadir}/foo-custom.h', 'tag': 'custom', 'subproject': None, }, - get_path(f'{self.builddir}/subdir/foo2.h'): { + f'{self.builddir}/subdir/foo2.h': { 'destination': '{datadir}/foo2.h', 'tag': None, 'subproject': None, }, }, 'data': { - get_path(f'{testdir}/bar-notag.txt'): { + f'{testdir}/bar-notag.txt': { 'destination': '{datadir}/bar-notag.txt', 'tag': None, 'subproject': None, }, - get_path(f'{testdir}/bar-devel.h'): { + f'{testdir}/bar-devel.h': { 'destination': '{includedir}/bar-devel.h', 'tag': 'devel', 'subproject': None, }, - get_path(f'{testdir}/bar-custom.txt'): { + f'{testdir}/bar-custom.txt': { 'destination': '{datadir}/bar-custom.txt', 'tag': 'custom', 'subproject': None, }, - get_path(f'{testdir}/subdir/bar2-devel.h'): { + f'{testdir}/subdir/bar2-devel.h': { 'destination': '{includedir}/bar2-devel.h', 'tag': 'devel', 'subproject': None, }, - get_path(f'{testdir}/subprojects/subproject/aaa.txt'): { + f'{testdir}/subprojects/subproject/aaa.txt': { 'destination': '{datadir}/subproject/aaa.txt', 'tag': None, 'subproject': 'subproject', }, - get_path(f'{testdir}/subprojects/subproject/bbb.txt'): { + f'{testdir}/subprojects/subproject/bbb.txt': { 'destination': '{datadir}/subproject/bbb.txt', 'tag': 'data', 'subproject': 'subproject', }, }, 'headers': { - get_path(f'{testdir}/foo1-devel.h'): { + f'{testdir}/foo1-devel.h': { 'destination': '{includedir}/foo1-devel.h', 'tag': 'devel', 'subproject': None, }, - get_path(f'{testdir}/subdir/foo3-devel.h'): { + f'{testdir}/subdir/foo3-devel.h': { 'destination': '{includedir}/foo3-devel.h', 'tag': 'devel', 'subproject': None, }, }, 'install_subdirs': { - get_path(f'{testdir}/custom_files'): { + f'{testdir}/custom_files': { 'destination': '{datadir}/custom_files', 'tag': 'custom', 'subproject': None, 'exclude_dirs': [], 'exclude_files': [], }, - get_path(f'{testdir}/excludes'): { + f'{testdir}/excludes': { 'destination': '{datadir}/excludes', 'tag': 'custom', 'subproject': None, @@ -5055,10 +5054,11 @@ class AllPlatformTests(BasePlatformTests): } } + fix_path = lambda path: os.path.sep.join(path.split('/')) expected_fixed = { data_type: { - get_path(source): { - key: get_path(value) if key == 'destination' else value + fix_path(source): { + key: fix_path(value) if key == 'destination' else value for key, value in attributes.items() } for source, attributes in files.items() @@ -5069,7 +5069,6 @@ class AllPlatformTests(BasePlatformTests): for data_type, files in expected_fixed.items(): for file, details in files.items(): with self.subTest(key='{}.{}'.format(data_type, file)): - if data_type == 'data': print(res[data_type]) self.assertEqual(res[data_type][file], details) @skip_if_not_language('rust') |