diff options
| author | Saikari <[email protected]> | 2026-02-23 06:48:12 +0300 |
|---|---|---|
| committer | Saikari <[email protected]> | 2026-02-23 06:48:12 +0300 |
| commit | 8ed3f12c86b74cb46e110e56c2ed20d88b242cee (patch) | |
| tree | c450f74c90a9c4b7166143535910c3c250f0a865 | |
| parent | 8990dc87238706323e46239368007de9a8f4c5c8 (diff) | |
todo
| -rw-r--r-- | xmake/rules/qt/load.lua | 27 | ||||
| -rw-r--r-- | xmake/rules/qt/xmake.lua | 3 |
2 files changed, 20 insertions, 10 deletions
diff --git a/xmake/rules/qt/load.lua b/xmake/rules/qt/load.lua index f24e319b3..2c7b6c73f 100644 --- a/xmake/rules/qt/load.lua +++ b/xmake/rules/qt/load.lua @@ -278,15 +278,24 @@ function main(target, opt) local plugins = target:values("qt.plugins") if plugins then local importfile = path.join(config.builddir(), ".qt", "plugin", target:name(), "static_import.cpp") - local file = io.open(importfile, "w") - if file then - file:print("#include <QtPlugin>") - for _, plugin in ipairs(plugins) do - file:print("Q_IMPORT_PLUGIN(%s)", plugin) + local content = "#include <QtPlugin>\n" + for _, plugin in ipairs(plugins) do + content = content .. string.format("Q_IMPORT_PLUGIN(%s)\n", plugin) + end + + local old_content = "" + if os.isfile(importfile) then + old_content = io.readfile(importfile) + end + + if old_content ~= content then + local file = io.open(importfile, "w") + if file then + file:write(content) + file:close() end - file:close() - target:add("files", importfile) end + target:add("files", importfile) end -- backup the user syslinks, we need to add them behind the qt syslinks @@ -505,12 +514,12 @@ function main(target, opt) -- FS is required for qtloader.js even if we don't use preload files target:add("ldflags", "-s EXPORTED_RUNTIME_METHODS=UTF16ToString,stringToUTF16,JSEvents,specialHTMLTargets,FS,callMain,cwrap,ccall,setValue,getValue,UTF8ToString,stringToUTF8") -- @see https://github.com/emscripten-core/emscripten/issues/21844 Export main and emscripten_thread_crashed for qtloader.js - target:add("ldflags", "-s EXPORTED_FUNCTIONS=_main", {force = true}) + target:add("ldflags", "-s EXPORTED_FUNCTIONS=_main,_malloc,_free") target:add("ldflags", "-s MODULARIZE=1", "-s EXPORT_NAME=createQtAppInstance") target:add("shflags", "-s MAX_WEBGL_VERSION=2", "-s WASM_BIGINT=1", "-s ASSERTIONS=0") target:add("shflags", "-sASYNCIFY_IMPORTS=qt_asyncify_suspend_js,qt_asyncify_resume_js") target:add("shflags", "-s EXPORTED_RUNTIME_METHODS=UTF16ToString,stringToUTF16,JSEvents,specialHTMLTargets,FS,callMain,cwrap,ccall,setValue,getValue,UTF8ToString,stringToUTF8") - target:add("shflags", "-s EXPORTED_FUNCTIONS=_main", {force = true}) + target:add("shflags", "-s EXPORTED_FUNCTIONS=_main,_malloc,_free") target:add("shflags", "-s MODULARIZE=1", "-s EXPORT_NAME=createQtAppInstance") target:set("extension", ".js") else diff --git a/xmake/rules/qt/xmake.lua b/xmake/rules/qt/xmake.lua index 4adf4971e..f8ad260f7 100644 --- a/xmake/rules/qt/xmake.lua +++ b/xmake/rules/qt/xmake.lua @@ -31,7 +31,8 @@ rule("qt._wasm_app") os.vcp(path.join(pluginsdir, "platforms/wasm_shell.html"), htmlfile) io.gsub(htmlfile, "@APPNAME@", target:name()) import("core.base.semver") - if qt.sdkver and semver.new(qt.sdkver):ge("6.0") then + local qt_sdkver = qt.sdkver or target:data("qt_sdkver") + if qt_sdkver and semver.new(qt_sdkver):ge("6.0") then io.gsub(htmlfile, "@APPEXPORTNAME@", "createQtAppInstance") local preload = "" -- @see https://github.com/xmake-io/xmake/issues/6182 |
