aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2018-10-04 00:07:44 -0400
committerXavier Claessens <xclaesse@gmail.com>2020-09-13 13:54:47 -0400
commit9d338200dacdf24c50259c309380200f8a53d5b5 (patch)
tree8e268a9357119265f11b30791f56e8e09fec393e /mesonbuild/mesonlib.py
parent19696c3dcdb379f4c5b88457f43242f2d33427a0 (diff)
downloadmeson-9d338200dacdf24c50259c309380200f8a53d5b5.zip
meson-9d338200dacdf24c50259c309380200f8a53d5b5.tar.gz
meson-9d338200dacdf24c50259c309380200f8a53d5b5.tar.bz2
external-project: New module to build configure/make projects
This adds an experimental meson module to build projects with other build systems. Closes: #4316
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r--mesonbuild/mesonlib.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 943aa42..c6cbbd6 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -971,6 +971,17 @@ def do_define(regex: T.Pattern[str], line: str, confdata: 'ConfigurationData', v
else:
raise MesonException('#mesondefine argument "%s" is of unknown type.' % varname)
+def get_variable_regex(variable_format: str = 'meson') -> T.Pattern[str]:
+ # Only allow (a-z, A-Z, 0-9, _, -) as valid characters for a define
+ # Also allow escaping '@' with '\@'
+ if variable_format in ['meson', 'cmake@']:
+ regex = re.compile(r'(?:\\\\)+(?=\\?@)|\\@|@([-a-zA-Z0-9_]+)@')
+ elif variable_format == 'cmake':
+ regex = re.compile(r'(?:\\\\)+(?=\\?\$)|\\\${|\${([-a-zA-Z0-9_]+)}')
+ else:
+ raise MesonException('Format "{}" not handled'.format(variable_format))
+ return regex
+
def do_conf_str (data: list, confdata: 'ConfigurationData', variable_format: str,
encoding: str = 'utf-8') -> T.Tuple[T.List[str],T.Set[str], bool]:
def line_is_valid(line : str, variable_format: str) -> bool:
@@ -982,14 +993,7 @@ def do_conf_str (data: list, confdata: 'ConfigurationData', variable_format: str
return False
return True
- # Only allow (a-z, A-Z, 0-9, _, -) as valid characters for a define
- # Also allow escaping '@' with '\@'
- if variable_format in ['meson', 'cmake@']:
- regex = re.compile(r'(?:\\\\)+(?=\\?@)|\\@|@([-a-zA-Z0-9_]+)@')
- elif variable_format == 'cmake':
- regex = re.compile(r'(?:\\\\)+(?=\\?\$)|\\\${|\${([-a-zA-Z0-9_]+)}')
- else:
- raise MesonException('Format "{}" not handled'.format(variable_format))
+ regex = get_variable_regex(variable_format)
search_token = '#mesondefine'
if variable_format != 'meson':