From d21bfee667ce0c6a6c66bb1d1c9481af5816eb97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wierci=C5=84ski?= Date: Wed, 7 Feb 2024 17:02:13 +0100 Subject: [PATCH] wasm: Fix duplication of .so files in preload_qml_imports.py The naive approach of "find_dependencies()" function, sometimes finds a given plugin itself as its own dependency, which results in duplication and wrong paths. Remove the plugin from its own dependencies list if needed. Task-number: QTBUG-121833 Change-Id: I4cf30233cfc291d360f69158bd12bd36024832be Reviewed-by: Lorn Potter --- util/wasm/preload/preload_qml_imports.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/util/wasm/preload/preload_qml_imports.py b/util/wasm/preload/preload_qml_imports.py index 3e936dce223..a572f1f0ec1 100755 --- a/util/wasm/preload/preload_qml_imports.py +++ b/util/wasm/preload/preload_qml_imports.py @@ -44,25 +44,27 @@ def find_dependencies(filepath): def extract_preload_files_from_imports(imports): libraries = [] - files = [] for qml_import in imports: try: relative_path = qml_import["relativePath"] plugin = qml_import["plugin"] # plugin .so + plugin_filename = "lib" + plugin + ".so" so_plugin_source_path = os.path.join( - qt_qml_path, relative_path, "lib" + plugin + ".so" + qt_qml_path, relative_path, plugin_filename ) so_plugin_destination_path = os.path.join( - qt_deploy_qml_path, relative_path, "lib" + plugin + ".so" + qt_deploy_qml_path, relative_path, plugin_filename ) preload_file(so_plugin_source_path, so_plugin_destination_path) so_plugin_qt_install_path = os.path.join( - qt_wasm_path, "qml", relative_path, "lib" + plugin + ".so" + qt_wasm_path, "qml", relative_path, plugin_filename ) deps = find_dependencies(so_plugin_qt_install_path) + if plugin_filename in deps: # sometimes plugin file itself is found as its dependency + deps.remove(plugin_filename) libraries.extend(deps) # qmldir file @@ -74,7 +76,7 @@ def extract_preload_files_from_imports(imports): except Exception as e: eprint(e) continue - return files, libraries + return libraries if __name__ == "__main__": @@ -96,8 +98,7 @@ if __name__ == "__main__": imports = json.loads(result.stdout) preload_files = [] - libraries = [] - files, libraries = extract_preload_files_from_imports(imports) + libraries = extract_preload_files_from_imports(imports) # Deploy plugin dependencies, that is, shared libraries used by the plugins. # Skip some of the obvious libraries which will be