From bb1745c614def21f4e44bf0be90a9520e8181794 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Tue, 10 Dec 2024 18:41:50 +0100 Subject: do @ variable substitution when parsing cmake format the upstream behavior of configure_file in cmake parses both @VAR@ and ${VAR} and only supports disabling the bracket variables through the `@ONLY` argument, meson needs to follow this behavior for compatibility --- mesonbuild/utils/universal.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index ea49a065a..f26a9a3de 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -1257,6 +1257,9 @@ def do_replacement_cmake(regex: T.Pattern[str], line: str, at_only: bool, else: # Template variable to be replaced varname = match.group('variable') + if not varname: + varname = match.group('cmake_variable') + var_str = '' if varname in confdata: var, _ = confdata.get(varname) @@ -1358,11 +1361,15 @@ def get_variable_regex(variable_format: Literal['meson', 'cmake', 'cmake@'] = 'm ''', re.VERBOSE) else: regex = re.compile(r''' - (?:\\\\)+(?=\\?\$) # Match multiple backslashes followed by a dollar sign + (?:\\\\)+(?=\\?(\$|@)) # Match multiple backslashes followed by a dollar sign or an @ symbol | # OR \\\${ # Match a backslash followed by a dollar sign and an opening curly brace | # OR - \${(?P[-a-zA-Z0-9_]+)} # Match a variable enclosed in curly braces and capture the variable name + \${(?P[-a-zA-Z0-9_]+)} # Match a variable enclosed in curly braces and capture the variable name + | # OR + (?[-a-zA-Z0-9_]+)@ # Match a variable enclosed in @ symbols and capture the variable name; no matches beginning with '\@' + | # OR + (?P\\@[-a-zA-Z0-9_]+\\@) # Match an escaped variable enclosed in @ symbols ''', re.VERBOSE) return regex -- cgit v1.2.3