-
-
Notifications
You must be signed in to change notification settings - Fork 892
Description
Xmake 版本
xmake v3.0.4+20251018
操作系统版本和架构
Fedora 43
描述问题
Hello,
I am encountering an issue when building a Qt 6.9.1 application for WebAssembly. The build and run process completes successfully, but the generated HTML file contains a raw template placeholder @APPEXPORTNAME@ that xmake failed to replace.
This causes the browser to crash immediately with a syntax error because @ is an illegal character in the generated JavaScript.
Note: With the same code and setting, but change the platform to linux x86_64 works perferctly.
Environment:
Qt Version: 6.9.1 install through xpack
Emcc: 3.1.70 ( Match with Qt Version 6.9 according to Qt doc)
期待的结果
It seems xmake's internal Qt rule copies the template but only replaces @appName@ and misses this new @APPEXPORTNAME@ placeholder introduced in Qt 6.9.
The qt.quickapp build rule for Wasm likely needs to be updated to detect @APPEXPORTNAME@ and replace it.
工程配置
set_config("plat", "wasm")
set_config("arch", "wasm32")
add_rules("mode.debug", "mode.release")
add_rules("plugin.compile_commands.autoupdate", { outputdir = "." })
add_requires("qt6quick")
if is_plat("wasm") then
add_cxxflags("-pthread", { force = true })
add_ldflags(
"-pthread",
" -s USE_PTHREADS=1 ",
" -s PROXY_TO_PTHREAD=1",
-- "-s PTHREAD_POOL_SIZE=8",
-- " -s ALLOW_MEMORY_GROWTH=1",
{ force = true }
)
end
target("qt-app")
set_kind("binary")
add_rules("qt.quickapp")
add_files("src/*.cpp")
add_files("src/qml.qrc")
add_packages("qt6quick")Build and run successfully
xmake clean && xmake f -c -v && rm -rf build/ .xmake/ .cache/
xmake b
emrun build/wasm/wasm32/release/qt_demo.html附加信息和错误日志
Uncaught SyntaxError: illegal character U+0040
Uncaught ReferenceError: init is not definedThe generated html file after built. Error of the line entryFunction: window.@APPEXPORTNAME@
<script type="text/javascript">
async function init()
{
const spinner = document.querySelector('#qtspinner');
const screen = document.querySelector('#screen');
const status = document.querySelector('#qtstatus');
const showUi = (ui) => {
[spinner, screen].forEach(element => element.style.display = 'none');
if (screen === ui)
screen.style.position = 'default';
ui.style.display = 'block';
}
try {
showUi(spinner);
status.innerHTML = 'Loading...';
const instance = await qtLoad({
qt: {
onLoaded: () => showUi(screen),
onExit: exitData =>
{
status.innerHTML = 'Application exit';
status.innerHTML +=
exitData.code !== undefined ? ` with code ${exitData.code}` : '';
status.innerHTML +=
exitData.text !== undefined ? ` (${exitData.text})` : '';
showUi(spinner);
},
entryFunction: window.@APPEXPORTNAME@,
containerElements: [screen],
@PRELOAD@
}
});
} catch (e) {
console.error(e);
console.error(e.stack);
}
}
</script>
<script src="qt-app.js"></script>
<script type="text/javascript" src="qtloader.js"></script>