Adapt string formatting in util/cmake
Second and final batch of changes related to string formatting styling. Change-Id: Ifc0e999ee95fe52fd076ac2f001b4a58f82ab5be Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
ffe0889413
commit
cfa3c64625
@ -306,7 +306,6 @@ add_qt_simd_part(Gui SIMD arch_haswell
|
|||||||
|
|
||||||
|
|
||||||
#### Keys ignored in scope 1:.:.:gui.pro:<TRUE>:
|
#### Keys ignored in scope 1:.:.:gui.pro:<TRUE>:
|
||||||
# MODULE_PLUGIN_TYPES = "platforms" "platforms/darwin" "xcbglintegrations" "platformthemes" "platforminputcontexts" "generic" "iconengines" "imageformats" "egldeviceintegrations"
|
|
||||||
# QMAKE_DYNAMIC_LIST_FILE = "$$PWD/QtGui.dynlist"
|
# QMAKE_DYNAMIC_LIST_FILE = "$$PWD/QtGui.dynlist"
|
||||||
# QMAKE_LIBS = "$$QMAKE_LIBS_GUI"
|
# QMAKE_LIBS = "$$QMAKE_LIBS_GUI"
|
||||||
# _LOADED = "qt_module" "cmake_functions"
|
# _LOADED = "qt_module" "cmake_functions"
|
||||||
@ -620,7 +619,7 @@ extend_target(Gui CONDITION WASM
|
|||||||
|
|
||||||
|
|
||||||
qt_create_tracepoints(Gui qtgui.tracepoints)
|
qt_create_tracepoints(Gui qtgui.tracepoints)
|
||||||
add_qt_docs(Gui,
|
add_qt_docs(Gui
|
||||||
doc/qtgui.qdocconf
|
doc/qtgui.qdocconf
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ def map_tests(test: str) -> str:
|
|||||||
if test in testmap:
|
if test in testmap:
|
||||||
return testmap.get(test, None)
|
return testmap.get(test, None)
|
||||||
if test in knownTests:
|
if test in knownTests:
|
||||||
return "TEST_{}".format(featureName(test))
|
return f"TEST_{featureName(test)}"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ def cm(ctx, *output):
|
|||||||
def readJsonFromDir(dir):
|
def readJsonFromDir(dir):
|
||||||
path = posixpath.join(dir, "configure.json")
|
path = posixpath.join(dir, "configure.json")
|
||||||
|
|
||||||
print("Reading {}...".format(path))
|
print(f"Reading {path}...")
|
||||||
assert posixpath.exists(path)
|
assert posixpath.exists(path)
|
||||||
|
|
||||||
parser = json_parser.QMakeSpecificJSONParser()
|
parser = json_parser.QMakeSpecificJSONParser()
|
||||||
@ -169,14 +169,14 @@ def processFiles(ctx, data):
|
|||||||
def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set):
|
def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set):
|
||||||
newlib = find_3rd_party_library_mapping(lib)
|
newlib = find_3rd_party_library_mapping(lib)
|
||||||
if not newlib:
|
if not newlib:
|
||||||
print(' XXXX Unknown library "{}".'.format(lib))
|
print(f' XXXX Unknown library "{lib}".')
|
||||||
return
|
return
|
||||||
|
|
||||||
if newlib.packageName is None:
|
if newlib.packageName is None:
|
||||||
print(' **** Skipping library "{}" -- was masked.'.format(lib))
|
print(f' **** Skipping library "{lib}" -- was masked.')
|
||||||
return
|
return
|
||||||
|
|
||||||
print(" mapped library {} to {}.".format(lib, newlib.targetName))
|
print(f" mapped library {lib} to {newlib.targetName}.")
|
||||||
|
|
||||||
# Avoid duplicate find_package calls.
|
# Avoid duplicate find_package calls.
|
||||||
if newlib.targetName in cmake_find_packages_set:
|
if newlib.targetName in cmake_find_packages_set:
|
||||||
@ -194,7 +194,7 @@ def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set):
|
|||||||
feature_data = data["features"][feature]
|
feature_data = data["features"][feature]
|
||||||
if (
|
if (
|
||||||
"condition" in feature_data
|
"condition" in feature_data
|
||||||
and "libs.{}".format(lib) in feature_data["condition"]
|
and f"libs.{lib}" in feature_data["condition"]
|
||||||
and "emitIf" in feature_data
|
and "emitIf" in feature_data
|
||||||
and "config." in feature_data["emitIf"]
|
and "config." in feature_data["emitIf"]
|
||||||
):
|
):
|
||||||
@ -212,8 +212,9 @@ def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set):
|
|||||||
def lineify(label, value, quote=True):
|
def lineify(label, value, quote=True):
|
||||||
if value:
|
if value:
|
||||||
if quote:
|
if quote:
|
||||||
return ' {} "{}"\n'.format(label, value.replace('"', '\\"'))
|
escaped_value = value.replace('"', '\\"')
|
||||||
return " {} {}\n".format(label, value)
|
return f' {label} "{escaped_value}"\n'
|
||||||
|
return f" {label} {value}\n"
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
@ -267,12 +268,10 @@ def map_condition(condition):
|
|||||||
if feature in mapped_features:
|
if feature in mapped_features:
|
||||||
substitution = mapped_features.get(feature)
|
substitution = mapped_features.get(feature)
|
||||||
else:
|
else:
|
||||||
substitution = "QT_FEATURE_{}".format(featureName(match.group(2)))
|
substitution = f"QT_FEATURE_{featureName(match.group(2))}"
|
||||||
|
|
||||||
elif match.group(1) == "subarch":
|
elif match.group(1) == "subarch":
|
||||||
substitution = "TEST_arch_{}_subarch_{}".format(
|
substitution = f"TEST_arch_{'${TEST_architecture_arch}'}_subarch_{match.group(2)}"
|
||||||
"${TEST_architecture_arch}", match.group(2)
|
|
||||||
)
|
|
||||||
|
|
||||||
elif match.group(1) == "call":
|
elif match.group(1) == "call":
|
||||||
if match.group(2) == "crossCompile":
|
if match.group(2) == "crossCompile":
|
||||||
@ -282,12 +281,12 @@ def map_condition(condition):
|
|||||||
substitution = map_tests(match.group(2))
|
substitution = map_tests(match.group(2))
|
||||||
|
|
||||||
elif match.group(1) == "input":
|
elif match.group(1) == "input":
|
||||||
substitution = "INPUT_{}".format(featureName(match.group(2)))
|
substitution = f"INPUT_{featureName(match.group(2))}"
|
||||||
|
|
||||||
elif match.group(1) == "config":
|
elif match.group(1) == "config":
|
||||||
substitution = map_platform(match.group(2))
|
substitution = map_platform(match.group(2))
|
||||||
elif match.group(1) == "module":
|
elif match.group(1) == "module":
|
||||||
substitution = "TARGET {}".format(map_qt_library(match.group(2)))
|
substitution = f"TARGET {map_qt_library(match.group(2))}"
|
||||||
|
|
||||||
elif match.group(1) == "arch":
|
elif match.group(1) == "arch":
|
||||||
if match.group(2) == "i386":
|
if match.group(2) == "i386":
|
||||||
@ -306,7 +305,7 @@ def map_condition(condition):
|
|||||||
substitution = "(TEST_architecture_arch STREQUAL mips)"
|
substitution = "(TEST_architecture_arch STREQUAL mips)"
|
||||||
|
|
||||||
if substitution is None:
|
if substitution is None:
|
||||||
print(' XXXX Unknown condition "{}".'.format(match.group(0)))
|
print(f' XXXX Unknown condition "{match.group(0)}"')
|
||||||
has_failed = True
|
has_failed = True
|
||||||
else:
|
else:
|
||||||
mapped_condition += condition[last_pos : match.start(1)] + substitution
|
mapped_condition += condition[last_pos : match.start(1)] + substitution
|
||||||
@ -919,7 +918,7 @@ def parseFeature(ctx, feature, data, cm_fh):
|
|||||||
if outputArgs.get("negative", False):
|
if outputArgs.get("negative", False):
|
||||||
cm_fh.write(" NEGATE")
|
cm_fh.write(" NEGATE")
|
||||||
if outputArgs.get("value") is not None:
|
if outputArgs.get("value") is not None:
|
||||||
cm_fh.write(' VALUE "{}"'.format(outputArgs.get("value")))
|
cm_fh.write(f' VALUE "{outputArgs.get("value")}"')
|
||||||
cm_fh.write(")\n")
|
cm_fh.write(")\n")
|
||||||
|
|
||||||
|
|
||||||
@ -1015,7 +1014,7 @@ def main():
|
|||||||
|
|
||||||
directory = sys.argv[1]
|
directory = sys.argv[1]
|
||||||
|
|
||||||
print("Processing: {}.".format(directory))
|
print(f"Processing: {directory}.")
|
||||||
|
|
||||||
data = readJsonFromDir(directory)
|
data = readJsonFromDir(directory)
|
||||||
processJson(directory, {}, data)
|
processJson(directory, {}, data)
|
||||||
|
@ -40,7 +40,7 @@ class LibraryMapping:
|
|||||||
resultVariable: typing.Optional[str] = None,
|
resultVariable: typing.Optional[str] = None,
|
||||||
extra: typing.List[str] = [],
|
extra: typing.List[str] = [],
|
||||||
appendFoundSuffix: bool = True,
|
appendFoundSuffix: bool = True,
|
||||||
emit_if: str = ""
|
emit_if: str = "",
|
||||||
) -> None:
|
) -> None:
|
||||||
self.soName = soName
|
self.soName = soName
|
||||||
self.packageName = packageName
|
self.packageName = packageName
|
||||||
@ -497,7 +497,7 @@ _library_map = [
|
|||||||
LibraryMapping("tiff", "TIFF", "TIFF::TIFF"),
|
LibraryMapping("tiff", "TIFF", "TIFF::TIFF"),
|
||||||
LibraryMapping("webp", "WrapWebP", "WrapWebP::WrapWebP"),
|
LibraryMapping("webp", "WrapWebP", "WrapWebP::WrapWebP"),
|
||||||
LibraryMapping("jasper", "WrapJasper", "WrapJasper::WrapJasper"),
|
LibraryMapping("jasper", "WrapJasper", "WrapJasper::WrapJasper"),
|
||||||
LibraryMapping('sdl2', 'SDL2', 'SDL2::SDL2'),
|
LibraryMapping("sdl2", "SDL2", "SDL2::SDL2"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -656,26 +656,22 @@ def generate_find_package_info(
|
|||||||
|
|
||||||
if use_qt_find_package:
|
if use_qt_find_package:
|
||||||
if extra:
|
if extra:
|
||||||
result = "{}qt_find_package({} {})\n".format(ind, lib.packageName, " ".join(extra))
|
result = f"{ind}qt_find_package({lib.packageName} {' '.join(extra)})\n"
|
||||||
else:
|
else:
|
||||||
result = "{}qt_find_package({})\n".format(ind, lib.packageName)
|
result = f"{ind}qt_find_package({lib.packageName})\n"
|
||||||
|
|
||||||
if isRequired:
|
if isRequired:
|
||||||
result += "{}set_package_properties({} PROPERTIES TYPE REQUIRED)\n".format(
|
result += f"{ind}set_package_properties({lib.packageName} PROPERTIES TYPE REQUIRED)\n"
|
||||||
ind, lib.packageName
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
if extra:
|
if extra:
|
||||||
result = "{}find_package({} {})\n".format(ind, lib.packageName, " ".join(extra))
|
result = f"{ind}find_package({lib.packageName} {' '.join(extra)})\n"
|
||||||
else:
|
else:
|
||||||
result = "{}find_package({})\n".format(ind, lib.packageName)
|
result = f"{ind}find_package({lib.packageName})\n"
|
||||||
|
|
||||||
# If a package should be found only in certain conditions, wrap
|
# If a package should be found only in certain conditions, wrap
|
||||||
# the find_package call within that condition.
|
# the find_package call within that condition.
|
||||||
if emit_if:
|
if emit_if:
|
||||||
result = "if(({emit_if}) OR QT_FIND_ALL_PACKAGES_ALWAYS)\n" "{ind}{result}endif()\n".format(
|
result = f"if(({emit_if}) OR QT_FIND_ALL_PACKAGES_ALWAYS)\n{one_ind}{result}endif()\n"
|
||||||
emit_if=emit_if, result=result, ind=one_ind
|
|
||||||
)
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -191,8 +191,7 @@ def is_example_project(project_file_path: str = "") -> bool:
|
|||||||
# relative to the repo source dir, then it must be an example, but
|
# relative to the repo source dir, then it must be an example, but
|
||||||
# some examples contain 3rdparty libraries that do not need to be
|
# some examples contain 3rdparty libraries that do not need to be
|
||||||
# built as examples.
|
# built as examples.
|
||||||
return (project_relative_path.startswith("examples")
|
return project_relative_path.startswith("examples") and "3rdparty" not in project_relative_path
|
||||||
and "3rdparty" not in project_relative_path)
|
|
||||||
|
|
||||||
|
|
||||||
def find_qmake_conf(project_file_path: str = "") -> Optional[str]:
|
def find_qmake_conf(project_file_path: str = "") -> Optional[str]:
|
||||||
@ -264,7 +263,7 @@ def process_qrc_file(
|
|||||||
lang = resource.get("lang", "")
|
lang = resource.get("lang", "")
|
||||||
prefix = resource.get("prefix", "/")
|
prefix = resource.get("prefix", "/")
|
||||||
if not prefix.startswith("/"):
|
if not prefix.startswith("/"):
|
||||||
prefix = "/" + prefix
|
prefix = f"/{prefix}"
|
||||||
|
|
||||||
full_resource_name = resource_name + (str(resource_count) if resource_count > 0 else "")
|
full_resource_name = resource_name + (str(resource_count) if resource_count > 0 else "")
|
||||||
|
|
||||||
@ -319,10 +318,11 @@ def write_add_qt_resource_call(
|
|||||||
alias = files[source]
|
alias = files[source]
|
||||||
if alias:
|
if alias:
|
||||||
full_source = posixpath.join(base_dir, source)
|
full_source = posixpath.join(base_dir, source)
|
||||||
output += (
|
output += dedent(f"""\
|
||||||
f'set_source_files_properties("{full_source}"\n'
|
set_source_files_properties("{full_source}"
|
||||||
f' PROPERTIES QT_RESOURCE_ALIAS "{alias}"\n)\n'
|
PROPERTIES QT_RESOURCE_ALIAS "{alias}"
|
||||||
)
|
)
|
||||||
|
""")
|
||||||
|
|
||||||
# Quote file paths in case there are spaces.
|
# Quote file paths in case there are spaces.
|
||||||
sorted_files_backup = sorted_files
|
sorted_files_backup = sorted_files
|
||||||
@ -334,7 +334,11 @@ def write_add_qt_resource_call(
|
|||||||
sorted_files.append(f'"{source}"')
|
sorted_files.append(f'"{source}"')
|
||||||
|
|
||||||
file_list = "\n ".join(sorted_files)
|
file_list = "\n ".join(sorted_files)
|
||||||
output += f"set({resource_name}_resource_files\n {file_list}\n)\n\n"
|
output += dedent(f"""\
|
||||||
|
set({resource_name}_resource_files
|
||||||
|
{file_list}
|
||||||
|
)\n
|
||||||
|
""")
|
||||||
file_list = f"${{{resource_name}_resource_files}}"
|
file_list = f"${{{resource_name}_resource_files}}"
|
||||||
if skip_qtquick_compiler:
|
if skip_qtquick_compiler:
|
||||||
output += (
|
output += (
|
||||||
@ -389,27 +393,30 @@ class QmlDir:
|
|||||||
self.designer_supported = False
|
self.designer_supported = False
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
str = "module: {}\n".format(self.module)
|
types_infos_line = " \n".join(self.types_infos)
|
||||||
str += "plugin: {} {}\n".format(self.plugin_name, self.plugin_path)
|
imports_line = " \n".join(self.imports)
|
||||||
str += "classname: {}\n".format(self.classname)
|
string = f"""\
|
||||||
str += "type_infos:{}\n".format(" \n".join(self.type_infos))
|
module: {self.module}
|
||||||
str += "imports:{}\n".format(" \n".join(self.imports))
|
plugin: {self.plugin_name} {self.plugin_path}
|
||||||
str += "dependends: \n"
|
classname: {self.classname}
|
||||||
|
type_infos:{type_infos_line}
|
||||||
|
imports:{imports_line}
|
||||||
|
dependends:
|
||||||
|
"""
|
||||||
for dep in self.depends:
|
for dep in self.depends:
|
||||||
str += " {} {}\n".format(dep[0], dep[1])
|
string += f" {dep[0]} {dep[1]}\n"
|
||||||
str += "designer supported: {}\n".format(self.designer_supported)
|
string += f"designer supported: {self.designer_supported}\n"
|
||||||
str += "type_names:\n"
|
string += "type_names:\n"
|
||||||
for key in self.type_names:
|
for key in self.type_names:
|
||||||
file_info = self.type_names[key]
|
file_info = self.type_names[key]
|
||||||
str += " type:{} version:{} path:{} internal:{} singleton:{}\n".format(
|
string += (
|
||||||
file_info.type_name,
|
f" type:{file_info.type_name} "
|
||||||
file_info.version,
|
f"version:{file_info.version} "
|
||||||
file_info.type_name,
|
f"path:{file_info.file_path} "
|
||||||
file_info.file_path,
|
f"internal:{file_info.internal} "
|
||||||
file_info.internal,
|
f"singleton:{file_info.singleton}\n"
|
||||||
file_info.singleton,
|
|
||||||
)
|
)
|
||||||
return str
|
return string
|
||||||
|
|
||||||
def get_or_create_file_info(self, path: str, type_name: str) -> QmlDirFileInfo:
|
def get_or_create_file_info(self, path: str, type_name: str) -> QmlDirFileInfo:
|
||||||
if not path in self.type_names:
|
if not path in self.type_names:
|
||||||
@ -437,7 +444,7 @@ class QmlDir:
|
|||||||
def from_file(self, path: str):
|
def from_file(self, path: str):
|
||||||
f = open(path, "r")
|
f = open(path, "r")
|
||||||
if not f:
|
if not f:
|
||||||
raise RuntimeError("Failed to open qmldir file at: {}".format(str))
|
raise RuntimeError(f"Failed to open qmldir file at: {path}")
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith("#"):
|
if line.startswith("#"):
|
||||||
continue
|
continue
|
||||||
@ -471,7 +478,7 @@ class QmlDir:
|
|||||||
elif len(entries) == 3:
|
elif len(entries) == 3:
|
||||||
self.handle_file(entries[0], entries[1], entries[2])
|
self.handle_file(entries[0], entries[1], entries[2])
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Uhandled qmldir entry {}".format(line))
|
raise RuntimeError(f"Uhandled qmldir entry {line}")
|
||||||
|
|
||||||
|
|
||||||
def fixup_linecontinuation(contents: str) -> str:
|
def fixup_linecontinuation(contents: str) -> str:
|
||||||
@ -640,9 +647,9 @@ class Operation:
|
|||||||
|
|
||||||
class AddOperation(Operation):
|
class AddOperation(Operation):
|
||||||
def process(
|
def process(
|
||||||
self, key: str, input: List[str], transformer: Callable[[List[str]], List[str]]
|
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
return input + transformer(self._value)
|
return sinput + transformer(self._value)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"+({self._dump()})"
|
return f"+({self._dump()})"
|
||||||
@ -650,9 +657,9 @@ class AddOperation(Operation):
|
|||||||
|
|
||||||
class UniqueAddOperation(Operation):
|
class UniqueAddOperation(Operation):
|
||||||
def process(
|
def process(
|
||||||
self, key: str, input: List[str], transformer: Callable[[List[str]], List[str]]
|
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
result = input
|
result = sinput
|
||||||
for v in transformer(self._value):
|
for v in transformer(self._value):
|
||||||
if v not in result:
|
if v not in result:
|
||||||
result.append(v)
|
result.append(v)
|
||||||
@ -664,14 +671,14 @@ class UniqueAddOperation(Operation):
|
|||||||
|
|
||||||
class SetOperation(Operation):
|
class SetOperation(Operation):
|
||||||
def process(
|
def process(
|
||||||
self, key: str, input: List[str], transformer: Callable[[List[str]], List[str]]
|
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
values = [] # List[str]
|
values = [] # List[str]
|
||||||
for v in self._value:
|
for v in self._value:
|
||||||
if v != f"$${key}":
|
if v != f"$${key}":
|
||||||
values.append(v)
|
values.append(v)
|
||||||
else:
|
else:
|
||||||
values += input
|
values += sinput
|
||||||
|
|
||||||
if transformer:
|
if transformer:
|
||||||
return list(transformer(values))
|
return list(transformer(values))
|
||||||
@ -687,20 +694,20 @@ class RemoveOperation(Operation):
|
|||||||
super().__init__(value)
|
super().__init__(value)
|
||||||
|
|
||||||
def process(
|
def process(
|
||||||
self, key: str, input: List[str], transformer: Callable[[List[str]], List[str]]
|
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
input_set = set(input)
|
sinput_set = set(sinput)
|
||||||
value_set = set(self._value)
|
value_set = set(self._value)
|
||||||
result: List[str] = []
|
result: List[str] = []
|
||||||
|
|
||||||
# Add everything that is not going to get removed:
|
# Add everything that is not going to get removed:
|
||||||
for v in input:
|
for v in sinput:
|
||||||
if v not in value_set:
|
if v not in value_set:
|
||||||
result += [v]
|
result += [v]
|
||||||
|
|
||||||
# Add everything else with removal marker:
|
# Add everything else with removal marker:
|
||||||
for v in transformer(self._value):
|
for v in transformer(self._value):
|
||||||
if v not in input_set:
|
if v not in sinput_set:
|
||||||
result += [f"-{v}"]
|
result += [f"-{v}"]
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@ -2226,7 +2233,7 @@ def write_resources(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0,
|
|||||||
else:
|
else:
|
||||||
immediate_files_filtered.append(f)
|
immediate_files_filtered.append(f)
|
||||||
immediate_files = {f: "" for f in immediate_files_filtered}
|
immediate_files = {f: "" for f in immediate_files_filtered}
|
||||||
immediate_prefix = scope.get(r + ".prefix")
|
immediate_prefix = scope.get(f"{r}.prefix")
|
||||||
if immediate_prefix:
|
if immediate_prefix:
|
||||||
immediate_prefix = immediate_prefix[0]
|
immediate_prefix = immediate_prefix[0]
|
||||||
else:
|
else:
|
||||||
@ -2252,10 +2259,16 @@ def write_resources(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0,
|
|||||||
# stadalone source file properties need to be set as they
|
# stadalone source file properties need to be set as they
|
||||||
# are parsed.
|
# are parsed.
|
||||||
if skip_qtquick_compiler:
|
if skip_qtquick_compiler:
|
||||||
qrc_output += 'set_source_files_properties(f"{r}" PROPERTIES QT_SKIP_QUICKCOMPILER 1)\n\n'
|
qrc_output += (
|
||||||
|
f'set_source_files_properties("{r}" PROPERTIES '
|
||||||
|
f"QT_SKIP_QUICKCOMPILER 1)\n\n"
|
||||||
|
)
|
||||||
|
|
||||||
if retain_qtquick_compiler:
|
if retain_qtquick_compiler:
|
||||||
qrc_output += 'set_source_files_properties(f"{r}" PROPERTIES QT_RETAIN_QUICKCOMPILER 1)\n\n'
|
qrc_output += (
|
||||||
|
f'set_source_files_properties("{r}" PROPERTIES '
|
||||||
|
f"QT_RETAIN_QUICKCOMPILER 1)\n\n"
|
||||||
|
)
|
||||||
standalone_files.append(r)
|
standalone_files.append(r)
|
||||||
|
|
||||||
if standalone_files:
|
if standalone_files:
|
||||||
@ -2494,7 +2507,7 @@ def write_main_part(
|
|||||||
destdir = scope.get_string("DESTDIR")
|
destdir = scope.get_string("DESTDIR")
|
||||||
if destdir:
|
if destdir:
|
||||||
if destdir.startswith("./") or destdir.startswith("../"):
|
if destdir.startswith("./") or destdir.startswith("../"):
|
||||||
destdir = "${CMAKE_CURRENT_BINARY_DIR}/" + destdir
|
destdir = f"${{CMAKE_CURRENT_BINARY_DIR}}/{destdir}"
|
||||||
extra_lines.append(f'OUTPUT_DIRECTORY "{destdir}"')
|
extra_lines.append(f'OUTPUT_DIRECTORY "{destdir}"')
|
||||||
|
|
||||||
cm_fh.write(f"{spaces(indent)}{cmake_function}({name}\n")
|
cm_fh.write(f"{spaces(indent)}{cmake_function}({name}\n")
|
||||||
@ -2725,12 +2738,14 @@ def write_example(
|
|||||||
dest_dir = "${CMAKE_CURRENT_BINARY_DIR}"
|
dest_dir = "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
else:
|
else:
|
||||||
uri = os.path.basename(dest_dir)
|
uri = os.path.basename(dest_dir)
|
||||||
dest_dir = "${CMAKE_CURRENT_BINARY_DIR}/" + dest_dir
|
dest_dir = f"${{CMAKE_CURRENT_BINARY_DIR}}/{dest_dir}"
|
||||||
|
|
||||||
add_target = f"qt6_add_qml_module({binary_name}\n"
|
add_target = dedent(f"""\
|
||||||
add_target += f' OUTPUT_DIRECTORY "{dest_dir}"\n'
|
qt6_add_qml_module({binary_name}
|
||||||
add_target += " VERSION 1.0\n"
|
OUTPUT_DIRECTORY "{dest_dir}"
|
||||||
add_target += ' URI "{}"\n'.format(uri)
|
VERSION 1.0
|
||||||
|
URI "{uri}"
|
||||||
|
""")
|
||||||
|
|
||||||
qmldir_file_path = scope.get_files("qmldir.files")
|
qmldir_file_path = scope.get_files("qmldir.files")
|
||||||
if qmldir_file_path:
|
if qmldir_file_path:
|
||||||
@ -2746,7 +2761,8 @@ def write_example(
|
|||||||
if len(qml_dir.classname) != 0:
|
if len(qml_dir.classname) != 0:
|
||||||
add_target += f" CLASSNAME {qml_dir.classname}\n"
|
add_target += f" CLASSNAME {qml_dir.classname}\n"
|
||||||
if len(qml_dir.imports) != 0:
|
if len(qml_dir.imports) != 0:
|
||||||
add_target += " IMPORTS\n{}".format(" \n".join(qml_dir.imports))
|
qml_dir_imports_line = " \n".join(qml_dir.imports)
|
||||||
|
add_target += f" IMPORTS\n{qml_dir_imports_line}"
|
||||||
if len(qml_dir.depends) != 0:
|
if len(qml_dir.depends) != 0:
|
||||||
add_target += " DEPENDENCIES\n"
|
add_target += " DEPENDENCIES\n"
|
||||||
for dep in qml_dir.depends:
|
for dep in qml_dir.depends:
|
||||||
@ -2768,18 +2784,14 @@ def write_example(
|
|||||||
cm_fh, scope, f"target_include_directories({binary_name} PUBLIC", indent=0, footer=")"
|
cm_fh, scope, f"target_include_directories({binary_name} PUBLIC", indent=0, footer=")"
|
||||||
)
|
)
|
||||||
write_defines(
|
write_defines(
|
||||||
cm_fh,
|
cm_fh, scope, f"target_compile_definitions({binary_name} PUBLIC", indent=0, footer=")"
|
||||||
scope,
|
|
||||||
"target_compile_definitions({} PUBLIC".format(binary_name),
|
|
||||||
indent=0,
|
|
||||||
footer=")",
|
|
||||||
)
|
)
|
||||||
write_list(
|
write_list(
|
||||||
cm_fh,
|
cm_fh,
|
||||||
private_libs,
|
private_libs,
|
||||||
"",
|
"",
|
||||||
indent=indent,
|
indent=indent,
|
||||||
header="target_link_libraries({} PRIVATE\n".format(binary_name),
|
header=f"target_link_libraries({binary_name} PRIVATE\n",
|
||||||
footer=")",
|
footer=")",
|
||||||
)
|
)
|
||||||
write_list(
|
write_list(
|
||||||
@ -2787,11 +2799,11 @@ def write_example(
|
|||||||
public_libs,
|
public_libs,
|
||||||
"",
|
"",
|
||||||
indent=indent,
|
indent=indent,
|
||||||
header="target_link_libraries({} PUBLIC\n".format(binary_name),
|
header=f"target_link_libraries({binary_name} PUBLIC\n",
|
||||||
footer=")",
|
footer=")",
|
||||||
)
|
)
|
||||||
write_compile_options(
|
write_compile_options(
|
||||||
cm_fh, scope, "target_compile_options({}".format(binary_name), indent=0, footer=")"
|
cm_fh, scope, f"target_compile_options({binary_name}", indent=0, footer=")"
|
||||||
)
|
)
|
||||||
|
|
||||||
write_resources(cm_fh, binary_name, scope, indent=indent, is_example=True)
|
write_resources(cm_fh, binary_name, scope, indent=indent, is_example=True)
|
||||||
@ -2801,11 +2813,11 @@ def write_example(
|
|||||||
write_qml_plugin_epilogue(cm_fh, binary_name, scope, qmldir, indent)
|
write_qml_plugin_epilogue(cm_fh, binary_name, scope, qmldir, indent)
|
||||||
|
|
||||||
cm_fh.write(
|
cm_fh.write(
|
||||||
"\ninstall(TARGETS {}\n".format(binary_name)
|
f"\ninstall(TARGETS {binary_name}\n"
|
||||||
+ ' RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"\n'
|
f' RUNTIME DESTINATION "${{INSTALL_EXAMPLEDIR}}"\n'
|
||||||
+ ' BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"\n'
|
f' BUNDLE DESTINATION "${{INSTALL_EXAMPLEDIR}}"\n'
|
||||||
+ ' LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"\n'
|
f' LIBRARY DESTINATION "${{INSTALL_EXAMPLEDIR}}"\n'
|
||||||
+ ")\n"
|
f")\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
return binary_name
|
return binary_name
|
||||||
@ -2829,7 +2841,7 @@ def write_plugin(cm_fh, scope, *, indent: int = 0) -> str:
|
|||||||
|
|
||||||
plugin_class_name = scope.get_string("PLUGIN_CLASS_NAME")
|
plugin_class_name = scope.get_string("PLUGIN_CLASS_NAME")
|
||||||
if plugin_class_name:
|
if plugin_class_name:
|
||||||
extra.append("CLASS_NAME {}".format(plugin_class_name))
|
extra.append(f"CLASS_NAME {plugin_class_name}")
|
||||||
|
|
||||||
write_main_part(
|
write_main_part(
|
||||||
cm_fh,
|
cm_fh,
|
||||||
@ -2898,7 +2910,9 @@ def write_qml_plugin(
|
|||||||
if len(qml_dir.classname) != 0:
|
if len(qml_dir.classname) != 0:
|
||||||
extra_lines.append(f"CLASSNAME {qml_dir.classname}")
|
extra_lines.append(f"CLASSNAME {qml_dir.classname}")
|
||||||
if len(qml_dir.imports) != 0:
|
if len(qml_dir.imports) != 0:
|
||||||
extra_lines.append("IMPORTS\n {}".format("\n ".join(qml_dir.imports)))
|
qml_dir_imports_line = "\n ".join(qml_dir.imports)
|
||||||
|
extra_lines.append("IMPORTS\n "
|
||||||
|
f"{qml_dir_imports_line}")
|
||||||
if len(qml_dir.depends) != 0:
|
if len(qml_dir.depends) != 0:
|
||||||
extra_lines.append("DEPENDENCIES")
|
extra_lines.append("DEPENDENCIES")
|
||||||
for dep in qml_dir.depends:
|
for dep in qml_dir.depends:
|
||||||
@ -2919,43 +2933,33 @@ def write_qml_plugin_epilogue(
|
|||||||
indent_0 = spaces(indent)
|
indent_0 = spaces(indent)
|
||||||
indent_1 = spaces(indent + 1)
|
indent_1 = spaces(indent + 1)
|
||||||
# Quote file paths in case there are spaces.
|
# Quote file paths in case there are spaces.
|
||||||
qml_files_quoted = ['"{}"'.format(f) for f in qml_files]
|
qml_files_quoted = [f'"{qf}"' for qf in qml_files]
|
||||||
|
|
||||||
cm_fh.write(
|
indented_qml_files = f"\n{indent_1}".join(qml_files_quoted)
|
||||||
"\n{}set(qml_files\n{}{}\n)\n".format(
|
cm_fh.write(f"\n{indent_0}set(qml_files\n{indent_1}" f"{indented_qml_files}\n)\n")
|
||||||
indent_0, indent_1, "\n{}".format(indent_1).join(qml_files_quoted)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
for qml_file in qml_files:
|
for qml_file in qml_files:
|
||||||
if qml_file in qmldir.type_names:
|
if qml_file in qmldir.type_names:
|
||||||
qmldir_file_info = qmldir.type_names[qml_file]
|
qmldir_file_info = qmldir.type_names[qml_file]
|
||||||
cm_fh.write(
|
cm_fh.write(f"{indent_0}set_source_files_properties({qml_file} PROPERTIES\n")
|
||||||
"{}set_source_files_properties({} PROPERTIES\n".format(indent_0, qml_file)
|
cm_fh.write(f'{indent_1}QT_QML_SOURCE_VERSION "{qmldir_file_info.version}"\n')
|
||||||
)
|
|
||||||
cm_fh.write(
|
|
||||||
'{}QT_QML_SOURCE_VERSION "{}"\n'.format(indent_1, qmldir_file_info.version)
|
|
||||||
)
|
|
||||||
# Only write typename if they are different, CMake will infer
|
# Only write typename if they are different, CMake will infer
|
||||||
# the name by default
|
# the name by default
|
||||||
if (
|
if (
|
||||||
os.path.splitext(os.path.basename(qmldir_file_info.path))[0]
|
os.path.splitext(os.path.basename(qmldir_file_info.path))[0]
|
||||||
!= qmldir_file_info.type_name
|
!= qmldir_file_info.type_name
|
||||||
):
|
):
|
||||||
cm_fh.write(
|
cm_fh.write(f"{indent_1}QT_QML_SOURCE_TYPENAME {qmldir_file_info.type_name}\n")
|
||||||
"{}QT_QML_SOURCE_TYPENAME {}\n".format(indent_1, qmldir_file_info.type_name)
|
cm_fh.write(f"{indent_1}QT_QML_SOURCE_INSTALL TRUE\n")
|
||||||
)
|
|
||||||
cm_fh.write("{}QT_QML_SOURCE_INSTALL TRUE\n".format(indent_1))
|
|
||||||
if qmldir_file_info.singleton:
|
if qmldir_file_info.singleton:
|
||||||
cm_fh.write("{}QT_QML_SINGLETON_TYPE TRUE\n".format(indent_1))
|
cm_fh.write(f"{indent_1}QT_QML_SINGLETON_TYPE TRUE\n")
|
||||||
if qmldir_file_info.internal:
|
if qmldir_file_info.internal:
|
||||||
cm_fh.write("{}QT_QML_INTERNAL_TYPE TRUE\n".format(indent_1))
|
cm_fh.write(f"{indent_1}QT_QML_INTERNAL_TYPE TRUE\n")
|
||||||
cm_fh.write("{})\n".format(indent_0))
|
cm_fh.write(f"{indent_0})\n")
|
||||||
|
|
||||||
cm_fh.write(
|
cm_fh.write(
|
||||||
"\n{}qt6_target_qml_files({}\n{}FILES\n{}${{qml_files}}\n)\n".format(
|
f"\n{indent_0}qt6_target_qml_files({target}\n{indent_1}FILES\n"
|
||||||
indent_0, target, indent_1, spaces(indent + 2)
|
f"{spaces(indent+2)}${{qml_files}}\n)\n"
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -3073,7 +3077,7 @@ def handle_top_level_repo_tests_project(scope: Scope, cm_fh: IO[str]):
|
|||||||
# Found a mapping, adjust name.
|
# Found a mapping, adjust name.
|
||||||
if qt_lib != file_name_without_qt:
|
if qt_lib != file_name_without_qt:
|
||||||
# QtDeclarative
|
# QtDeclarative
|
||||||
qt_lib = re.sub(r":", r"", qt_lib) + "Tests"
|
qt_lib = f'{re.sub(r":", r"", qt_lib)}{"Tests"}'
|
||||||
else:
|
else:
|
||||||
qt_lib += "Tests_FIXME"
|
qt_lib += "Tests_FIXME"
|
||||||
else:
|
else:
|
||||||
@ -3120,7 +3124,7 @@ def cmakeify_scope(
|
|||||||
# Wrap top level examples project with some commands which
|
# Wrap top level examples project with some commands which
|
||||||
# are necessary to build examples as part of the overall
|
# are necessary to build examples as part of the overall
|
||||||
# build.
|
# build.
|
||||||
buffer_value = f"\nqt_examples_build_begin()\n\n{buffer_value}\nqt_examples_build_end()"
|
buffer_value = f"qt_examples_build_begin()\n\n{buffer_value}\nqt_examples_build_end()\n"
|
||||||
|
|
||||||
cm_fh.write(buffer_value)
|
cm_fh.write(buffer_value)
|
||||||
|
|
||||||
|
@ -184,13 +184,11 @@ def print_stats(
|
|||||||
for stat in stats:
|
for stat in stats:
|
||||||
if stats[stat]["value"] > 0:
|
if stats[stat]["value"] > 0:
|
||||||
print(
|
print(
|
||||||
"{:<40}: {} ({}%)".format(
|
f"{stats[stat]['label']:<40}: {stats[stat]['value']} ({stats[stat]['percentage']}%)"
|
||||||
stats[stat]["label"], stats[stat]["value"], stats[stat]["percentage"]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
print("\n{:<40}: {:.10f} seconds".format("Scan time", scan_time))
|
print(f"\n{'Scan time':<40}: {scan_time:.10f} seconds")
|
||||||
print("{:<40}: {:.10f} seconds".format("Total script time", script_time))
|
print(f"{'Total script time':<40}: {script_time:.10f} seconds")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user