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 <alexandru.croitor@qt.io>
This commit is contained in:
Frederik Gladhorn 2019-10-09 10:54:00 +02:00
parent 03f365f93e
commit c0618eb583

View File

@ -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,
)