From 1fd839ef555ec3a8d0237fc6b1d5f4be93f0ca29 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sat, 31 May 2025 17:25:55 +0200 Subject: handle spacing between # and cmakedefine just as with C defines cmakedefine supports a variable amount of whitespace between the # symbol and the actual token. --- mesonbuild/utils/universal.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index e89887631..fc9a435ed 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -1346,7 +1346,7 @@ def do_define_cmake(regex: T.Pattern[str], line: str, confdata: 'ConfigurationDa cmake_bool_define = 'cmakedefine01' in line def get_cmake_define(line: str, confdata: 'ConfigurationData') -> str: - arr = line.split() + arr = line[1:].split() if cmake_bool_define: (v, desc) = confdata.get(arr[1]) @@ -1361,7 +1361,7 @@ def do_define_cmake(regex: T.Pattern[str], line: str, confdata: 'ConfigurationDa define_value += [token] return ' '.join(define_value) - arr = line.split() + arr = line[1:].split() if len(arr) != 2 and subproject is not None: from ..interpreterbase.decorators import FeatureNew @@ -1455,7 +1455,7 @@ def do_conf_str_cmake(src: str, data: T.List[str], confdata: 'ConfigurationData' regex = get_variable_regex(variable_format) - search_token = '#cmakedefine' + search_token = 'cmakedefine' result: T.List[str] = [] missing_variables: T.Set[str] = set() @@ -1463,7 +1463,8 @@ def do_conf_str_cmake(src: str, data: T.List[str], confdata: 'ConfigurationData' # during substitution so we can warn the user to use the `copy:` kwarg. confdata_useless = not confdata.keys() for line in data: - if line.lstrip().startswith(search_token): + stripped_line = line.lstrip() + if len(stripped_line) >= 2 and stripped_line[0] == '#' and stripped_line[1:].lstrip().startswith(search_token): confdata_useless = False line = do_define_cmake(regex, line, confdata, at_only, subproject) else: -- cgit v1.2.3