From c0618eb5835547250a6b01c7c4d6b8d921e45ddc Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 9 Oct 2019 10:54:00 +0200 Subject: [PATCH] cmake scripts: Do not add empty child conditions into condition list c.condition can be None, there is no point in adding it into the set of conditions. An example is tests/auto/corelib/codecs/qtextcodec/test.pro Initializing the set to an empty set instead of None makes mypy happy, since we could otherwise end up passing None where frozenset was expected. Change-Id: If88a86d810b4c55aae7f1ee97a62db559abfc86d Reviewed-by: Alexandru Croitor --- util/cmake/pro2cmake.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 4f8c158cc1c..93081187299 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -1671,7 +1671,7 @@ def handle_subdir( cm_fh: IO[str], *, indent: int = 0, - current_conditions: FrozenSet[str] = None, + current_conditions: FrozenSet[str] = frozenset(), is_example: bool = False, ): for sd in scope.get_files("SUBDIRS"): @@ -1705,12 +1705,16 @@ def handle_subdir( for c in scope.children: # Use total_condition for 'else' conditions, otherwise just use the regular value to # simplify the logic. + child_conditions = current_conditions child_condition = c.total_condition if c.condition == "else" else c.condition + if child_condition: + child_conditions = frozenset((*child_conditions, child_condition)) + handle_subdir_helper( c, cm_fh, indent=indent + 1, - current_conditions=frozenset((*current_conditions, child_condition)), + current_conditions=child_conditions, is_example=is_example, )