Skip to content

Commit a604bb3

Browse files
committed
Revert "backends: Use POSIX paths for target paths"
This reverts commit 12563f7.
1 parent a3437c4 commit a604bb3

File tree

4 files changed

+49
-51
lines changed

4 files changed

+49
-51
lines changed

mesonbuild/backend/backends.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class TargetInstallData:
150150
def __post_init__(self, outdir_name: T.Optional[str]) -> None:
151151
if outdir_name is None:
152152
outdir_name = os.path.join('{prefix}', self.outdir)
153-
self.out_name = Path(outdir_name, os.path.basename(self.fname)).as_posix()
153+
self.out_name = os.path.join(outdir_name, os.path.basename(self.fname))
154154

155155
@dataclass(eq=False)
156156
class InstallEmptyDir:
@@ -306,24 +306,24 @@ def get_target_filename(self, t: T.Union[build.Target, build.CustomTargetIndex],
306306
else:
307307
assert isinstance(t, build.BuildTarget), t
308308
filename = t.get_filename()
309-
return Path(self.get_target_dir(t), filename).as_posix()
309+
return os.path.join(self.get_target_dir(t), filename)
310310

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

314314
def get_target_debug_filename(self, target: build.BuildTarget) -> T.Optional[str]:
315315
assert isinstance(target, build.BuildTarget), target
316316
if target.get_debug_filename():
317317
debug_filename = target.get_debug_filename()
318-
return Path(self.get_target_dir(target), debug_filename).as_posix()
318+
return os.path.join(self.get_target_dir(target), debug_filename)
319319
else:
320320
return None
321321

322322
def get_target_debug_filename_abs(self, target: build.BuildTarget) -> T.Optional[str]:
323323
assert isinstance(target, build.BuildTarget), target
324324
if not target.get_debug_filename():
325325
return None
326-
return Path(self.environment.get_build_dir(), self.get_target_debug_filename(target)).as_posix()
326+
return os.path.join(self.environment.get_build_dir(), self.get_target_debug_filename(target))
327327

328328
def get_source_dir_include_args(self, target: build.BuildTarget, compiler: 'Compiler', *, absolute_path: bool = False) -> T.List[str]:
329329
curdir = target.get_subdir()

mesonbuild/backend/ninjabackend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,7 +3388,7 @@ def generate_pch(self, target, header_deps=None):
33883388
def get_target_shsym_filename(self, target):
33893389
# Always name the .symbols file after the primary build output because it always exists
33903390
targetdir = self.get_target_private_dir(target)
3391-
return Path(targetdir, target.get_filename() + '.symbols').as_posix()
3391+
return os.path.join(targetdir, target.get_filename() + '.symbols')
33923392

33933393
def generate_shsym(self, target) -> None:
33943394
target_file = self.get_target_filename(target)
@@ -3407,7 +3407,7 @@ def generate_shsym(self, target) -> None:
34073407
self.add_build(elem)
34083408

34093409
def get_import_filename(self, target) -> str:
3410-
return Path(self.get_target_dir(target), target.import_filename).as_posix()
3410+
return os.path.join(self.get_target_dir(target), target.import_filename)
34113411

34123412
def get_target_type_link_args(self, target, linker):
34133413
commands = []

mesonbuild/mintro.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def list_installed(installdata: backends.InstallData) -> T.Dict[str, str]:
128128
def list_install_plan(installdata: backends.InstallData) -> T.Dict[str, T.Dict[str, T.Dict[str, T.Union[str, T.List[str], None]]]]:
129129
plan: T.Dict[str, T.Dict[str, T.Dict[str, T.Union[str, T.List[str], None]]]] = {
130130
'targets': {
131-
Path(installdata.build_dir, target.fname).as_posix(): {
131+
os.path.join(installdata.build_dir, target.fname): {
132132
'destination': target.out_name,
133133
'tag': target.tag or None,
134134
'subproject': target.subproject or None,
@@ -146,14 +146,13 @@ def list_install_plan(installdata: backends.InstallData) -> T.Dict[str, T.Dict[s
146146
}.items():
147147
# Mypy doesn't recognize SubdirInstallData as a subclass of InstallDataBase
148148
for data in data_list: # type: ignore[attr-defined]
149-
data_path = Path(data.path).as_posix()
150149
data_type = data.data_type or key
151-
install_path_name = Path(data.install_path_name)
150+
install_path_name = data.install_path_name
152151
if key == 'headers': # in the headers, install_path_name is the directory
153-
install_path_name = install_path_name / os.path.basename(data.path)
152+
install_path_name = os.path.join(install_path_name, os.path.basename(data.path))
154153

155154
entry = {
156-
'destination': install_path_name.as_posix(),
155+
'destination': install_path_name,
157156
'tag': data.tag or None,
158157
'subproject': data.subproject or None,
159158
}
@@ -164,7 +163,7 @@ def list_install_plan(installdata: backends.InstallData) -> T.Dict[str, T.Dict[s
164163
entry['exclude_files'] = list(exclude_files)
165164

166165
plan[data_type] = plan.get(data_type, {})
167-
plan[data_type][data_path] = entry
166+
plan[data_type][data.path] = entry
168167

169168
return plan
170169

unittests/allplatformstests.py

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4826,144 +4826,143 @@ def output_name(name, type_):
48264826
shared_lib_name = lambda name: output_name(name, SharedLibrary)
48274827
static_lib_name = lambda name: output_name(name, StaticLibrary)
48284828
exe_name = lambda name: output_name(name, Executable)
4829-
get_path = lambda f: Path(f).as_posix()
48304829

48314830
expected = {
48324831
'targets': {
4833-
get_path(f'{self.builddir}/out1-notag.txt'): {
4832+
f'{self.builddir}/out1-notag.txt': {
48344833
'build_rpaths': [],
48354834
'destination': '{datadir}/out1-notag.txt',
48364835
'install_rpath': None,
48374836
'tag': None,
48384837
'subproject': None,
48394838
},
4840-
get_path(f'{self.builddir}/out2-notag.txt'): {
4839+
f'{self.builddir}/out2-notag.txt': {
48414840
'build_rpaths': [],
48424841
'destination': '{datadir}/out2-notag.txt',
48434842
'install_rpath': None,
48444843
'tag': None,
48454844
'subproject': None,
48464845
},
4847-
get_path(f'{self.builddir}/libstatic.a'): {
4846+
f'{self.builddir}/libstatic.a': {
48484847
'build_rpaths': [],
48494848
'destination': '{libdir_static}/libstatic.a',
48504849
'install_rpath': None,
48514850
'tag': 'devel',
48524851
'subproject': None,
48534852
},
4854-
get_path(f'{self.builddir}/' + exe_name('app')): {
4853+
f'{self.builddir}/' + exe_name('app'): {
48554854
'build_rpaths': [],
48564855
'destination': '{bindir}/' + exe_name('app'),
48574856
'install_rpath': None,
48584857
'tag': 'runtime',
48594858
'subproject': None,
48604859
},
4861-
get_path(f'{self.builddir}/' + exe_name('app-otherdir')): {
4860+
f'{self.builddir}/' + exe_name('app-otherdir'): {
48624861
'build_rpaths': [],
48634862
'destination': '{prefix}/otherbin/' + exe_name('app-otherdir'),
48644863
'install_rpath': None,
48654864
'tag': 'runtime',
48664865
'subproject': None,
48674866
},
4868-
get_path(f'{self.builddir}/subdir/' + exe_name('app2')): {
4867+
f'{self.builddir}/subdir/' + exe_name('app2'): {
48694868
'build_rpaths': [],
48704869
'destination': '{bindir}/' + exe_name('app2'),
48714870
'install_rpath': None,
48724871
'tag': 'runtime',
48734872
'subproject': None,
48744873
},
4875-
get_path(f'{self.builddir}/' + shared_lib_name('shared')): {
4874+
f'{self.builddir}/' + shared_lib_name('shared'): {
48764875
'build_rpaths': [],
48774876
'destination': '{libdir_shared}/' + shared_lib_name('shared'),
48784877
'install_rpath': None,
48794878
'tag': 'runtime',
48804879
'subproject': None,
48814880
},
4882-
get_path(f'{self.builddir}/' + shared_lib_name('both')): {
4881+
f'{self.builddir}/' + shared_lib_name('both'): {
48834882
'build_rpaths': [],
48844883
'destination': '{libdir_shared}/' + shared_lib_name('both'),
48854884
'install_rpath': None,
48864885
'tag': 'runtime',
48874886
'subproject': None,
48884887
},
4889-
get_path(f'{self.builddir}/' + static_lib_name('both')): {
4888+
f'{self.builddir}/' + static_lib_name('both'): {
48904889
'build_rpaths': [],
48914890
'destination': '{libdir_static}/' + static_lib_name('both'),
48924891
'install_rpath': None,
48934892
'tag': 'devel',
48944893
'subproject': None,
48954894
},
4896-
get_path(f'{self.builddir}/' + shared_lib_name('bothcustom')): {
4895+
f'{self.builddir}/' + shared_lib_name('bothcustom'): {
48974896
'build_rpaths': [],
48984897
'destination': '{libdir_shared}/' + shared_lib_name('bothcustom'),
48994898
'install_rpath': None,
49004899
'tag': 'custom',
49014900
'subproject': None,
49024901
},
4903-
get_path(f'{self.builddir}/' + static_lib_name('bothcustom')): {
4902+
f'{self.builddir}/' + static_lib_name('bothcustom'): {
49044903
'build_rpaths': [],
49054904
'destination': '{libdir_static}/' + static_lib_name('bothcustom'),
49064905
'install_rpath': None,
49074906
'tag': 'custom',
49084907
'subproject': None,
49094908
},
4910-
get_path(f'{self.builddir}/subdir/' + shared_lib_name('both2')): {
4909+
f'{self.builddir}/subdir/' + shared_lib_name('both2'): {
49114910
'build_rpaths': [],
49124911
'destination': '{libdir_shared}/' + shared_lib_name('both2'),
49134912
'install_rpath': None,
49144913
'tag': 'runtime',
49154914
'subproject': None,
49164915
},
4917-
get_path(f'{self.builddir}/subdir/' + static_lib_name('both2')): {
4916+
f'{self.builddir}/subdir/' + static_lib_name('both2'): {
49184917
'build_rpaths': [],
49194918
'destination': '{libdir_static}/' + static_lib_name('both2'),
49204919
'install_rpath': None,
49214920
'tag': 'devel',
49224921
'subproject': None,
49234922
},
4924-
get_path(f'{self.builddir}/out1-custom.txt'): {
4923+
f'{self.builddir}/out1-custom.txt': {
49254924
'build_rpaths': [],
49264925
'destination': '{datadir}/out1-custom.txt',
49274926
'install_rpath': None,
49284927
'tag': 'custom',
49294928
'subproject': None,
49304929
},
4931-
get_path(f'{self.builddir}/out2-custom.txt'): {
4930+
f'{self.builddir}/out2-custom.txt': {
49324931
'build_rpaths': [],
49334932
'destination': '{datadir}/out2-custom.txt',
49344933
'install_rpath': None,
49354934
'tag': 'custom',
49364935
'subproject': None,
49374936
},
4938-
get_path(f'{self.builddir}/out3-custom.txt'): {
4937+
f'{self.builddir}/out3-custom.txt': {
49394938
'build_rpaths': [],
49404939
'destination': '{datadir}/out3-custom.txt',
49414940
'install_rpath': None,
49424941
'tag': 'custom',
49434942
'subproject': None,
49444943
},
4945-
get_path(f'{self.builddir}/subdir/out1.txt'): {
4944+
f'{self.builddir}/subdir/out1.txt': {
49464945
'build_rpaths': [],
49474946
'destination': '{datadir}/out1.txt',
49484947
'install_rpath': None,
49494948
'tag': None,
49504949
'subproject': None,
49514950
},
4952-
get_path(f'{self.builddir}/subdir/out2.txt'): {
4951+
f'{self.builddir}/subdir/out2.txt': {
49534952
'build_rpaths': [],
49544953
'destination': '{datadir}/out2.txt',
49554954
'install_rpath': None,
49564955
'tag': None,
49574956
'subproject': None,
49584957
},
4959-
get_path(f'{self.builddir}/out-devel.h'): {
4958+
f'{self.builddir}/out-devel.h': {
49604959
'build_rpaths': [],
49614960
'destination': '{includedir}/out-devel.h',
49624961
'install_rpath': None,
49634962
'tag': 'devel',
49644963
'subproject': None,
49654964
},
4966-
get_path(f'{self.builddir}/out3-notag.txt'): {
4965+
f'{self.builddir}/out3-notag.txt': {
49674966
'build_rpaths': [],
49684967
'destination': '{datadir}/out3-notag.txt',
49694968
'install_rpath': None,
@@ -4972,80 +4971,80 @@ def output_name(name, type_):
49724971
},
49734972
},
49744973
'configure': {
4975-
get_path(f'{self.builddir}/foo-notag.h'): {
4974+
f'{self.builddir}/foo-notag.h': {
49764975
'destination': '{datadir}/foo-notag.h',
49774976
'tag': None,
49784977
'subproject': None,
49794978
},
4980-
get_path(f'{self.builddir}/foo2-devel.h'): {
4979+
f'{self.builddir}/foo2-devel.h': {
49814980
'destination': '{includedir}/foo2-devel.h',
49824981
'tag': 'devel',
49834982
'subproject': None,
49844983
},
4985-
get_path(f'{self.builddir}/foo-custom.h'): {
4984+
f'{self.builddir}/foo-custom.h': {
49864985
'destination': '{datadir}/foo-custom.h',
49874986
'tag': 'custom',
49884987
'subproject': None,
49894988
},
4990-
get_path(f'{self.builddir}/subdir/foo2.h'): {
4989+
f'{self.builddir}/subdir/foo2.h': {
49914990
'destination': '{datadir}/foo2.h',
49924991
'tag': None,
49934992
'subproject': None,
49944993
},
49954994
},
49964995
'data': {
4997-
get_path(f'{testdir}/bar-notag.txt'): {
4996+
f'{testdir}/bar-notag.txt': {
49984997
'destination': '{datadir}/bar-notag.txt',
49994998
'tag': None,
50004999
'subproject': None,
50015000
},
5002-
get_path(f'{testdir}/bar-devel.h'): {
5001+
f'{testdir}/bar-devel.h': {
50035002
'destination': '{includedir}/bar-devel.h',
50045003
'tag': 'devel',
50055004
'subproject': None,
50065005
},
5007-
get_path(f'{testdir}/bar-custom.txt'): {
5006+
f'{testdir}/bar-custom.txt': {
50085007
'destination': '{datadir}/bar-custom.txt',
50095008
'tag': 'custom',
50105009
'subproject': None,
50115010
},
5012-
get_path(f'{testdir}/subdir/bar2-devel.h'): {
5011+
f'{testdir}/subdir/bar2-devel.h': {
50135012
'destination': '{includedir}/bar2-devel.h',
50145013
'tag': 'devel',
50155014
'subproject': None,
50165015
},
5017-
get_path(f'{testdir}/subprojects/subproject/aaa.txt'): {
5016+
f'{testdir}/subprojects/subproject/aaa.txt': {
50185017
'destination': '{datadir}/subproject/aaa.txt',
50195018
'tag': None,
50205019
'subproject': 'subproject',
50215020
},
5022-
get_path(f'{testdir}/subprojects/subproject/bbb.txt'): {
5021+
f'{testdir}/subprojects/subproject/bbb.txt': {
50235022
'destination': '{datadir}/subproject/bbb.txt',
50245023
'tag': 'data',
50255024
'subproject': 'subproject',
50265025
},
50275026
},
50285027
'headers': {
5029-
get_path(f'{testdir}/foo1-devel.h'): {
5028+
f'{testdir}/foo1-devel.h': {
50305029
'destination': '{includedir}/foo1-devel.h',
50315030
'tag': 'devel',
50325031
'subproject': None,
50335032
},
5034-
get_path(f'{testdir}/subdir/foo3-devel.h'): {
5033+
f'{testdir}/subdir/foo3-devel.h': {
50355034
'destination': '{includedir}/foo3-devel.h',
50365035
'tag': 'devel',
50375036
'subproject': None,
50385037
},
50395038
},
50405039
'install_subdirs': {
5041-
get_path(f'{testdir}/custom_files'): {
5040+
f'{testdir}/custom_files': {
50425041
'destination': '{datadir}/custom_files',
50435042
'tag': 'custom',
50445043
'subproject': None,
50455044
'exclude_dirs': [],
50465045
'exclude_files': [],
50475046
},
5048-
get_path(f'{testdir}/excludes'): {
5047+
f'{testdir}/excludes': {
50495048
'destination': '{datadir}/excludes',
50505049
'tag': 'custom',
50515050
'subproject': None,
@@ -5055,10 +5054,11 @@ def output_name(name, type_):
50555054
}
50565055
}
50575056

5057+
fix_path = lambda path: os.path.sep.join(path.split('/'))
50585058
expected_fixed = {
50595059
data_type: {
5060-
get_path(source): {
5061-
key: get_path(value) if key == 'destination' else value
5060+
fix_path(source): {
5061+
key: fix_path(value) if key == 'destination' else value
50625062
for key, value in attributes.items()
50635063
}
50645064
for source, attributes in files.items()
@@ -5069,7 +5069,6 @@ def output_name(name, type_):
50695069
for data_type, files in expected_fixed.items():
50705070
for file, details in files.items():
50715071
with self.subTest(key='{}.{}'.format(data_type, file)):
5072-
if data_type == 'data': print(res[data_type])
50735072
self.assertEqual(res[data_type][file], details)
50745073

50755074
@skip_if_not_language('rust')

0 commit comments

Comments
 (0)