cmake scripts: flake8 cleanup

At least setting the example install dir looks like a bug.

Change-Id: Ibcced739d05de5445fa455e509cc6f42b9ed935b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Frederik Gladhorn 2019-10-10 15:10:37 +02:00 committed by Alexandru Croitor
parent 6167031ecc
commit 174b17d65d
4 changed files with 20 additions and 16 deletions

View File

@ -37,7 +37,6 @@ import sys
import re import re
import io import io
import glob import glob
import collections
from condition_simplifier import simplify_condition from condition_simplifier import simplify_condition
from condition_simplifier_cache import set_condition_simplified_cache_enabled from condition_simplifier_cache import set_condition_simplified_cache_enabled
@ -618,6 +617,7 @@ class AddOperation(Operation):
def __repr__(self): def __repr__(self):
return f"+({self._dump()})" return f"+({self._dump()})"
class UniqueAddOperation(Operation): class UniqueAddOperation(Operation):
def process( def process(
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]] self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
@ -631,6 +631,7 @@ class UniqueAddOperation(Operation):
def __repr__(self): def __repr__(self):
return f"*({self._dump()})" return f"*({self._dump()})"
class ReplaceOperation(Operation): class ReplaceOperation(Operation):
def process( def process(
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]] self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
@ -663,6 +664,7 @@ class ReplaceOperation(Operation):
def __repr__(self): def __repr__(self):
return f"*({self._dump()})" return f"*({self._dump()})"
class SetOperation(Operation): class SetOperation(Operation):
def process( def process(
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]] self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
@ -1289,6 +1291,7 @@ _path_replacements = {
"$$OUT_PWD": "${CMAKE_CURRENT_BINARY_DIR}", "$$OUT_PWD": "${CMAKE_CURRENT_BINARY_DIR}",
} }
def replace_path_constants(path: str, scope: Scope) -> str: def replace_path_constants(path: str, scope: Scope) -> str:
""" Clean up DESTDIR and target.path """ """ Clean up DESTDIR and target.path """
if path.startswith("./"): if path.startswith("./"):
@ -1970,6 +1973,7 @@ def write_statecharts(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0
cm_fh.write(f"{spaces(indent)}{f}\n") cm_fh.write(f"{spaces(indent)}{f}\n")
cm_fh.write(")\n") cm_fh.write(")\n")
def write_qlalrsources(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0): def write_qlalrsources(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
sources = scope.get_files("QLALRSOURCES", use_vpath=True) sources = scope.get_files("QLALRSOURCES", use_vpath=True)
if not sources: if not sources:
@ -1982,6 +1986,7 @@ def write_qlalrsources(cm_fh: IO[str], target: str, scope: Scope, indent: int =
cm_fh.write(f"{spaces(indent)}\"\"\n") cm_fh.write(f"{spaces(indent)}\"\"\n")
cm_fh.write(")\n") cm_fh.write(")\n")
def write_repc_files(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0): def write_repc_files(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
for t in ["SOURCE", "REPLICA", "MERGED"]: for t in ["SOURCE", "REPLICA", "MERGED"]:
sources = scope.get_files("REPC_" + t, use_vpath=True) sources = scope.get_files("REPC_" + t, use_vpath=True)
@ -1993,6 +1998,7 @@ def write_repc_files(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0)
cm_fh.write(f"{spaces(indent)}{f}\n") cm_fh.write(f"{spaces(indent)}{f}\n")
cm_fh.write(")\n") cm_fh.write(")\n")
def expand_project_requirements(scope: Scope, skip_message: bool = False) -> str: def expand_project_requirements(scope: Scope, skip_message: bool = False) -> str:
requirements = "" requirements = ""
for requirement in scope.get("_REQUIREMENTS"): for requirement in scope.get("_REQUIREMENTS"):
@ -2637,7 +2643,7 @@ def write_example(
example_install_dir = scope.get_string('target.path') example_install_dir = scope.get_string('target.path')
if not example_install_dir: if not example_install_dir:
example_install = 'examples' example_install_dir = 'examples'
example_install_dir = example_install_dir.replace('$$[QT_INSTALL_EXAMPLES]', 'examples') example_install_dir = example_install_dir.replace('$$[QT_INSTALL_EXAMPLES]', 'examples')
cm_fh.write( cm_fh.write(
@ -2717,9 +2723,7 @@ def write_example(
else: else:
add_target = f'add_{"qt_gui_" if gui else ""}executable({binary_name}' add_target = f'add_{"qt_gui_" if gui else ""}executable({binary_name}'
write_all_source_file_lists(cm_fh, scope, add_target, indent=0) write_all_source_file_lists(cm_fh, scope, add_target, indent=0)
cm_fh.write(")\n") cm_fh.write(")\n")
for scope in scopes: for scope in scopes: