forked from qt-creator/qt-creator
WebAssembly: Convert to new plugin setup scheme
Change-Id: I7d5def6084a0cc2cf164a4d72b693b44f8be7005 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -5,14 +5,19 @@
|
||||
#include "webassemblydevice.h"
|
||||
#include "webassemblytr.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/desktopdevice.h>
|
||||
#include <projectexplorer/devicesupport/idevicefactory.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace WebAssembly {
|
||||
namespace Internal {
|
||||
namespace WebAssembly::Internal {
|
||||
|
||||
WebAssemblyDevice::WebAssemblyDevice()
|
||||
class WebAssemblyDevice final : public DesktopDevice
|
||||
{
|
||||
public:
|
||||
WebAssemblyDevice()
|
||||
{
|
||||
setupId(IDevice::AutoDetected, Constants::WEBASSEMBLY_DEVICE_DEVICE_ID);
|
||||
setType(Constants::WEBASSEMBLY_DEVICE_TYPE);
|
||||
const QString displayNameAndType = Tr::tr("Web Browser");
|
||||
@@ -22,22 +27,31 @@ WebAssemblyDevice::WebAssemblyDevice()
|
||||
setMachineType(IDevice::Hardware);
|
||||
setOsType(OsTypeOther);
|
||||
setFileAccess(nullptr);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
IDevice::Ptr WebAssemblyDevice::create()
|
||||
IDevicePtr createWebAssemblyDevice()
|
||||
{
|
||||
return IDevicePtr(new WebAssemblyDevice);
|
||||
}
|
||||
|
||||
WebAssemblyDeviceFactory::WebAssemblyDeviceFactory()
|
||||
: ProjectExplorer::IDeviceFactory(Constants::WEBASSEMBLY_DEVICE_TYPE)
|
||||
class WebAssemblyDeviceFactory final : public IDeviceFactory
|
||||
{
|
||||
public:
|
||||
WebAssemblyDeviceFactory()
|
||||
: IDeviceFactory(Constants::WEBASSEMBLY_DEVICE_TYPE)
|
||||
{
|
||||
setDisplayName(Tr::tr("WebAssembly Runtime"));
|
||||
setCombinedIcon(":/webassembly/images/webassemblydevicesmall.png",
|
||||
":/webassembly/images/webassemblydevice.png");
|
||||
setConstructionFunction(&WebAssemblyDevice::create);
|
||||
setCreator(&WebAssemblyDevice::create);
|
||||
setConstructionFunction(&createWebAssemblyDevice);
|
||||
setCreator(&createWebAssemblyDevice);
|
||||
}
|
||||
};
|
||||
|
||||
void setupWebAssemblyDevice()
|
||||
{
|
||||
static WebAssemblyDeviceFactory theWebAssemblyDeviceFactory;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace WebAssembly
|
||||
} // WebAssembly::Internal
|
||||
|
||||
@@ -3,26 +3,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/devicesupport/desktopdevice.h>
|
||||
#include <projectexplorer/devicesupport/idevicefactory.h>
|
||||
#include <projectexplorer/devicesupport/idevicefwd.h>
|
||||
|
||||
namespace WebAssembly {
|
||||
namespace Internal {
|
||||
namespace WebAssembly::Internal {
|
||||
|
||||
class WebAssemblyDevice final : public ProjectExplorer::DesktopDevice
|
||||
{
|
||||
public:
|
||||
static ProjectExplorer::IDevice::Ptr create();
|
||||
ProjectExplorer::IDevicePtr createWebAssemblyDevice();
|
||||
|
||||
private:
|
||||
WebAssemblyDevice();
|
||||
};
|
||||
void setupWebAssemblyDevice();
|
||||
|
||||
class WebAssemblyDeviceFactory final : public ProjectExplorer::IDeviceFactory
|
||||
{
|
||||
public:
|
||||
WebAssemblyDeviceFactory();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace WebAssembly
|
||||
} // WebAssembly::Interenal
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "webassemblydevice.h"
|
||||
#include "webassemblyqtversion.h"
|
||||
#include "webassemblyrunconfiguration.h"
|
||||
#include "webassemblysettings.h"
|
||||
#include "webassemblytoolchain.h"
|
||||
#include "webassemblytr.h"
|
||||
|
||||
@@ -18,6 +17,8 @@
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
|
||||
@@ -31,47 +32,7 @@ using namespace Utils;
|
||||
|
||||
namespace WebAssembly::Internal {
|
||||
|
||||
class WebAssemblyPluginPrivate
|
||||
{
|
||||
public:
|
||||
WebAssemblyToolchainFactory toolChainFactory;
|
||||
WebAssemblyDeviceFactory deviceFactory;
|
||||
WebAssemblyQtVersionFactory qtVersionFactory;
|
||||
EmrunRunConfigurationFactory emrunRunConfigurationFactory;
|
||||
EmrunRunWorkerFactory emrunRunWorkerFactory;
|
||||
};
|
||||
|
||||
static WebAssemblyPluginPrivate *dd = nullptr;
|
||||
|
||||
WebAssemblyPlugin::WebAssemblyPlugin()
|
||||
{
|
||||
setObjectName("WebAssemblyPlugin");
|
||||
}
|
||||
|
||||
WebAssemblyPlugin::~WebAssemblyPlugin()
|
||||
{
|
||||
delete dd;
|
||||
dd = nullptr;
|
||||
}
|
||||
|
||||
void WebAssemblyPlugin::initialize()
|
||||
{
|
||||
dd = new WebAssemblyPluginPrivate;
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
addTest<WebAssemblyTest>();
|
||||
#endif // WITH_TESTS
|
||||
}
|
||||
|
||||
void WebAssemblyPlugin::extensionsInitialized()
|
||||
{
|
||||
connect(KitManager::instance(), &KitManager::kitsLoaded, this, [] {
|
||||
DeviceManager::instance()->addDevice(WebAssemblyDevice::create());
|
||||
askUserAboutEmSdkSetup();
|
||||
});
|
||||
}
|
||||
|
||||
void WebAssemblyPlugin::askUserAboutEmSdkSetup()
|
||||
static void askUserAboutEmSdkSetup()
|
||||
{
|
||||
const char setupWebAssemblyEmSdk[] = "SetupWebAssemblyEmSdk";
|
||||
|
||||
@@ -91,4 +52,32 @@ void WebAssemblyPlugin::askUserAboutEmSdkSetup()
|
||||
ICore::infoBar()->addInfo(info);
|
||||
}
|
||||
|
||||
class WebAssemblyPlugin final : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "WebAssembly.json")
|
||||
|
||||
public:
|
||||
void initialize() final
|
||||
{
|
||||
setupWebAssemblyToolchain();
|
||||
setupWebAssemblyDevice();
|
||||
setupWebAssemblyQtVersion();
|
||||
setupEmrunRunSupport();
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
addTest<WebAssemblyTest>();
|
||||
#endif // WITH_TESTS
|
||||
}
|
||||
void extensionsInitialized() final
|
||||
{
|
||||
connect(KitManager::instance(), &KitManager::kitsLoaded, this, [] {
|
||||
DeviceManager::instance()->addDevice(createWebAssemblyDevice());
|
||||
askUserAboutEmSdkSetup();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
} // WebAssembly::Internal
|
||||
|
||||
#include "webassemblyplugin.moc"
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
namespace WebAssembly::Internal {
|
||||
|
||||
class WebAssemblyPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "WebAssembly.json")
|
||||
|
||||
public:
|
||||
WebAssemblyPlugin();
|
||||
~WebAssemblyPlugin() override;
|
||||
|
||||
void initialize() override;
|
||||
void extensionsInitialized() override;
|
||||
static void askUserAboutEmSdkSetup();
|
||||
};
|
||||
|
||||
} // WebAssembly::Internal
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "webassemblyconstants.h"
|
||||
#include "webassemblyqtversion.h"
|
||||
|
||||
#include "webassemblyconstants.h"
|
||||
#include "webassemblytr.h"
|
||||
|
||||
#include <coreplugin/featureprovider.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/abi.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <remotelinux/remotelinux_constants.h>
|
||||
#include <coreplugin/featureprovider.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <qtsupport/qtversionfactory.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
|
||||
#include <remotelinux/remotelinux_constants.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -22,8 +27,7 @@
|
||||
using namespace QtSupport;
|
||||
using namespace Utils;
|
||||
|
||||
namespace WebAssembly {
|
||||
namespace Internal {
|
||||
namespace WebAssembly::Internal {
|
||||
|
||||
WebAssemblyQtVersion::WebAssemblyQtVersion() = default;
|
||||
|
||||
@@ -37,16 +41,6 @@ QSet<Id> WebAssemblyQtVersion::targetDeviceTypes() const
|
||||
return {Constants::WEBASSEMBLY_DEVICE_TYPE};
|
||||
}
|
||||
|
||||
WebAssemblyQtVersionFactory::WebAssemblyQtVersionFactory()
|
||||
{
|
||||
setQtVersionCreator([] { return new WebAssemblyQtVersion; });
|
||||
setSupportedType(Constants::WEBASSEMBLY_QT_VERSION);
|
||||
setPriority(1);
|
||||
setRestrictionChecker([](const SetupData &setup) {
|
||||
return setup.platforms.contains("wasm");
|
||||
});
|
||||
}
|
||||
|
||||
bool WebAssemblyQtVersion::isValid() const
|
||||
{
|
||||
return QtVersion::isValid() && qtVersion() >= minimumSupportedQtVersion();
|
||||
@@ -84,5 +78,23 @@ bool WebAssemblyQtVersion::isUnsupportedQtVersionInstalled()
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace WebAssembly
|
||||
class WebAssemblyQtVersionFactory final : public QtVersionFactory
|
||||
{
|
||||
public:
|
||||
WebAssemblyQtVersionFactory()
|
||||
{
|
||||
setQtVersionCreator([] { return new WebAssemblyQtVersion; });
|
||||
setSupportedType(Constants::WEBASSEMBLY_QT_VERSION);
|
||||
setPriority(1);
|
||||
setRestrictionChecker([](const SetupData &setup) {
|
||||
return setup.platforms.contains("wasm");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
void setupWebAssemblyQtVersion()
|
||||
{
|
||||
static WebAssemblyQtVersionFactory theWebAssemblyQtVersionFactory;
|
||||
}
|
||||
|
||||
} // WebAssembly::Internal
|
||||
|
||||
@@ -3,34 +3,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qtsupport/qtversionfactory.h>
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
|
||||
namespace WebAssembly {
|
||||
namespace Internal {
|
||||
namespace WebAssembly::Internal {
|
||||
|
||||
class WebAssemblyQtVersion : public QtSupport::QtVersion
|
||||
class WebAssemblyQtVersion final : public QtSupport::QtVersion
|
||||
{
|
||||
public:
|
||||
WebAssemblyQtVersion();
|
||||
|
||||
QString description() const override;
|
||||
QString description() const final;
|
||||
|
||||
QSet<Utils::Id> targetDeviceTypes() const override;
|
||||
QSet<Utils::Id> targetDeviceTypes() const final;
|
||||
|
||||
bool isValid() const override;
|
||||
QString invalidReason() const override;
|
||||
bool isValid() const final;
|
||||
QString invalidReason() const final;
|
||||
|
||||
static const QVersionNumber &minimumSupportedQtVersion();
|
||||
static bool isQtVersionInstalled();
|
||||
static bool isUnsupportedQtVersionInstalled();
|
||||
};
|
||||
|
||||
class WebAssemblyQtVersionFactory : public QtSupport::QtVersionFactory
|
||||
{
|
||||
public:
|
||||
WebAssemblyQtVersionFactory();
|
||||
};
|
||||
void setupWebAssemblyQtVersion();
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace WebAssembly
|
||||
} // WebAssembly::Internal
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
@@ -221,17 +222,31 @@ public:
|
||||
|
||||
// Factories
|
||||
|
||||
EmrunRunConfigurationFactory::EmrunRunConfigurationFactory()
|
||||
class EmrunRunConfigurationFactory final : public ProjectExplorer::RunConfigurationFactory
|
||||
{
|
||||
public:
|
||||
EmrunRunConfigurationFactory()
|
||||
{
|
||||
registerRunConfiguration<EmrunRunConfiguration>(Constants::WEBASSEMBLY_RUNCONFIGURATION_EMRUN);
|
||||
addSupportedTargetDeviceType(Constants::WEBASSEMBLY_DEVICE_TYPE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
EmrunRunWorkerFactory::EmrunRunWorkerFactory()
|
||||
class EmrunRunWorkerFactory final : public ProjectExplorer::RunWorkerFactory
|
||||
{
|
||||
public:
|
||||
EmrunRunWorkerFactory()
|
||||
{
|
||||
setProduct<EmrunRunWorker>();
|
||||
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
|
||||
addSupportedRunConfig(Constants::WEBASSEMBLY_RUNCONFIGURATION_EMRUN);
|
||||
}
|
||||
};
|
||||
|
||||
void setupEmrunRunSupport()
|
||||
{
|
||||
static EmrunRunConfigurationFactory theEmrunRunConfigurationFactory;
|
||||
static EmrunRunWorkerFactory theEmrunRunWorkerFactory;
|
||||
}
|
||||
|
||||
} // Webassembly::Internal
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
namespace WebAssembly::Internal {
|
||||
|
||||
@@ -13,17 +13,6 @@ using WebBrowserEntries = QList<WebBrowserEntry>;
|
||||
|
||||
WebBrowserEntries parseEmrunOutput(const QByteArray &output);
|
||||
|
||||
|
||||
class EmrunRunConfigurationFactory final : public ProjectExplorer::RunConfigurationFactory
|
||||
{
|
||||
public:
|
||||
EmrunRunConfigurationFactory();
|
||||
};
|
||||
|
||||
class EmrunRunWorkerFactory final : public ProjectExplorer::RunWorkerFactory
|
||||
{
|
||||
public:
|
||||
EmrunRunWorkerFactory();
|
||||
};
|
||||
void setupEmrunRunSupport();
|
||||
|
||||
} // Webassembly::Internal
|
||||
|
||||
@@ -26,8 +26,7 @@ using namespace ProjectExplorer;
|
||||
using namespace QtSupport;
|
||||
using namespace Utils;
|
||||
|
||||
namespace WebAssembly {
|
||||
namespace Internal {
|
||||
namespace WebAssembly::Internal {
|
||||
|
||||
static const Abi &toolChainAbi()
|
||||
{
|
||||
@@ -168,20 +167,28 @@ bool WebAssemblyToolChain::areToolChainsRegistered()
|
||||
return !ToolchainManager::findToolchains(toolChainAbi()).isEmpty();
|
||||
}
|
||||
|
||||
WebAssemblyToolchainFactory::WebAssemblyToolchainFactory()
|
||||
class WebAssemblyToolchainFactory final : public ToolchainFactory
|
||||
{
|
||||
public:
|
||||
WebAssemblyToolchainFactory()
|
||||
{
|
||||
setDisplayName(Tr::tr("Emscripten"));
|
||||
setSupportedToolChainType(Constants::WEBASSEMBLY_TOOLCHAIN_TYPEID);
|
||||
setSupportedLanguages({ProjectExplorer::Constants::C_LANGUAGE_ID,
|
||||
ProjectExplorer::Constants::CXX_LANGUAGE_ID});
|
||||
setToolchainConstructor([] { return new WebAssemblyToolChain; });
|
||||
setUserCreatable(true);
|
||||
}
|
||||
}
|
||||
|
||||
Toolchains WebAssemblyToolchainFactory::autoDetect(const ToolchainDetector &detector) const
|
||||
{
|
||||
Toolchains autoDetect(const ToolchainDetector &detector) const
|
||||
{
|
||||
return doAutoDetect(detector);
|
||||
}
|
||||
};
|
||||
|
||||
void setupWebAssemblyToolchain()
|
||||
{
|
||||
static WebAssemblyToolchainFactory theWebAssemblyToolchainFactory;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace WebAssembly
|
||||
} // WebAssembly::Internal
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
#include <QVersionNumber>
|
||||
|
||||
namespace WebAssembly {
|
||||
namespace Internal {
|
||||
namespace WebAssembly::Internal {
|
||||
|
||||
class WebAssemblyToolChain final : public ProjectExplorer::GccToolChain
|
||||
{
|
||||
@@ -25,14 +24,6 @@ public:
|
||||
static bool areToolChainsRegistered();
|
||||
};
|
||||
|
||||
class WebAssemblyToolchainFactory : public ProjectExplorer::ToolchainFactory
|
||||
{
|
||||
public:
|
||||
WebAssemblyToolchainFactory();
|
||||
void setupWebAssemblyToolchain();
|
||||
|
||||
ProjectExplorer::Toolchains autoDetect(
|
||||
const ProjectExplorer::ToolchainDetector &detector) const final;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace WebAssembly
|
||||
} // WebAssembly::Internal
|
||||
|
||||
Reference in New Issue
Block a user