Skip to content

Commit 1fd839e

Browse files
Jan200101jpakkane
authored andcommitted
handle spacing between # and cmakedefine
just as with C defines cmakedefine supports a variable amount of whitespace between the # symbol and the actual token.
1 parent b474a8f commit 1fd839e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mesonbuild/utils/universal.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ def do_define_cmake(regex: T.Pattern[str], line: str, confdata: 'ConfigurationDa
13461346
cmake_bool_define = 'cmakedefine01' in line
13471347

13481348
def get_cmake_define(line: str, confdata: 'ConfigurationData') -> str:
1349-
arr = line.split()
1349+
arr = line[1:].split()
13501350

13511351
if cmake_bool_define:
13521352
(v, desc) = confdata.get(arr[1])
@@ -1361,7 +1361,7 @@ def get_cmake_define(line: str, confdata: 'ConfigurationData') -> str:
13611361
define_value += [token]
13621362
return ' '.join(define_value)
13631363

1364-
arr = line.split()
1364+
arr = line[1:].split()
13651365

13661366
if len(arr) != 2 and subproject is not None:
13671367
from ..interpreterbase.decorators import FeatureNew
@@ -1455,15 +1455,16 @@ def do_conf_str_cmake(src: str, data: T.List[str], confdata: 'ConfigurationData'
14551455

14561456
regex = get_variable_regex(variable_format)
14571457

1458-
search_token = '#cmakedefine'
1458+
search_token = 'cmakedefine'
14591459

14601460
result: T.List[str] = []
14611461
missing_variables: T.Set[str] = set()
14621462
# Detect when the configuration data is empty and no tokens were found
14631463
# during substitution so we can warn the user to use the `copy:` kwarg.
14641464
confdata_useless = not confdata.keys()
14651465
for line in data:
1466-
if line.lstrip().startswith(search_token):
1466+
stripped_line = line.lstrip()
1467+
if len(stripped_line) >= 2 and stripped_line[0] == '#' and stripped_line[1:].lstrip().startswith(search_token):
14671468
confdata_useless = False
14681469
line = do_define_cmake(regex, line, confdata, at_only, subproject)
14691470
else:

0 commit comments

Comments
 (0)