From 6d1e18247650b59a47ee7cdb200be0ef38d3b258 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 7 Oct 2021 16:20:06 +0200 Subject: [PATCH] Windows module: Make path flattening for windres work in more cases If either 'name' or 'name_formatted' are absolute paths, then they are of the form: C:\path/to/file.ext (example) By only substituting slashes with the underscore, we get: C:_path_to_file.ext This is still not quite right, infact os.path.basename() returns: _path_to_file.ext Also replace colons with underscores to overcome issues when absolute paths are involved. --- mesonbuild/modules/windows.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py index 7f627cff1..8f1af2cdd 100644 --- a/mesonbuild/modules/windows.py +++ b/mesonbuild/modules/windows.py @@ -145,8 +145,8 @@ class WindowsModule(ExtensionModule): raise MesonException(f'Unexpected source type {src!r}. windows.compile_resources accepts only strings, files, custom targets, and lists thereof.') # Path separators are not allowed in target names - name = name.replace('/', '_').replace('\\', '_') - name_formatted = name_formatted.replace('/', '_').replace('\\', '_') + name = name.replace('/', '_').replace('\\', '_').replace(':', '_') + name_formatted = name_formatted.replace('/', '_').replace('\\', '_').replace(':', '_') res_kwargs = { 'output': name + '_@BASENAME@.' + suffix,