diff options
author | Leander Beernaert <leander.beernaert@qt.io> | 2019-10-15 10:48:53 +0200 |
---|---|---|
committer | Leander Beernaert <leander.beernaert@qt.io> | 2019-10-15 09:07:39 +0000 |
commit | 355a00270437d76fb98c14ac672ee662be0c06f5 (patch) | |
tree | 30172c7d5539b42c83d5d2cb79cd993dd33f6f36 | |
parent | a3fd3c193d962fdeba32861a91c040d8b3d715a7 (diff) |
Fix add_qt_resource condition scopes
Calls to add_qt_resource from extend_target were not being wrapped in
a condition scope.
Change-Id: I78cf889fcf4663660fd870bfb93eec90a4ca1c47
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rwxr-xr-x | util/cmake/pro2cmake.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 420df3011d..5041519348 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -1971,9 +1971,10 @@ def write_resources(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0, ) if qrc_output: - cm_fh.write("\n# Resources:\n") + str_indent = spaces(indent) + cm_fh.write(f"\n{str_indent}# Resources:\n") for line in qrc_output.split("\n"): - cm_fh.write(f"{' ' * indent}{line}\n") + cm_fh.write(f"{str_indent}{line}\n") def write_statecharts(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0, is_example=False): @@ -2043,9 +2044,12 @@ def write_extend_target(cm_fh: IO[str], target: str, scope: Scope, indent: int = extend_qt_string = extend_qt_io_string.getvalue() assert scope.total_condition, "Cannot write CONDITION when scope.condition is None" + + condition = map_to_cmake_condition(scope.total_condition) + extend_scope = ( f"\n{ind}extend_target({target} CONDITION" - f" {map_to_cmake_condition(scope.total_condition)}\n" + f" {condition}\n" f"{extend_qt_string}{ind})\n" ) @@ -2054,8 +2058,13 @@ def write_extend_target(cm_fh: IO[str], target: str, scope: Scope, indent: int = cm_fh.write(extend_scope) - write_resources(cm_fh, target, scope, indent) - + io_string = io.StringIO() + write_resources(io_string, target, scope, indent + 1) + resource_string = io_string.getvalue() + if len(resource_string) != 0: + resource_string = resource_string.strip('\n').rstrip(f'\n{spaces(indent + 1)}') + cm_fh.write(f"\n{spaces(indent)}if({condition})\n{resource_string}") + cm_fh.write(f"\n{spaces(indent)}endif()\n") def flatten_scopes(scope: Scope) -> List[Scope]: result = [scope] # type: List[Scope] |