summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-11-11 18:13:56 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-11-12 15:25:06 +0100
commit267bb4ec6c628d998ba7f11bcdf56cc03b0aa5a0 (patch)
tree02f99b6dfa727e1aa71514003f359e04b4911249 /util
parent34437b9e14f531fd514941143f34e95639d9cb74 (diff)
CMake: pro2cmake: Reformat scripts using black8 again
Change-Id: I1b024867e76baa2e443e95a5e980745b65ee1f19 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-xutil/cmake/configurejson2cmake.py63
-rw-r--r--util/cmake/helper.py53
-rwxr-xr-xutil/cmake/pro2cmake.py39
3 files changed, 98 insertions, 57 deletions
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py
index 60b92539e1..7d7984b574 100755
--- a/util/cmake/configurejson2cmake.py
+++ b/util/cmake/configurejson2cmake.py
@@ -769,6 +769,7 @@ def write_compile_test(
# }
# },
+
def write_compiler_supports_flag_test(
ctx, name, details, data, cm_fh, manual_library_list=None, is_library_test=False
):
@@ -777,6 +778,7 @@ def write_compiler_supports_flag_test(
cm_fh.write(lineify("FLAG", data.get("flag", "")))
cm_fh.write(")\n\n")
+
def write_linker_supports_flag_test(
ctx, name, details, data, cm_fh, manual_library_list=None, is_library_test=False
):
@@ -785,6 +787,7 @@ def write_linker_supports_flag_test(
cm_fh.write(lineify("FLAG", data.get("flag", "")))
cm_fh.write(")\n\n")
+
def parseTest(ctx, test, data, cm_fh):
skip_tests = {
"c11",
@@ -894,7 +897,7 @@ def get_feature_mapping():
},
"debug": {
"autoDetect": "ON",
- "condition": "CMAKE_BUILD_TYPE STREQUAL Debug OR Debug IN_LIST CMAKE_CONFIGURATION_TYPES"
+ "condition": "CMAKE_BUILD_TYPE STREQUAL Debug OR Debug IN_LIST CMAKE_CONFIGURATION_TYPES",
},
"dlopen": {"condition": "UNIX"},
"enable_new_dtags": None,
@@ -928,7 +931,7 @@ else()
endforeach()
unset(__qt_uc_config)
endif()""",
- "condition": "__qt_ltcg_detected"
+ "condition": "__qt_ltcg_detected",
},
"msvc_mp": None,
"simulator_and_device": {"condition": "UIKIT AND NOT QT_UIKIT_SDK"},
@@ -937,24 +940,18 @@ endif()""",
"profile": None,
"qmakeargs": None,
"qpa_default_platform": None, # Not a bool!
- "qreal" : {
- "condition": "DEFINED QT_COORD_TYPE AND NOT QT_COORD_TYPE STREQUAL \"double\"",
+ "qreal": {
+ "condition": 'DEFINED QT_COORD_TYPE AND NOT QT_COORD_TYPE STREQUAL "double"',
"output": [
- {
- "type": "define",
- "name": "QT_COORD_TYPE",
- "value": "${QT_COORD_TYPE}",
- },
+ {"type": "define", "name": "QT_COORD_TYPE", "value": "${QT_COORD_TYPE}",},
{
"type": "define",
"name": "QT_COORD_TYPE_STRING",
- "value": "\\\"${QT_COORD_TYPE}\\\"",
+ "value": '\\"${QT_COORD_TYPE}\\"',
},
],
},
- "reduce_exports": {
- "condition": "NOT MSVC",
- },
+ "reduce_exports": {"condition": "NOT MSVC",},
"release": None,
"release_tools": None,
"rpath": {
@@ -1043,8 +1040,14 @@ def parseFeature(ctx, feature, data, cm_fh):
if isinstance(o, dict):
outputType = o["type"]
- if outputType in ["varAssign", "varAppend", "varRemove",
- "useBFDLinker", "useGoldLinker", "useLLDLinker"]:
+ if outputType in [
+ "varAssign",
+ "varAppend",
+ "varRemove",
+ "useBFDLinker",
+ "useGoldLinker",
+ "useLLDLinker",
+ ]:
continue
elif outputType == "define":
publicDefine = True
@@ -1130,8 +1133,13 @@ def parseFeature(ctx, feature, data, cm_fh):
# Default internal feature case.
featureCalls = {}
- featureCalls[feature] = {"name": feature, "labelAppend": "", "autoDetect": autoDetect,
- "cmakePrelude": cmakePrelude, "cmakeEpilogue": cmakeEpilogue}
+ featureCalls[feature] = {
+ "name": feature,
+ "labelAppend": "",
+ "autoDetect": autoDetect,
+ "cmakePrelude": cmakePrelude,
+ "cmakeEpilogue": cmakeEpilogue,
+ }
# Go over all outputs to compute the number of features that have to be declared
for o in output:
@@ -1366,9 +1374,11 @@ def processReportHelper(ctx, entries, cm_fh):
else:
print(f" XXXX UNHANDLED REPORT TYPE {entry}.")
+
def parseCommandLineCustomHandler(ctx, data, cm_fh):
cm_fh.write(f"qt_commandline_custom({data})\n")
+
def parseCommandLineOptions(ctx, data, cm_fh):
for key in data:
args = [key]
@@ -1385,7 +1395,7 @@ def parseCommandLineOptions(ctx, data, cm_fh):
if "values" in option:
values = option["values"]
if isinstance(values, list):
- args += ["VALUES", ' '.join(option["values"])]
+ args += ["VALUES", " ".join(option["values"])]
else:
args += ["MAPPING"]
for lhs in values:
@@ -1393,14 +1403,17 @@ def parseCommandLineOptions(ctx, data, cm_fh):
cm_fh.write(f"qt_commandline_option({' '.join(args)})\n")
+
def parseCommandLinePrefixes(ctx, data, cm_fh):
for key in data:
cm_fh.write(f"qt_commandline_prefix({key} {data[key]})\n")
+
def parseCommandLineAssignments(ctx, data, cm_fh):
for key in data:
cm_fh.write(f"qt_commandline_assignment({key} {data[key]})\n")
+
def processCommandLine(ctx, data, cm_fh):
print(" commandline:")
@@ -1425,6 +1438,7 @@ def processCommandLine(ctx, data, cm_fh):
print(" assignments:")
parseCommandLineAssignments(ctx, commandLine["assignments"], cm_fh)
+
def processInputs(ctx, data, cm_fh):
print(" inputs:")
if "commandline" not in data:
@@ -1509,7 +1523,7 @@ class special_cased_file:
def __exit__(self, type, value, trace_back):
self.file.close()
if self.preserve_special_cases and self.sc_handler.handle_special_cases():
- os.replace(self.gen_file_path, self.file_path)
+ os.replace(self.gen_file_path, self.file_path)
else:
os.replace(self.gen_file_path, self.file_path)
@@ -1521,12 +1535,10 @@ def processJson(path, ctx, data, skip_special_case_preservation=False):
ctx = processFiles(ctx, data)
- with special_cased_file(path, "qt_cmdline.cmake",
- skip_special_case_preservation) as cm_fh:
+ with special_cased_file(path, "qt_cmdline.cmake", skip_special_case_preservation) as cm_fh:
processCommandLine(ctx, data, cm_fh)
- with special_cased_file(path, "configure.cmake",
- skip_special_case_preservation) as cm_fh:
+ with special_cased_file(path, "configure.cmake", skip_special_case_preservation) as cm_fh:
cm_fh.write("\n\n#### Inputs\n\n")
processInputs(ctx, data, cm_fh)
@@ -1563,7 +1575,7 @@ def main():
quit(1)
skip_special_case_preservation = False
- if len(sys.argv) > 2 and sys.argv[2] == '-s':
+ if len(sys.argv) > 2 and sys.argv[2] == "-s":
skip_special_case_preservation = True
directory = sys.argv[1]
@@ -1571,8 +1583,7 @@ def main():
print(f"Processing: {directory}.")
data = readJsonFromDir(directory)
- processJson(directory, {}, data,
- skip_special_case_preservation=skip_special_case_preservation)
+ processJson(directory, {}, data, skip_special_case_preservation=skip_special_case_preservation)
if __name__ == "__main__":
diff --git a/util/cmake/helper.py b/util/cmake/helper.py
index f1025d86b7..0c381a1cd9 100644
--- a/util/cmake/helper.py
+++ b/util/cmake/helper.py
@@ -87,9 +87,13 @@ _qt_library_map = [
LibraryMapping("3dinput", "Qt6", "Qt::3DInput", extra=["COMPONENTS", "3DInput"]),
LibraryMapping("3dlogic", "Qt6", "Qt::3DLogic", extra=["COMPONENTS", "3DLogic"]),
LibraryMapping("3dquick", "Qt6", "Qt::3DQuick", extra=["COMPONENTS", "3DQuick"]),
- LibraryMapping("3dquickextras", "Qt6", "Qt::3DQuickExtras", extra=["COMPONENTS", "3DQuickExtras"]),
+ LibraryMapping(
+ "3dquickextras", "Qt6", "Qt::3DQuickExtras", extra=["COMPONENTS", "3DQuickExtras"]
+ ),
LibraryMapping("3dquickinput", "Qt6", "Qt::3DQuickInput", extra=["COMPONENTS", "3DQuickInput"]),
- LibraryMapping("3dquickrender", "Qt6", "Qt::3DQuickRender", extra=["COMPONENTS", "3DQuickRender"]),
+ LibraryMapping(
+ "3dquickrender", "Qt6", "Qt::3DQuickRender", extra=["COMPONENTS", "3DQuickRender"]
+ ),
LibraryMapping("3drender", "Qt6", "Qt::3DRender", extra=["COMPONENTS", "3DRender"]),
LibraryMapping(
"application-lib", "Qt6", "Qt::AppManApplication", extra=["COMPONENTS", "AppManApplication"]
@@ -147,7 +151,10 @@ _qt_library_map = [
"eglfs_kms_support", "Qt6", "Qt::EglFsKmsSupport", extra=["COMPONENTS", "EglFsKmsSupport"]
),
LibraryMapping(
- "eglfs_kms_gbm_support", "Qt6", "Qt::EglFsKmsGbmSupport", extra=["COMPONENTS", "EglFsKmsGbmSupport"]
+ "eglfs_kms_gbm_support",
+ "Qt6",
+ "Qt::EglFsKmsGbmSupport",
+ extra=["COMPONENTS", "EglFsKmsGbmSupport"],
),
LibraryMapping("egl_support", "Qt6", "Qt::EglSupport", extra=["COMPONENTS", "EglSupport"]),
# enginio: Not needed in Qt6!
@@ -291,7 +298,10 @@ _qt_library_map = [
"quickcontrols2", "Qt6", "Qt::QuickControls2", extra=["COMPONENTS", "QuickControls2"]
),
LibraryMapping(
- "quickcontrols2impl", "Qt6", "Qt::QuickControls2Impl", extra=["COMPONENTS", "QuickControls2Impl"]
+ "quickcontrols2impl",
+ "Qt6",
+ "Qt::QuickControls2Impl",
+ extra=["COMPONENTS", "QuickControls2Impl"],
),
LibraryMapping("quick", "Qt6", "Qt::Quick", extra=["COMPONENTS", "Quick"]),
LibraryMapping("quickshapes", "Qt6", "Qt::QuickShapes", extra=["COMPONENTS", "QuickShapes"]),
@@ -415,8 +425,11 @@ _library_map = [
LibraryMapping("gtk3", "GTK3", "PkgConfig::GTK3", extra=["3.6"]),
LibraryMapping("gssapi", "GSSAPI", "GSSAPI::GSSAPI"),
LibraryMapping(
- "harfbuzz", "WrapHarfbuzz", "WrapHarfbuzz::WrapHarfbuzz", is_bundled_with_qt=True,
- extra=["2.6.0"]
+ "harfbuzz",
+ "WrapHarfbuzz",
+ "WrapHarfbuzz::WrapHarfbuzz",
+ is_bundled_with_qt=True,
+ extra=["2.6.0"],
),
LibraryMapping("host_dbus", None, None),
LibraryMapping(
@@ -460,7 +473,11 @@ _library_map = [
),
LibraryMapping("oci", "Oracle", "Oracle::OCI"),
LibraryMapping(
- "pcre2", "WrapPCRE2", "WrapPCRE2::WrapPCRE2", extra=["10.20", "REQUIRED"], is_bundled_with_qt=True
+ "pcre2",
+ "WrapPCRE2",
+ "WrapPCRE2::WrapPCRE2",
+ extra=["10.20", "REQUIRED"],
+ is_bundled_with_qt=True,
),
LibraryMapping("pps", "PPS", "PPS::PPS"),
LibraryMapping("psql", "PostgreSQL", "PostgreSQL::PostgreSQL"),
@@ -495,13 +512,25 @@ _library_map = [
"xcb_glx", "XCB", "XCB::GLX", extra=["COMPONENTS", "GLX"], resultVariable="XCB_GLX"
),
LibraryMapping(
- "xcb_icccm", "XCB", "XCB::ICCCM", extra=["0.3.9", "COMPONENTS", "ICCCM"], resultVariable="XCB_ICCCM"
+ "xcb_icccm",
+ "XCB",
+ "XCB::ICCCM",
+ extra=["0.3.9", "COMPONENTS", "ICCCM"],
+ resultVariable="XCB_ICCCM",
),
LibraryMapping(
- "xcb_image", "XCB", "XCB::IMAGE", extra=["0.3.9", "COMPONENTS", "IMAGE"], resultVariable="XCB_IMAGE"
+ "xcb_image",
+ "XCB",
+ "XCB::IMAGE",
+ extra=["0.3.9", "COMPONENTS", "IMAGE"],
+ resultVariable="XCB_IMAGE",
),
LibraryMapping(
- "xcb_util", "XCB", "XCB::UTIL", extra=["0.3.9", "COMPONENTS", "UTIL"], resultVariable="XCB_UTIL"
+ "xcb_util",
+ "XCB",
+ "XCB::UTIL",
+ extra=["0.3.9", "COMPONENTS", "UTIL"],
+ resultVariable="XCB_UTIL",
),
LibraryMapping(
"xcb_keysyms",
@@ -783,8 +812,8 @@ def generate_find_package_info(
package_name: str = initial_package_name
if use_system_package_name:
replace_args = ["Wrap", "WrapSystem"]
- package_name = package_name.replace(*replace_args) # type: ignore
- cmake_target_name = cmake_target_name.replace(*replace_args) # type: ignore
+ package_name = package_name.replace(*replace_args) # type: ignore
+ cmake_target_name = cmake_target_name.replace(*replace_args) # type: ignore
if use_qt_find_package:
if cmake_target_name:
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 4f7118007e..6308ab0a6d 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -396,10 +396,13 @@ def detect_cmake_api_version_used_in_file_content(project_file_path: str) -> Opt
api_call_versions = sorted(api_call_versions, reverse=True)
api_call_version_matches = {}
for version in api_call_versions:
- versioned_api_calls = [cmake_api_calls[version][api_call]
- for api_call in cmake_api_calls[version]]
+ versioned_api_calls = [
+ cmake_api_calls[version][api_call] for api_call in cmake_api_calls[version]
+ ]
versioned_api_calls_alternatives = "|".join(versioned_api_calls)
- api_call_version_matches[version] = re.search(versioned_api_calls_alternatives, contents)
+ api_call_version_matches[version] = re.search(
+ versioned_api_calls_alternatives, contents
+ )
# If new style found, return latest api version. Otherwise
# return the current version.
@@ -2928,12 +2931,10 @@ def write_windows_part(cm_fh: IO[str], target: str, scope: Scope, indent: int =
def write_aux_qml_file_install_call(cm_fh: IO[str], file_list: List[str], indent: int = 0):
cm_fh.write(f"\n{spaces(indent)}qt_copy_or_install(\n")
- write_list(
- cm_fh, file_list, "FILES", indent + 1
- )
+ write_list(cm_fh, file_list, "FILES", indent + 1)
destination_option = 'DESTINATION "${__aux_qml_files_install_dir}"'
- cm_fh.write(f'{spaces(indent + 1)}{destination_option})\n')
+ cm_fh.write(f"{spaces(indent + 1)}{destination_option})\n")
def write_aux_qml_path_setup(cm_fh: IO[str], base_dir: str, indent: int = 0):
@@ -3419,7 +3420,7 @@ def write_module(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
module_name_for_pri_as_cmake_computes_it = cmake_target_name.lower()
if module_name_for_pri != module_name_for_pri_as_cmake_computes_it:
- extra.append(f'CONFIG_MODULE_NAME {module_name_for_pri}')
+ extra.append(f"CONFIG_MODULE_NAME {module_name_for_pri}")
if is_static:
extra.append("STATIC")
@@ -3665,8 +3666,9 @@ def write_jar(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
return target
-def write_win32_and_mac_bundle_properties(cm_fh: IO[str], scope: Scope, target: str, *,
- handling_first_scope=False, indent: int = 0):
+def write_win32_and_mac_bundle_properties(
+ cm_fh: IO[str], scope: Scope, target: str, *, handling_first_scope=False, indent: int = 0
+):
config = scope.get("CONFIG")
win32 = all(val not in config for val in ["cmdline", "console"])
mac_bundle = all(val not in config for val in ["cmdline", "-app_bundle"])
@@ -3674,8 +3676,10 @@ def write_win32_and_mac_bundle_properties(cm_fh: IO[str], scope: Scope, target:
true_value = "TRUE"
false_value = "FALSE"
- properties_mapping = {"WIN32_EXECUTABLE": true_value if win32 else false_value,
- "MACOSX_BUNDLE": true_value if mac_bundle else false_value}
+ properties_mapping = {
+ "WIN32_EXECUTABLE": true_value if win32 else false_value,
+ "MACOSX_BUNDLE": true_value if mac_bundle else false_value,
+ }
properties = []
@@ -3830,7 +3834,7 @@ def write_example(
add_target += f"target_sources({binary_name} PRIVATE"
else:
- add_target = f'qt_add_executable({binary_name}'
+ add_target = f"qt_add_executable({binary_name}"
write_all_source_file_lists(cm_fh, scope, add_target, indent=0)
cm_fh.write(")\n")
@@ -3858,11 +3862,9 @@ def write_example(
io_string, scope, target_sources, indent=indent, footer=")\n"
)
- write_win32_and_mac_bundle_properties(io_string,
- scope,
- binary_name,
- handling_first_scope=handling_first_scope,
- indent=indent)
+ write_win32_and_mac_bundle_properties(
+ io_string, scope, binary_name, handling_first_scope=handling_first_scope, indent=indent
+ )
write_include_paths(
io_string,
@@ -4260,7 +4262,6 @@ def handle_app_or_lib(
if past_major_versions:
cm_fh.write(f"{spaces(indent+1)}QT_QML_PAST_MAJOR_VERSIONS {past_major_versions}\n")
-
import_name = scope.expandString("QML_IMPORT_NAME")
if import_name:
cm_fh.write(f"{spaces(indent+1)}QT_QML_MODULE_URI {import_name}\n")