From 706e7fdb0ca5ab2beabecf39809c032bd98ac84a Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Fri, 8 Nov 2019 10:37:38 +0100 Subject: [PATCH] Add generic lessThan|greaterThan|equal condition map to pro2cmake.py Change-Id: Ib611aa9a808a05b38a83bd3fd7d95081bdf6e256 Reviewed-by: Alexandru Croitor --- util/cmake/pro2cmake.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 07f1fe26df3..87e593a4236 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -1238,6 +1238,24 @@ def map_condition(condition: str) -> str: pattern = r"(equals|greaterThan|lessThan)\(WINDOWS_SDK_VERSION,[ ]*([0-9]+)\)" condition = re.sub(pattern, windows_sdk_version_handler, condition) + # Generic lessThan|equals|lessThan() + + def generic_version_handler(match_obj: Match): + operator = match_obj.group(1) + if operator == "equals": + operator = "EQUAL" + elif operator == "greaterThan": + operator = "GREATER" + elif operator == "lessThan": + operator = "LESS" + + variable = match_obj.group(2) + version = match_obj.group(3) + return f"({variable} {operator} {version})" + + pattern = r"(equals|greaterThan|lessThan)\((.+),[ ]*([0-9]+)\)" + condition = re.sub(pattern, generic_version_handler, condition) + # Handle if(...) conditions. condition = unwrap_if(condition)