From 0a9e5e139a2c23553f4046897c3be4b1df3dfdfa Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 22 Jan 2019 14:23:59 +0100 Subject: [PATCH] CMake: pro2cmake.py: Fix handling of complex else branches Return the current scope's condition, not the total condition from recursive_evaluate_scope. That is the part the "else" referrs to. The parent_condition stays identical for all branches, so that should not get negated. Change-Id: I0da91483d4d748d01a29ac16890d709d8d659843 Reviewed-by: Simon Hausmann --- util/cmake/pro2cmake.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 3130aeea02a..114677e86e4 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -718,7 +718,8 @@ def write_ignored_keys(scope: Scope, ignored_keys, indent) -> str: def recursive_evaluate_scope(scope: Scope, parent_condition: str = '', previous_condition: str = '') -> str: - total_condition = scope.condition() + current_condition = scope.condition() + total_condition = current_condition if total_condition == 'else': assert previous_condition, \ "Else branch without previous condition in: %s" % scope.file() @@ -753,7 +754,7 @@ def recursive_evaluate_scope(scope: Scope, parent_condition: str = '', prev_condition = recursive_evaluate_scope(c, total_condition, prev_condition) - return total_condition + return current_condition def write_extend_target(cm_fh: typing.IO[str], target: str,