Skip to content

Commit 533fe7f

Browse files
committed
clang: Always pass POSIX paths to consumers
Fixes #12191
1 parent 8758e13 commit 533fe7f

File tree

3 files changed

+46
-43
lines changed

3 files changed

+46
-43
lines changed

mesonbuild/backend/backends.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,10 @@ def get_target_filename(self, t: T.Union[build.Target, build.CustomTargetIndex],
309309
else:
310310
assert isinstance(t, build.BuildTarget), t
311311
filename = t.get_filename()
312-
return os.path.join(self.get_target_dir(t), filename)
312+
return (Path(self.get_target_dir(t)) / filename).as_posix()
313313

314314
def get_target_filename_abs(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str:
315-
return os.path.join(self.environment.get_build_dir(), self.get_target_filename(target))
315+
return (Path(self.environment.get_build_dir()) / self.get_target_filename(target)).as_posix()
316316

317317
def get_source_dir_include_args(self, target: build.BuildTarget, compiler: 'Compiler', *, absolute_path: bool = False) -> T.List[str]:
318318
curdir = target.get_subdir()
@@ -339,16 +339,16 @@ def get_target_filename_for_linking(self, target: T.Union[build.Target, build.Cu
339339
# On all other platforms, we link to the library directly.
340340
if isinstance(target, build.SharedLibrary):
341341
link_lib = target.get_import_filename() or target.get_filename()
342-
return os.path.join(self.get_target_dir(target), link_lib)
342+
return (Path(self.get_target_dir(target)) / link_lib).as_posix()
343343
elif isinstance(target, build.StaticLibrary):
344-
return os.path.join(self.get_target_dir(target), target.get_filename())
344+
return (Path(self.get_target_dir(target)) / target.get_filename()).as_posix()
345345
elif isinstance(target, (build.CustomTarget, build.CustomTargetIndex)):
346346
if not target.is_linkable_target():
347347
raise MesonException(f'Tried to link against custom target "{target.name}", which is not linkable.')
348-
return os.path.join(self.get_target_dir(target), target.get_filename())
348+
return (Path(self.get_target_dir(target)) / target.get_filename()).as_posix()
349349
elif isinstance(target, build.Executable):
350350
if target.import_filename:
351-
return os.path.join(self.get_target_dir(target), target.get_import_filename())
351+
return (Path(self.get_target_dir(target)) / target.import_filename).as_posix()
352352
else:
353353
return None
354354
raise AssertionError(f'BUG: Tried to link to {target!r} which is not linkable')
@@ -1972,7 +1972,7 @@ def get_devenv(self) -> mesonlib.EnvironmentVariables:
19721972
in_default_dir = t.should_install() and not t.get_install_dir()[2]
19731973
if t.for_machine != MachineChoice.HOST or not in_default_dir:
19741974
continue
1975-
tdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(t))
1975+
tdir = (Path(self.environment.get_build_dir()) / self.get_target_dir(t)).as_posix()
19761976
if isinstance(t, build.Executable):
19771977
# Add binaries that are going to be installed in bindir into PATH
19781978
# so they get used by default instead of searching on system when

mesonbuild/backend/ninjabackend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3222,7 +3222,7 @@ def generate_pch(self, target, header_deps=None):
32223222
def get_target_shsym_filename(self, target):
32233223
# Always name the .symbols file after the primary build output because it always exists
32243224
targetdir = self.get_target_private_dir(target)
3225-
return os.path.join(targetdir, target.get_filename() + '.symbols')
3225+
return (Path(targetdir) / (target.get_filename() + '.symbols')).as_posix()
32263226

32273227
def generate_shsym(self, target):
32283228
target_file = self.get_target_filename(target)
@@ -3235,7 +3235,7 @@ def generate_shsym(self, target):
32353235
self.add_build(elem)
32363236

32373237
def get_import_filename(self, target):
3238-
return os.path.join(self.get_target_dir(target), target.import_filename)
3238+
return (Path(self.get_target_dir(target)) / target.import_filename).as_posix()
32393239

32403240
def get_target_type_link_args(self, target, linker):
32413241
commands = []

unittests/allplatformstests.py

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4511,184 +4511,187 @@ def output_name(name, type_):
45114511
static_lib_name = lambda name: output_name(name, StaticLibrary)
45124512
exe_name = lambda name: output_name(name, Executable)
45134513

4514+
def get_path(f):
4515+
return Path(f).as_posix()
4516+
45144517
expected = {
45154518
'targets': {
4516-
f'{self.builddir}/out1-notag.txt': {
4519+
get_path(f'{self.builddir}/out1-notag.txt'): {
45174520
'destination': '{datadir}/out1-notag.txt',
45184521
'tag': None,
45194522
'subproject': None,
45204523
},
4521-
f'{self.builddir}/out2-notag.txt': {
4524+
get_path(f'{self.builddir}/out2-notag.txt'): {
45224525
'destination': '{datadir}/out2-notag.txt',
45234526
'tag': None,
45244527
'subproject': None,
45254528
},
4526-
f'{self.builddir}/libstatic.a': {
4529+
get_path(f'{self.builddir}/libstatic.a'): {
45274530
'destination': '{libdir_static}/libstatic.a',
45284531
'tag': 'devel',
45294532
'subproject': None,
45304533
},
4531-
f'{self.builddir}/' + exe_name('app'): {
4534+
get_path('{self.builddir}/' + exe_name('app')): {
45324535
'destination': '{bindir}/' + exe_name('app'),
45334536
'tag': 'runtime',
45344537
'subproject': None,
45354538
},
4536-
f'{self.builddir}/' + exe_name('app-otherdir'): {
4539+
get_path('{self.builddir}/' + exe_name('app-otherdir')): {
45374540
'destination': '{prefix}/otherbin/' + exe_name('app-otherdir'),
45384541
'tag': 'runtime',
45394542
'subproject': None,
45404543
},
4541-
f'{self.builddir}/subdir/' + exe_name('app2'): {
4544+
get_path('{self.builddir}/subdir/' + exe_name('app2')): {
45424545
'destination': '{bindir}/' + exe_name('app2'),
45434546
'tag': 'runtime',
45444547
'subproject': None,
45454548
},
4546-
f'{self.builddir}/' + shared_lib_name('shared'): {
4549+
get_path('{self.builddir}/' + shared_lib_name('shared')): {
45474550
'destination': '{libdir_shared}/' + shared_lib_name('shared'),
45484551
'tag': 'runtime',
45494552
'subproject': None,
45504553
},
4551-
f'{self.builddir}/' + shared_lib_name('both'): {
4554+
get_path('{self.builddir}/' + shared_lib_name('both')): {
45524555
'destination': '{libdir_shared}/' + shared_lib_name('both'),
45534556
'tag': 'runtime',
45544557
'subproject': None,
45554558
},
4556-
f'{self.builddir}/' + static_lib_name('both'): {
4559+
get_path('{self.builddir}/' + static_lib_name('both')): {
45574560
'destination': '{libdir_static}/' + static_lib_name('both'),
45584561
'tag': 'devel',
45594562
'subproject': None,
45604563
},
4561-
f'{self.builddir}/' + shared_lib_name('bothcustom'): {
4564+
get_path('{self.builddir}/' + shared_lib_name('bothcustom')): {
45624565
'destination': '{libdir_shared}/' + shared_lib_name('bothcustom'),
45634566
'tag': 'custom',
45644567
'subproject': None,
45654568
},
4566-
f'{self.builddir}/' + static_lib_name('bothcustom'): {
4569+
get_path('{self.builddir}/' + static_lib_name('bothcustom')): {
45674570
'destination': '{libdir_static}/' + static_lib_name('bothcustom'),
45684571
'tag': 'custom',
45694572
'subproject': None,
45704573
},
4571-
f'{self.builddir}/subdir/' + shared_lib_name('both2'): {
4574+
get_path('{self.builddir}/subdir/' + shared_lib_name('both2')): {
45724575
'destination': '{libdir_shared}/' + shared_lib_name('both2'),
45734576
'tag': 'runtime',
45744577
'subproject': None,
45754578
},
4576-
f'{self.builddir}/subdir/' + static_lib_name('both2'): {
4579+
get_path('{self.builddir}/subdir/' + static_lib_name('both2')): {
45774580
'destination': '{libdir_static}/' + static_lib_name('both2'),
45784581
'tag': 'devel',
45794582
'subproject': None,
45804583
},
4581-
f'{self.builddir}/out1-custom.txt': {
4584+
get_path('{self.builddir}/out1-custom.txt'): {
45824585
'destination': '{datadir}/out1-custom.txt',
45834586
'tag': 'custom',
45844587
'subproject': None,
45854588
},
4586-
f'{self.builddir}/out2-custom.txt': {
4589+
get_path('{self.builddir}/out2-custom.txt'): {
45874590
'destination': '{datadir}/out2-custom.txt',
45884591
'tag': 'custom',
45894592
'subproject': None,
45904593
},
4591-
f'{self.builddir}/out3-custom.txt': {
4594+
get_path('{self.builddir}/out3-custom.txt'): {
45924595
'destination': '{datadir}/out3-custom.txt',
45934596
'tag': 'custom',
45944597
'subproject': None,
45954598
},
4596-
f'{self.builddir}/subdir/out1.txt': {
4599+
get_path('{self.builddir}/subdir/out1.txt'): {
45974600
'destination': '{datadir}/out1.txt',
45984601
'tag': None,
45994602
'subproject': None,
46004603
},
4601-
f'{self.builddir}/subdir/out2.txt': {
4604+
get_path('{self.builddir}/subdir/out2.txt'): {
46024605
'destination': '{datadir}/out2.txt',
46034606
'tag': None,
46044607
'subproject': None,
46054608
},
4606-
f'{self.builddir}/out-devel.h': {
4609+
get_path('{self.builddir}/out-devel.h'): {
46074610
'destination': '{includedir}/out-devel.h',
46084611
'tag': 'devel',
46094612
'subproject': None,
46104613
},
4611-
f'{self.builddir}/out3-notag.txt': {
4614+
get_path('{self.builddir}/out3-notag.txt'): {
46124615
'destination': '{datadir}/out3-notag.txt',
46134616
'tag': None,
46144617
'subproject': None,
46154618
},
46164619
},
46174620
'configure': {
4618-
f'{self.builddir}/foo-notag.h': {
4621+
get_path('{self.builddir}/foo-notag.h'): {
46194622
'destination': '{datadir}/foo-notag.h',
46204623
'tag': None,
46214624
'subproject': None,
46224625
},
4623-
f'{self.builddir}/foo2-devel.h': {
4626+
get_path('{self.builddir}/foo2-devel.h'): {
46244627
'destination': '{includedir}/foo2-devel.h',
46254628
'tag': 'devel',
46264629
'subproject': None,
46274630
},
4628-
f'{self.builddir}/foo-custom.h': {
4631+
get_path('{self.builddir}/foo-custom.h'): {
46294632
'destination': '{datadir}/foo-custom.h',
46304633
'tag': 'custom',
46314634
'subproject': None,
46324635
},
4633-
f'{self.builddir}/subdir/foo2.h': {
4636+
get_path('{self.builddir}/subdir/foo2.h'): {
46344637
'destination': '{datadir}/foo2.h',
46354638
'tag': None,
46364639
'subproject': None,
46374640
},
46384641
},
46394642
'data': {
4640-
f'{testdir}/bar-notag.txt': {
4643+
get_path('{testdir}/bar-notag.txt'): {
46414644
'destination': '{datadir}/bar-notag.txt',
46424645
'tag': None,
46434646
'subproject': None,
46444647
},
4645-
f'{testdir}/bar-devel.h': {
4648+
get_path('{testdir}/bar-devel.h'): {
46464649
'destination': '{includedir}/bar-devel.h',
46474650
'tag': 'devel',
46484651
'subproject': None,
46494652
},
4650-
f'{testdir}/bar-custom.txt': {
4653+
get_path('{testdir}/bar-custom.txt'): {
46514654
'destination': '{datadir}/bar-custom.txt',
46524655
'tag': 'custom',
46534656
'subproject': None,
46544657
},
4655-
f'{testdir}/subdir/bar2-devel.h': {
4658+
get_path('{testdir}/subdir/bar2-devel.h'): {
46564659
'destination': '{includedir}/bar2-devel.h',
46574660
'tag': 'devel',
46584661
'subproject': None,
46594662
},
4660-
f'{testdir}/subprojects/subproject/aaa.txt': {
4663+
get_path('{testdir}/subprojects/subproject/aaa.txt'): {
46614664
'destination': '{datadir}/subproject/aaa.txt',
46624665
'tag': None,
46634666
'subproject': 'subproject',
46644667
},
4665-
f'{testdir}/subprojects/subproject/bbb.txt': {
4668+
get_path('{testdir}/subprojects/subproject/bbb.txt'): {
46664669
'destination': '{datadir}/subproject/bbb.txt',
46674670
'tag': 'data',
46684671
'subproject': 'subproject',
46694672
},
46704673
},
46714674
'headers': {
4672-
f'{testdir}/foo1-devel.h': {
4675+
get_path('{testdir}/foo1-devel.h'): {
46734676
'destination': '{includedir}/foo1-devel.h',
46744677
'tag': 'devel',
46754678
'subproject': None,
46764679
},
4677-
f'{testdir}/subdir/foo3-devel.h': {
4680+
get_path('{testdir}/subdir/foo3-devel.h'): {
46784681
'destination': '{includedir}/foo3-devel.h',
46794682
'tag': 'devel',
46804683
'subproject': None,
46814684
},
46824685
},
46834686
'install_subdirs': {
4684-
f'{testdir}/custom_files': {
4687+
get_path('{testdir}/custom_files'): {
46854688
'destination': '{datadir}/custom_files',
46864689
'tag': 'custom',
46874690
'subproject': None,
46884691
'exclude_dirs': [],
46894692
'exclude_files': [],
46904693
},
4691-
f'{testdir}/excludes': {
4694+
get_path('{testdir}/excludes'): {
46924695
'destination': '{datadir}/excludes',
46934696
'tag': 'custom',
46944697
'subproject': None,

0 commit comments

Comments
 (0)