From d4018dac8b0c1834ae3f865020637f63d6846ddd Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 11 Mar 2020 19:14:35 +0100 Subject: CMake: Reformat the python scripts using black Change-Id: I1e2eba46eb7c9dfefd267be91790be7898634c3a Reviewed-by: Leander Beernaert Reviewed-by: Alexandru Croitor --- util/cmake/configurejson2cmake.py | 44 ++++++++++++++++++++++++--------------- util/cmake/helper.py | 27 ++++++++++++++++-------- util/cmake/pro2cmake.py | 6 +++--- 3 files changed, 48 insertions(+), 29 deletions(-) (limited to 'util') diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py index 76d6a33477..cabf1e41e0 100755 --- a/util/cmake/configurejson2cmake.py +++ b/util/cmake/configurejson2cmake.py @@ -229,7 +229,9 @@ def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set): if run_library_test and "test" in data["libraries"][lib]: test = data["libraries"][lib]["test"] - write_compile_test(ctx, lib, test, data, cm_fh, manual_library_list=[lib], is_library_test = True) + write_compile_test( + ctx, lib, test, data, cm_fh, manual_library_list=[lib], is_library_test=True + ) def lineify(label, value, quote=True): @@ -498,9 +500,11 @@ def parseInput(ctx, sinput, data, cm_fh): return -def write_compile_test(ctx, name, details, data, cm_fh, manual_library_list = None, is_library_test = False): +def write_compile_test( + ctx, name, details, data, cm_fh, manual_library_list=None, is_library_test=False +): - if manual_library_list == None: + if manual_library_list is None: manual_library_list = [] inherited_test_name = details["inherit"] if "inherit" in details else None @@ -508,7 +512,7 @@ def write_compile_test(ctx, name, details, data, cm_fh, manual_library_list = No if inherited_test_name and is_library_test: inherit_details = data["libraries"][inherited_test_name]["test"] if not inherit_details: - print(f" XXXX Failed to locate inherited library test {inherit}") + print(f" XXXX Failed to locate inherited library test {inherited_test_name}") if isinstance(details, str): rel_test_project_path = f"{ctx['test_dir']}/{details}" @@ -543,7 +547,7 @@ qt_config_compile_test("{details}" include = f"#include <{include}>" return include - include ="" + include = "" if is_library_test: if inherit_details: inherited_lib_data = data["libraries"][inherited_test_name] @@ -563,7 +567,7 @@ qt_config_compile_test("{details}" tail = "\n".join(tail) return tail - tail ="" + tail = "" if inherit_details: tail += resolve_tail(inherit_details) tail += resolve_tail(details) @@ -671,7 +675,6 @@ qt_config_compile_test("{details}" cm_fh.write(")\n\n") - # "tests": { # "cxx11_future": { # "label": "C++11 ", @@ -765,17 +768,21 @@ def get_feature_mapping(): "compiler-flags": None, "cross_compile": None, "debug_and_release": { - "autoDetect": "1", # Setting this to None has weird effects... - "condition": "QT_GENERATOR_IS_MULTI_CONFIG" + "autoDetect": "1", # Setting this to None has weird effects... + "condition": "QT_GENERATOR_IS_MULTI_CONFIG", + }, + "debug": { + "condition": "CMAKE_BUILD_TYPE STREQUAL Debug OR Debug IN_LIST CMAKE_CONFIGURATION_TYPES" }, - "debug": {"condition": "CMAKE_BUILD_TYPE STREQUAL Debug OR Debug IN_LIST CMAKE_CONFIGURATION_TYPES"}, "dlopen": {"condition": "UNIX"}, "enable_gdb_index": None, "enable_new_dtags": None, "force_debug_info": { "autoDetect": "CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo OR RelWithDebInfo IN_LIST CMAKE_CONFIGURATION_TYPES" }, - "framework": {"condition": "APPLE AND BUILD_SHARED_LIBS AND NOT CMAKE_BUILD_TYPE STREQUAL Debug"}, + "framework": { + "condition": "APPLE AND BUILD_SHARED_LIBS AND NOT CMAKE_BUILD_TYPE STREQUAL Debug" + }, "gc_binaries": None, "gcc-sysroot": None, "gcov": None, @@ -1092,8 +1099,11 @@ def processSummaryHelper(ctx, entries, cm_fh): if isinstance(entry, str): name = entry cm_fh.write(f'qt_configure_add_summary_entry(ARGS "{name}")\n') - elif "type" in entry \ - and entry["type"] in ["feature", "firstAvailableFeature", "featureList"]: + elif "type" in entry and entry["type"] in [ + "feature", + "firstAvailableFeature", + "featureList", + ]: function_args = [] entry_type = entry["type"] @@ -1125,12 +1135,12 @@ def processSummaryHelper(ctx, entries, cm_fh): condition = map_condition(entry["condition"]) function_args.append(lineify("CONDITION", condition, quote=False)) entry_args_string = "".join(function_args) - cm_fh.write(f'qt_configure_add_summary_entry(\n{entry_args_string})\n') + cm_fh.write(f"qt_configure_add_summary_entry(\n{entry_args_string})\n") elif "type" in entry and entry["type"] == "buildTypeAndConfig": - cm_fh.write(f'qt_configure_add_summary_build_type_and_config()\n') + cm_fh.write(f"qt_configure_add_summary_build_type_and_config()\n") elif "type" in entry and entry["type"] == "buildMode": message = entry["message"] - cm_fh.write(f'qt_configure_add_summary_build_mode({message})\n') + cm_fh.write(f"qt_configure_add_summary_build_mode({message})\n") elif "section" in entry: section = entry["section"] cm_fh.write(f'qt_configure_add_summary_section(NAME "{section}")\n') @@ -1186,7 +1196,7 @@ def processReportHelper(ctx, entries, cm_fh): condition = map_condition(condition) entry_args.append(lineify("CONDITION", condition, quote=False)) entry_args_string = "".join(entry_args) - cm_fh.write(f'qt_configure_add_report_entry(\n{entry_args_string})\n') + cm_fh.write(f"qt_configure_add_report_entry(\n{entry_args_string})\n") else: print(f" XXXX UNHANDLED REPORT TYPE {entry}.") diff --git a/util/cmake/helper.py b/util/cmake/helper.py index aa6107412f..9f88e23f97 100644 --- a/util/cmake/helper.py +++ b/util/cmake/helper.py @@ -43,7 +43,7 @@ class LibraryMapping: emit_if: str = "", is_bundled_with_qt: bool = False, test_library_overwrite: str = "", - run_library_test: bool = False + run_library_test: bool = False, ) -> None: self.soName = soName self.packageName = packageName @@ -226,7 +226,9 @@ _qt_library_map = [ "openglextensions", "Qt6", "Qt::OpenGLExtensions", extra=["COMPONENTS", "OpenGLExtensions"] ), LibraryMapping("opengl", "Qt6", "Qt::OpenGL", extra=["COMPONENTS", "OpenGL"]), - LibraryMapping("openglwidgets", "Qt6", "Qt::OpenGLWidgets", extra=["COMPONENTS", "OpenGLWidgets"]), + LibraryMapping( + "openglwidgets", "Qt6", "Qt::OpenGLWidgets", extra=["COMPONENTS", "OpenGLWidgets"] + ), LibraryMapping( "package-lib", "Qt6", "Qt::AppManPackage", extra=["COMPONENTS", "AppManPackage"] ), @@ -383,9 +385,7 @@ _qt_library_map = [ LibraryMapping( "webkitwidgets", "Qt6", "Qt::WebKitWidgets", extra=["COMPONENTS", "WebKitWidgets"] ), - LibraryMapping( - "zlib", "Qt6", "Qt::Zlib", extra=["COMPONENTS", "Zlib"] - ) + LibraryMapping("zlib", "Qt6", "Qt::Zlib", extra=["COMPONENTS", "Zlib"]), ] # Note that the library map is adjusted dynamically further down. @@ -398,7 +398,9 @@ _library_map = [ LibraryMapping("directfb", "DirectFB", "PkgConfig::DirectFB"), LibraryMapping("db2", "DB2", "DB2::DB2"), LibraryMapping("dbus", "WrapDBus1", "dbus-1", resultVariable="DBus1"), - LibraryMapping("doubleconversion", "WrapDoubleConversion", "WrapDoubleConversion::WrapDoubleConversion"), + LibraryMapping( + "doubleconversion", "WrapDoubleConversion", "WrapDoubleConversion::WrapDoubleConversion" + ), LibraryMapping("drm", "Libdrm", "Libdrm::Libdrm"), LibraryMapping("egl", "EGL", "EGL::EGL"), LibraryMapping("flite", "Flite", "Flite::Flite"), @@ -448,10 +450,17 @@ _library_map = [ "OpenSSL::SSL_nolink", resultVariable="TEST_openssl_headers", appendFoundSuffix=False, - test_library_overwrite = "OpenSSL::SSL", - run_library_test=True + test_library_overwrite="OpenSSL::SSL", + run_library_test=True, + ), + LibraryMapping( + "openssl", + "OpenSSL", + "OpenSSL::SSL", + resultVariable="TEST_openssl", + appendFoundSuffix=False, + run_library_test=True, ), - LibraryMapping("openssl", "OpenSSL", "OpenSSL::SSL", resultVariable="TEST_openssl", appendFoundSuffix=False, run_library_test=True), LibraryMapping("oci", "Oracle", "Oracle::OCI"), LibraryMapping( "pcre2", "WrapPCRE2", "WrapPCRE2::WrapPCRE2", extra=["REQUIRED"], is_bundled_with_qt=True diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 7bc29990c5..e6ad26ad3c 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -2540,12 +2540,12 @@ def write_reduce_relocations_part(cm_fh: IO[str], target: str, scope: Scope, ind dynlist_file = scope.get_files("QMAKE_DYNAMIC_LIST_FILE") if dynlist_file: dynlist_path = "${CMAKE_CURRENT_LIST_DIR}/" + dynlist_file[0] - cm_fh.write(f'{ind}if(QT_FEATURE_reduce_relocations AND UNIX AND GCC)\n') + cm_fh.write(f"{ind}if(QT_FEATURE_reduce_relocations AND UNIX AND GCC)\n") ind = spaces(indent + 1) - cm_fh.write(f'{ind}target_link_options({target} PRIVATE\n') + cm_fh.write(f"{ind}target_link_options({target} PRIVATE\n") cm_fh.write(f'{ind} "LINKER:--dynamic-list={dynlist_path}")\n') ind = spaces(indent) - cm_fh.write(f'{ind}endif()\n') + cm_fh.write(f"{ind}endif()\n") def write_android_part(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0): -- cgit v1.2.3