WebAssembly: Revamp Emscripten SDK registration and toolchain handling

Qt Creator's ability to register Emscripten toolchains depended on an
SDK being activated "globally", and on the presence of the ~/.emscripten
file. Qt Creator would parse that file in order to determine the
location of the compiler and the necessary environment variables that
have to be set.

As of recently, the Emscripten SDK does neither activate gobally
anymore, nor is the ~/.emscripten generated. This change here addresses
the new situation in a couple of ways:

- Instead of trying to silently detect everything, add a UI
(IOptionsPageWidget) that lets the user select the Emscripten SDK root.
- Instead of parsing the ~/.emscripten file, parse the output of the
emsdk_env tool to determine the toolchain environment
(ToolChain::addToEnvironment). The parsing is cached. A test for the
parsing is included.
- Instead of registering the underlying clang as compiler, register the
emcc/em++ wrapper scripts, which are (also as of recently) compatible
with Qt Creator's way of determining gcc's predefined macros and built-
in header paths.

One Emscripten SDK is registered globally in Qt Creator. When changing
that, the previous Emscripten toolchains are removed, the new ones are
registered and the kit are "fixed" to use those.

On startup, an InfoBar entry is shown if Qt for Webassembly kits exist
and no Emscripten toolchains are present. That's the case for first-time
use after installing Qt for Webassembly via Qt SDK installer. The
InfoBar entry opens up the IOptionsPageWidget.

Qt 5.15.0 for WebAssembly and Emscripten SDK 1.39.0 are the minimum
supported versions. The new UI will show warnings accordingly.

Task-number: QTCREATORBUG-24811
Fixes: QTCREATORBUG-24822
Fixes: QTCREATORBUG-24814
Fixes: QTCREATORBUG-23741
Fixes: QTCREATORBUG-23561
Fixes: QTCREATORBUG-23160
Fixes: QTCREATORBUG-23126
Change-Id: I017c61586b17e815bb20a90e3f305a6bf705da36
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Alessandro Portale
2020-11-03 00:20:43 +01:00
parent 783a06b2ee
commit b057ea1ab8
15 changed files with 712 additions and 110 deletions

View File

@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
@@ -43,11 +43,21 @@ namespace Internal {
static CommandLine emrunCommand(Target *target, const QString &browser, const QString &port)
{
if (BuildConfiguration *bc = target->activeBuildConfiguration()) {
const QFileInfo emrunScript = bc->environment().searchInPath("emrun").toFileInfo();
const QFileInfo emrun = bc->environment().searchInPath("emrun").toFileInfo();
auto html = bc->buildDirectory().pathAppended(target->project()->displayName() + ".html");
return CommandLine(bc->environment().searchInPath("python"), {
emrunScript.absolutePath() + "/" + emrunScript.baseName() + ".py",
// On Windows, we need to use the python interpreter (it comes with the emsdk) to ensure
// that the web server is killed when the application is stopped in Qt Creator.
// On Non-windows, we prefer using the shell script, because that knows how to find the
// right python (not part of emsdk). The shell script stays attached to the server process.
const FilePath interpreter = bc->environment().searchInPath(
QLatin1String(HostOsInfo::isWindowsHost() ? "python" : "sh"));
const QString emrunLaunchScript = HostOsInfo::isWindowsHost()
? emrun.absolutePath() + "/" + emrun.baseName() + ".py"
: emrun.absoluteFilePath();
return CommandLine(interpreter, {
emrunLaunchScript,
"--browser", browser,
"--port", port,
"--no_emrun_detect",