forked from qt-creator/qt-creator
WebAssembly: fix the running of targets with name != project.name
The new QtQuick application wizard for Qt 6.2-based applications now uses different names for the project and for the main target. The WebAssembly plugin cannot construct the html file name for launching like <projectname>.html, anymore. It instead would need to use <targetname>.html for that. The author of this patch did not manage to programmatically retrieve the target name or buildkey. So, as a hack, we simply chose the first html file that we find in the build directory. Fixes: QTCREATORBUG-26562 Change-Id: I7e929fe265a15501c7275e2c76b7f5fa4ed1e6b5 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -55,14 +55,20 @@ static FilePath pythonInterpreter(const Environment &env)
|
||||
return {};
|
||||
}
|
||||
|
||||
static CommandLine emrunCommand(Target *target, const QString &browser, const QString &port)
|
||||
static FilePath htmlFileInDir(const FilePath &dir)
|
||||
{
|
||||
if (BuildConfiguration *bc = target->activeBuildConfiguration()) {
|
||||
const FilePaths htmlFiles = dir.dirEntries(QStringList("*.html"), QDir::Files);
|
||||
return htmlFiles.isEmpty() ? FilePath() : htmlFiles.first();
|
||||
}
|
||||
|
||||
static CommandLine emrunCommand(const RunConfiguration *rc, const QString &browser,
|
||||
const QString &port)
|
||||
{
|
||||
if (BuildConfiguration *bc = rc->target()->activeBuildConfiguration()) {
|
||||
const Environment env = bc->environment();
|
||||
const FilePath emrun = env.searchInPath("emrun");
|
||||
const FilePath emrunPy = emrun.absolutePath().pathAppended(emrun.baseName() + ".py");
|
||||
const FilePath html =
|
||||
bc->buildDirectory().pathAppended(target->project()->displayName() + ".html");
|
||||
const FilePath html = htmlFileInDir(bc->buildDirectory());
|
||||
|
||||
return CommandLine(pythonInterpreter(env), {
|
||||
emrunPy.path(),
|
||||
@@ -91,8 +97,8 @@ public:
|
||||
effectiveEmrunCall->setDisplayStyle(StringAspect::TextEditDisplay);
|
||||
effectiveEmrunCall->setReadOnly(true);
|
||||
|
||||
setUpdater([target, effectiveEmrunCall, webBrowserAspect] {
|
||||
effectiveEmrunCall->setValue(emrunCommand(target,
|
||||
setUpdater([this, effectiveEmrunCall, webBrowserAspect] {
|
||||
effectiveEmrunCall->setValue(emrunCommand(this,
|
||||
webBrowserAspect->currentBrowser(),
|
||||
"<port>").toUserOutput());
|
||||
});
|
||||
@@ -122,7 +128,7 @@ public:
|
||||
|
||||
setStarter([this, runControl, portsGatherer] {
|
||||
Runnable r;
|
||||
r.command = emrunCommand(runControl->target(),
|
||||
r.command = emrunCommand(runControl->runConfiguration(),
|
||||
runControl->aspect<WebBrowserSelectionAspect>()->currentBrowser(),
|
||||
QString::number(portsGatherer->findEndPoint().port()));
|
||||
SimpleTargetRunner::doStart(r, {});
|
||||
|
||||
Reference in New Issue
Block a user