Xcode backend: better quoting for spaces in HEADER_SEARCH_PATHS
Xcode treats this dict value as a space-separated string, any spaces in
the path will make the path invalid by splitting it into pieces.
Split out header path processing into a helper function.
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
index 5c03c71..0e40d02 100644
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -1756,19 +1756,12 @@
settings_dict.add_item('GCC_PREFIX_HEADER', f'$(PROJECT_DIR)/{relative_pch_path}')
settings_dict.add_item('GCC_PREPROCESSOR_DEFINITIONS', '')
settings_dict.add_item('GCC_SYMBOLS_PRIVATE_EXTERN', 'NO')
- header_arr = PbxArray()
- unquoted_headers = []
- unquoted_headers.append(self.get_target_private_dir_abs(target))
+ unquoted_headers = [self.get_target_private_dir_abs(target)]
if target.implicit_include_directories:
unquoted_headers.append(os.path.join(self.environment.get_build_dir(), target.get_subdir()))
unquoted_headers.append(os.path.join(self.environment.get_source_dir(), target.get_subdir()))
- if headerdirs:
- for i in headerdirs:
- i = os.path.normpath(i)
- unquoted_headers.append(i)
- for i in unquoted_headers:
- header_arr.add_item(f'"{i}"')
- settings_dict.add_item('HEADER_SEARCH_PATHS', header_arr)
+ unquoted_headers += headerdirs
+ settings_dict.add_item('HEADER_SEARCH_PATHS', self.normalize_header_search_paths(unquoted_headers))
settings_dict.add_item('INSTALL_PATH', install_path)
settings_dict.add_item('LIBRARY_SEARCH_PATHS', '')
if isinstance(target, build.SharedModule):
@@ -1796,6 +1789,15 @@
warn_array.add_item('"$(inherited)"')
bt_dict.add_item('name', buildtype)
+ def normalize_header_search_paths(self, header_dirs) -> PbxArray:
+ header_arr = PbxArray()
+ for i in header_dirs:
+ np = os.path.normpath(i)
+ # Make sure Xcode will not split single path into separate entries, escaping space with a slash is not enought
+ item = f'"\\\"{np}\\\""' if ' ' in np else f'"{np}"'
+ header_arr.add_item(item)
+ return header_arr
+
def add_otherargs(self, settings_dict, langargs):
for langname, args in langargs.items():
if args: