From 5c758763bf0a8bf63099701dfa96525a7ae7f048 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Tue, 10 Dec 2024 18:41:50 +0100 Subject: [PATCH] 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 88d8e1f891c7..41b21212fa02 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -1189,6 +1189,9 @@ def variable_replace(match: T.Match[str]) -> str: 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) @@ -1280,11 +1283,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