diff options
| author | Jan200101 <sentrycraft123@gmail.com> | 2024-12-10 18:41:50 +0100 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2024-12-19 09:45:19 -0800 |
| commit | bb1745c614def21f4e44bf0be90a9520e8181794 (patch) | |
| tree | e0c75aad0450697d0a2e5376ee400b4aedc6a901 /mesonbuild/utils | |
| parent | 1c8b523c86f9c2b9ed71104334a1bad8c41079cf (diff) | |
| download | meson-bb1745c614def21f4e44bf0be90a9520e8181794.tar.gz | |
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
Diffstat (limited to 'mesonbuild/utils')
| -rw-r--r-- | mesonbuild/utils/universal.py | 11 |
1 files 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<variable>[-a-zA-Z0-9_]+)} # Match a variable enclosed in curly braces and capture the variable name + \${(?P<cmake_variable>[-a-zA-Z0-9_]+)} # Match a variable enclosed in curly braces and capture the variable name + | # OR + (?<!\\)@(?P<variable>[-a-zA-Z0-9_]+)@ # Match a variable enclosed in @ symbols and capture the variable name; no matches beginning with '\@' + | # OR + (?P<escaped>\\@[-a-zA-Z0-9_]+\\@) # Match an escaped variable enclosed in @ symbols ''', re.VERBOSE) return regex |
