From 9ec3b99a4fd61ba928b3534dd18c1abd8e5b09db Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 24 Oct 2021 21:03:11 -0400 Subject: [PATCH] do not repeat magic regexes for cmake define replacements We already have this magic string in mesonlib, and this should always have used the cmake@ format which is identical to the meson format other than the regex. --- mesonbuild/modules/cmake.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py index 51ee9ee05..76a7b9bf4 100644 --- a/mesonbuild/modules/cmake.py +++ b/mesonbuild/modules/cmake.py @@ -310,10 +310,10 @@ class CmakeModule(ExtensionModule): raise mesonlib.MesonException(f'Could not read input file {infile}: {e!s}') result = [] - regex = re.compile(r'(?:\\\\)+(?=\\?@)|\\@|@([-a-zA-Z0-9_]+)@') + regex = mesonlib.get_variable_regex('cmake@') for line in data: line = line.replace('@PACKAGE_INIT@', package_init) - line, _missing = mesonlib.do_replacement(regex, line, 'meson', confdata) + line, _missing = mesonlib.do_replacement(regex, line, 'cmake@', confdata) result.append(line)