CMake: pro2cmake.py: Better mapping of complex conditions

.pro-files support things like contains(Foo, bar), etc.

Map that in such a way that only one identifier will be visible to
CMake to unconfuse the logic handling on that side. These conditions
will need manual fixup later!

Change-Id: Id4946e694a9adccf9f54bcce26a6c227cd921007
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
Tobias Hunger 2019-02-07 15:28:49 +01:00
parent d796410045
commit 199cce0c20

View File

@ -588,11 +588,11 @@ def parseProFile(file: str, *, debug=False):
def map_condition(condition: str) -> str:
re.sub(r'if\s*\((.*?)\)', r'\1', condition)
re.sub(r'(^|[^a-zA-Z0-9_])isEmpty\s*\((.*?)\)', r'\2_ISEMPTY', condition)
re.sub(r'(^|[^a-zA-Z0-9_])contains\s*\((.*?), (.*)?\)',
r'\2___contains___\3', condition)
re.sub(r'\s*==\s*', '___STREQUAL___', condition)
condition = re.sub(r'\bif\s*\((.*?)\)', r'\1', condition)
condition = re.sub(r'\bisEmpty\s*\((.*?)\)', r'\1_ISEMPTY', condition)
condition = re.sub(r'\bcontains\s*\((.*?), (.*)?\)',
r'\1___contains___\2', condition)
condition = re.sub(r'\s*==\s*', '___STREQUAL___', condition)
condition = condition.replace('*', '_x_')
condition = condition.replace('.$$', '__ss_')