From a5f51e489885babf48cbc3fd224e1492a02bd60f Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 1 Mar 2019 15:00:19 +0100 Subject: [PATCH] CMake: pro2cmake.py: Automatically map equals(QT_ARCH, "foo") in conditions Change-Id: I10d8001ba8330deaa622ef8c499b2b6fe438e28a Reviewed-by: Alexandru Croitor --- util/cmake/pro2cmake.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index d21ae36a824..7c00afad1cb 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -656,9 +656,9 @@ def parseProFile(file: str, *, debug=False): def map_condition(condition: str) -> str: 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*\((.*?), (.*)?\)', + condition = re.sub(r'\bcontains\s*\((.*?),\s*"?(.*?)"?\)', r'\1___contains___\2', condition) - condition = re.sub(r'\bequals\s*\((.*?), (.*)?\)', + condition = re.sub(r'\bequals\s*\((.*?),\s*"?(.*?)"?\)', r'\1___equals___\2', condition) condition = re.sub(r'\s*==\s*', '___STREQUAL___', condition) @@ -1070,6 +1070,14 @@ def recursive_evaluate_scope(scope: Scope, parent_condition: str = '', return current_condition +def map_to_cmake_condition(condition: str) -> str: + condition = re.sub(r'\bQT_ARCH___equals___([a-zA-Z_0-9]*)', + r'(TEST_architecture STREQUAL "\1")', condition) + condition = re.sub(r'\bQT_ARCH___contains___([a-zA-Z_0-9]*)', + r'(TEST_architecture STREQUAL "\1")', condition) + return condition + + def write_extend_target(cm_fh: typing.IO[str], target: str, scope: Scope, indent: int = 0): extend_qt_io_string = io.StringIO() @@ -1083,7 +1091,7 @@ def write_extend_target(cm_fh: typing.IO[str], target: str, extend_scope = '\n{}extend_target({} CONDITION {}\n' \ '{}{})\n'.format(spaces(indent), target, - scope.total_condition, + map_to_cmake_condition(scope.total_condition), extend_qt_string, ignored_keys_report) if not extend_qt_string: