wasm: make preload_qml_imports take a source path

This was running qmlimportscanner on ".", which in some
cases would recurse down the qt/ symlink in the app
build directory (used with dynamic linking on wasm),
and find all of the imports from the Qt installation.

Make it take a path instead. Users can then provide
a path to the QML sources which will be passed to
qmlimportscanner

Change-Id: Ib5175e5dc1d26875c42f5a3e286314b7d602c9fe

Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Morten Sørvig 2024-01-24 14:45:36 +01:00
parent 4281495f52
commit 3424234579

View File

@ -80,21 +80,20 @@ def extract_preload_files_from_imports(imports):
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python make_qt_symlinks.py <qt-host-path> <qt-wasm-path>")
if len(sys.argv) != 4:
print("Usage: python preload_qml_imports.py <qml-source-path> <qt-host-path> <qt-wasm-path>")
sys.exit(1)
qt_host_path = sys.argv[1]
qt_wasm_path = sys.argv[2]
qml_source_path = sys.argv[1]
qt_host_path = sys.argv[2]
qt_wasm_path = sys.argv[3]
qml_import_path = os.path.join(qt_wasm_path, "qml")
qmlimportsscanner_path = os.path.join(qt_host_path, "libexec/qmlimportscanner")
eprint("runing qmlimportsscanner")
result = subprocess.run(
[qmlimportsscanner_path, "-rootPath", ".", "-importPath", qml_import_path],
stdout=subprocess.PIPE,
)
command = [qmlimportsscanner_path, "-rootPath", qml_source_path, "-importPath", qml_import_path]
result = subprocess.run(command, stdout=subprocess.PIPE)
imports = json.loads(result.stdout)
preload_files = []