CMake: Reformat the python scripts using black

Change-Id: I1e2eba46eb7c9dfefd267be91790be7898634c3a
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexandru Croitor 2020-03-11 19:14:35 +01:00
parent 60a93a15b1
commit d4018dac8b
3 changed files with 48 additions and 29 deletions

View File

@ -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]: if run_library_test and "test" in data["libraries"][lib]:
test = data["libraries"][lib]["test"] 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): def lineify(label, value, quote=True):
@ -498,9 +500,11 @@ def parseInput(ctx, sinput, data, cm_fh):
return 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 = [] manual_library_list = []
inherited_test_name = details["inherit"] if "inherit" in details else None 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: if inherited_test_name and is_library_test:
inherit_details = data["libraries"][inherited_test_name]["test"] inherit_details = data["libraries"][inherited_test_name]["test"]
if not inherit_details: 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): if isinstance(details, str):
rel_test_project_path = f"{ctx['test_dir']}/{details}" rel_test_project_path = f"{ctx['test_dir']}/{details}"
@ -543,7 +547,7 @@ qt_config_compile_test("{details}"
include = f"#include <{include}>" include = f"#include <{include}>"
return include return include
include ="" include = ""
if is_library_test: if is_library_test:
if inherit_details: if inherit_details:
inherited_lib_data = data["libraries"][inherited_test_name] inherited_lib_data = data["libraries"][inherited_test_name]
@ -563,7 +567,7 @@ qt_config_compile_test("{details}"
tail = "\n".join(tail) tail = "\n".join(tail)
return tail return tail
tail ="" tail = ""
if inherit_details: if inherit_details:
tail += resolve_tail(inherit_details) tail += resolve_tail(inherit_details)
tail += resolve_tail(details) tail += resolve_tail(details)
@ -671,7 +675,6 @@ qt_config_compile_test("{details}"
cm_fh.write(")\n\n") cm_fh.write(")\n\n")
# "tests": { # "tests": {
# "cxx11_future": { # "cxx11_future": {
# "label": "C++11 <future>", # "label": "C++11 <future>",
@ -766,16 +769,20 @@ def get_feature_mapping():
"cross_compile": None, "cross_compile": None,
"debug_and_release": { "debug_and_release": {
"autoDetect": "1", # Setting this to None has weird effects... "autoDetect": "1", # Setting this to None has weird effects...
"condition": "QT_GENERATOR_IS_MULTI_CONFIG" "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"}, "dlopen": {"condition": "UNIX"},
"enable_gdb_index": None, "enable_gdb_index": None,
"enable_new_dtags": None, "enable_new_dtags": None,
"force_debug_info": { "force_debug_info": {
"autoDetect": "CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo OR RelWithDebInfo IN_LIST CMAKE_CONFIGURATION_TYPES" "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, "gc_binaries": None,
"gcc-sysroot": None, "gcc-sysroot": None,
"gcov": None, "gcov": None,
@ -1092,8 +1099,11 @@ def processSummaryHelper(ctx, entries, cm_fh):
if isinstance(entry, str): if isinstance(entry, str):
name = entry name = entry
cm_fh.write(f'qt_configure_add_summary_entry(ARGS "{name}")\n') cm_fh.write(f'qt_configure_add_summary_entry(ARGS "{name}")\n')
elif "type" in entry \ elif "type" in entry and entry["type"] in [
and entry["type"] in ["feature", "firstAvailableFeature", "featureList"]: "feature",
"firstAvailableFeature",
"featureList",
]:
function_args = [] function_args = []
entry_type = entry["type"] entry_type = entry["type"]
@ -1125,12 +1135,12 @@ def processSummaryHelper(ctx, entries, cm_fh):
condition = map_condition(entry["condition"]) condition = map_condition(entry["condition"])
function_args.append(lineify("CONDITION", condition, quote=False)) function_args.append(lineify("CONDITION", condition, quote=False))
entry_args_string = "".join(function_args) 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": 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": elif "type" in entry and entry["type"] == "buildMode":
message = entry["message"] 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: elif "section" in entry:
section = entry["section"] section = entry["section"]
cm_fh.write(f'qt_configure_add_summary_section(NAME "{section}")\n') 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) condition = map_condition(condition)
entry_args.append(lineify("CONDITION", condition, quote=False)) entry_args.append(lineify("CONDITION", condition, quote=False))
entry_args_string = "".join(entry_args) 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: else:
print(f" XXXX UNHANDLED REPORT TYPE {entry}.") print(f" XXXX UNHANDLED REPORT TYPE {entry}.")

View File

@ -43,7 +43,7 @@ class LibraryMapping:
emit_if: str = "", emit_if: str = "",
is_bundled_with_qt: bool = False, is_bundled_with_qt: bool = False,
test_library_overwrite: str = "", test_library_overwrite: str = "",
run_library_test: bool = False run_library_test: bool = False,
) -> None: ) -> None:
self.soName = soName self.soName = soName
self.packageName = packageName self.packageName = packageName
@ -226,7 +226,9 @@ _qt_library_map = [
"openglextensions", "Qt6", "Qt::OpenGLExtensions", extra=["COMPONENTS", "OpenGLExtensions"] "openglextensions", "Qt6", "Qt::OpenGLExtensions", extra=["COMPONENTS", "OpenGLExtensions"]
), ),
LibraryMapping("opengl", "Qt6", "Qt::OpenGL", extra=["COMPONENTS", "OpenGL"]), 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( LibraryMapping(
"package-lib", "Qt6", "Qt::AppManPackage", extra=["COMPONENTS", "AppManPackage"] "package-lib", "Qt6", "Qt::AppManPackage", extra=["COMPONENTS", "AppManPackage"]
), ),
@ -383,9 +385,7 @@ _qt_library_map = [
LibraryMapping( LibraryMapping(
"webkitwidgets", "Qt6", "Qt::WebKitWidgets", extra=["COMPONENTS", "WebKitWidgets"] "webkitwidgets", "Qt6", "Qt::WebKitWidgets", extra=["COMPONENTS", "WebKitWidgets"]
), ),
LibraryMapping( LibraryMapping("zlib", "Qt6", "Qt::Zlib", extra=["COMPONENTS", "Zlib"]),
"zlib", "Qt6", "Qt::Zlib", extra=["COMPONENTS", "Zlib"]
)
] ]
# Note that the library map is adjusted dynamically further down. # Note that the library map is adjusted dynamically further down.
@ -398,7 +398,9 @@ _library_map = [
LibraryMapping("directfb", "DirectFB", "PkgConfig::DirectFB"), LibraryMapping("directfb", "DirectFB", "PkgConfig::DirectFB"),
LibraryMapping("db2", "DB2", "DB2::DB2"), LibraryMapping("db2", "DB2", "DB2::DB2"),
LibraryMapping("dbus", "WrapDBus1", "dbus-1", resultVariable="DBus1"), LibraryMapping("dbus", "WrapDBus1", "dbus-1", resultVariable="DBus1"),
LibraryMapping("doubleconversion", "WrapDoubleConversion", "WrapDoubleConversion::WrapDoubleConversion"), LibraryMapping(
"doubleconversion", "WrapDoubleConversion", "WrapDoubleConversion::WrapDoubleConversion"
),
LibraryMapping("drm", "Libdrm", "Libdrm::Libdrm"), LibraryMapping("drm", "Libdrm", "Libdrm::Libdrm"),
LibraryMapping("egl", "EGL", "EGL::EGL"), LibraryMapping("egl", "EGL", "EGL::EGL"),
LibraryMapping("flite", "Flite", "Flite::Flite"), LibraryMapping("flite", "Flite", "Flite::Flite"),
@ -448,10 +450,17 @@ _library_map = [
"OpenSSL::SSL_nolink", "OpenSSL::SSL_nolink",
resultVariable="TEST_openssl_headers", resultVariable="TEST_openssl_headers",
appendFoundSuffix=False, appendFoundSuffix=False,
test_library_overwrite = "OpenSSL::SSL", test_library_overwrite="OpenSSL::SSL",
run_library_test=True 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("oci", "Oracle", "Oracle::OCI"),
LibraryMapping( LibraryMapping(
"pcre2", "WrapPCRE2", "WrapPCRE2::WrapPCRE2", extra=["REQUIRED"], is_bundled_with_qt=True "pcre2", "WrapPCRE2", "WrapPCRE2::WrapPCRE2", extra=["REQUIRED"], is_bundled_with_qt=True

View File

@ -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") dynlist_file = scope.get_files("QMAKE_DYNAMIC_LIST_FILE")
if dynlist_file: if dynlist_file:
dynlist_path = "${CMAKE_CURRENT_LIST_DIR}/" + dynlist_file[0] 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) 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') cm_fh.write(f'{ind} "LINKER:--dynamic-list={dynlist_path}")\n')
ind = spaces(indent) 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): def write_android_part(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):