diff options
author | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2019-10-09 10:54:00 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2019-10-09 11:30:30 +0000 |
commit | c0618eb5835547250a6b01c7c4d6b8d921e45ddc (patch) | |
tree | cd8db9d4915bdde51e6c107b68cf56bcb987f372 | |
parent | 03f365f93e8dab6bcd8473b5f5ba172bab200e1f (diff) |
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>
-rwxr-xr-x | util/cmake/pro2cmake.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 4f8c158cc1..9308118729 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, ) |