summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2025-05-31 17:25:55 +0200
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-06-08 23:51:31 +0300
commit1fd839ef555ec3a8d0237fc6b1d5f4be93f0ca29 (patch)
tree442dd8516da0b206ac81be412888140eebe1050b
parentb474a8f715f51c22698caa999c40d86d9ad6ab86 (diff)
downloadmeson-1fd839ef555ec3a8d0237fc6b1d5f4be93f0ca29.tar.gz
handle spacing between # and cmakedefine
just as with C defines cmakedefine supports a variable amount of whitespace between the # symbol and the actual token.
-rw-r--r--mesonbuild/utils/universal.py9
1 files 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: