Skip to content

Commit

Permalink
Revert "wasm: Generate plugin preloads for dynamic linking at install…
Browse files Browse the repository at this point in the history
… step"

This reverts commit f0f89d3.

Reason for revert: Breaks qttools. Installs without consent in user projects.

Fixes: QTBUG-130717
Change-Id: I2a856cc89cc144f9d69c75a396ba9b8fa4fba482
Reviewed-by: Alexey Edelev <[email protected]>
  • Loading branch information
alcroito committed Oct 31, 2024
1 parent 48f9ab0 commit 9804741
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 64 deletions.
8 changes: 0 additions & 8 deletions cmake/QtBaseGlobalTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,9 @@ if(APPLE)
elseif(WASM)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/util/wasm/wasmtestrunner/qt-wasmtestrunner.py"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/qt-wasmtestrunner.py" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/util/wasm/preload/preload_qml_imports.py"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/preload_qml_imports.py" COPYONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/util/wasm/preload/preload_qt_plugins.py"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/preload_qt_plugins.py" COPYONLY)

qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/qt-wasmtestrunner.py"
DESTINATION "${INSTALL_LIBEXECDIR}")
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/preload_qml_imports.py"
DESTINATION "${INSTALL_LIBEXECDIR}")
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/preload_qt_plugins.py"
DESTINATION "${INSTALL_LIBEXECDIR}")
endif()

# Install CI support files to libexec.
Expand Down
43 changes: 0 additions & 43 deletions src/corelib/Qt6WasmMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,49 +91,6 @@ function(_qt_internal_wasm_add_target_helpers target)
${_target_directory}/qtloader.js COPYONLY)
configure_file("${WASM_BUILD_DIR}/plugins/platforms/qtlogo.svg"
${_target_directory}/qtlogo.svg COPYONLY)

if(QT_FEATURE_shared)
configure_file("${WASM_BUILD_DIR}/libexec/preload_qml_imports.py"
${_target_directory}/preload_qml_imports.py COPYONLY)
configure_file("${WASM_BUILD_DIR}/libexec/preload_qt_plugins.py"
${_target_directory}/preload_qt_plugins.py COPYONLY)
endif()

if(CMAKE_STAGING_PREFIX)
install(FILES
${_target_directory}/qtloader.js
${_target_directory}/qtlogo.svg
${_target_directory}/${_target_output_name}.html
${_target_directory}/${_target_output_name}.wasm
${_target_directory}/${_target_output_name}.js
DESTINATION ${CMAKE_STAGING_PREFIX})
if(QT_FEATURE_thread)
install(FILES
${_target_directory}/${_target_output_name}.worker.js
DESTINATION ${CMAKE_STAGING_PREFIX})
endif()

if(QT_FEATURE_shared)
find_package(Python3 COMPONENTS Interpreter)
if(Python3_Interpreter_FOUND)
install(FILES
${_target_directory}/preload_qml_imports.py
${_target_directory}/preload_qt_plugins.py
DESTINATION ${CMAKE_STAGING_PREFIX})
install(CODE "execute_process(COMMAND ${Python3_EXECUTABLE} \
${_target_directory}/preload_qml_imports.py \
${CMAKE_CURRENT_SOURCE_DIR} ${QT_HOST_PATH} \
${QT6_INSTALL_PREFIX} \
${CMAKE_STAGING_PREFIX})")
install(CODE "execute_process(COMMAND ${Python3_EXECUTABLE} \
${_target_directory}/preload_qt_plugins.py \
${QT6_INSTALL_PREFIX} \
${CMAKE_STAGING_PREFIX})")
else()
message(WARNING "Python 3 not found. Generating preload list for dynamic linking is disabled.")
endif()
endif()
endif()
endif()
endif()
endif()
Expand Down
15 changes: 9 additions & 6 deletions util/wasm/preload/preload_qml_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
qt_deploy_qml_path = "/qt/qml"


def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)


def preload_file(source, destination):
preload_files.append({"source": source, "destination": destination})

Expand Down Expand Up @@ -51,23 +55,24 @@ def extract_preload_files_from_imports(imports):
)
preload_file(qmldir_source_path, qmldir_destination_path)
except Exception as e:
eprint(e)
continue
return libraries


if __name__ == "__main__":
if len(sys.argv) != 5:
print("Usage: python preload_qml_imports.py <qml-source-path> <qt-host-path> <qt-wasm-path> <output-dir>")
if len(sys.argv) != 4:
print("Usage: python preload_qml_imports.py <qml-source-path> <qt-host-path> <qt-wasm-path>")
sys.exit(1)

qml_source_path = sys.argv[1]
qt_host_path = sys.argv[2]
qt_wasm_path = sys.argv[3]
output_dir = sys.argv[4]

qml_import_path = os.path.join(qt_wasm_path, "qml")
qmlimportsscanner_path = os.path.join(qt_host_path, "libexec/qmlimportscanner")

eprint("runing qmlimportsscanner")
command = [qmlimportsscanner_path, "-rootPath", qml_source_path, "-importPath", qml_import_path]
result = subprocess.run(command, stdout=subprocess.PIPE)
imports = json.loads(result.stdout)
Expand All @@ -93,6 +98,4 @@ def extract_preload_files_from_imports(imports):
destination = os.path.join("/", library)
preload_file(source, destination)

with open(f"{output_dir}/qt_qml_imports.json", "w") as f:
f.write(json.dumps(preload_files, indent=2))

print(json.dumps(preload_files, indent=2))
11 changes: 4 additions & 7 deletions util/wasm/preload/preload_qt_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ def find_so_files(directory):


if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python preload_qt_plugins.py <qt-wasm-path> <output-dir>")
if len(sys.argv) != 2:
print("Usage: python make_qt_symlinks.py <qt-wasm-path>")
sys.exit(1)

qt_wasm_path = sys.argv[1]
output_dir = sys.argv[2]

# preload all plugins
plugins = find_so_files(os.path.join(qt_wasm_path, "plugins"))
Expand All @@ -48,10 +47,8 @@ def find_so_files(directory):
# and QML imports in /qt/plugins and /qt/qml. The qt.conf file is
# written to the current directory.
qtconf = "[Paths]\nPrefix = /qt\n"
with open(f"{output_dir}/qt.conf", "w") as f:
with open("qt.conf", "w") as f:
f.write(qtconf)
preload.append({"source": "qt.conf", "destination": "/qt.conf"})

with open(f"{output_dir}/qt_plugins.json", "w") as f:
f.write(json.dumps(preload, indent=2))

print(json.dumps(preload, indent=2))

0 comments on commit 9804741

Please sign in to comment.