forked from qt-creator/qt-creator
ProjectExplorer: Always assume a BuildInfo has a factory
The purpose of a BuildInfo is to create a BuildConfiguration via its factory. It's confusing if code treats a null factory as a valid condition. Change-Id: I2efd45c2f8f82b927aa300370fc39d991a5f8fa2 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1097,6 +1097,8 @@ void Project::setup(const QList<BuildInfo> &infoList)
|
|||||||
|
|
||||||
BuildConfiguration *Project::setup(const BuildInfo &info)
|
BuildConfiguration *Project::setup(const BuildInfo &info)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(info.factory, return nullptr);
|
||||||
|
|
||||||
Kit *k = KitManager::kit(info.kitId);
|
Kit *k = KitManager::kit(info.kitId);
|
||||||
if (!k)
|
if (!k)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -1109,12 +1111,9 @@ BuildConfiguration *Project::setup(const BuildInfo &info)
|
|||||||
|
|
||||||
QTC_ASSERT(t, return nullptr);
|
QTC_ASSERT(t, return nullptr);
|
||||||
|
|
||||||
BuildConfiguration *bc = nullptr;
|
BuildConfiguration * const bc = info.factory->create(t, info);
|
||||||
if (info.factory) {
|
|
||||||
bc = info.factory->create(t, info);
|
|
||||||
if (bc)
|
if (bc)
|
||||||
t->addBuildConfiguration(bc);
|
t->addBuildConfiguration(bc);
|
||||||
}
|
|
||||||
if (newTarget) {
|
if (newTarget) {
|
||||||
newTarget->updateDefaultDeployConfigurations();
|
newTarget->updateDefaultDeployConfigurations();
|
||||||
newTarget->updateDefaultRunConfigurations();
|
newTarget->updateDefaultRunConfigurations();
|
||||||
|
@@ -138,6 +138,10 @@ const QList<BuildInfo> ProjectImporter::import(const Utils::FilePath &importPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto factory = BuildConfigurationFactory::find(k, projectFilePath());
|
auto factory = BuildConfigurationFactory::find(k, projectFilePath());
|
||||||
|
if (!factory) {
|
||||||
|
qCDebug(log) << "No factory for kit" << k->displayName();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (BuildInfo i : infoList) {
|
for (BuildInfo i : infoList) {
|
||||||
i.displayName = Tr::tr("%1 (imported)").arg(i.displayName);
|
i.displayName = Tr::tr("%1 (imported)").arg(i.displayName);
|
||||||
i.kitId = k->id();
|
i.kitId = k->id();
|
||||||
|
@@ -129,7 +129,6 @@ void TargetSetupWidget::addBuildInfo(const BuildInfo &info, bool isImport)
|
|||||||
store.isEnabled = info.enabledByDefault;
|
store.isEnabled = info.enabledByDefault;
|
||||||
++m_selected;
|
++m_selected;
|
||||||
|
|
||||||
if (info.factory) {
|
|
||||||
store.checkbox = new QCheckBox;
|
store.checkbox = new QCheckBox;
|
||||||
store.checkbox->setText(info.displayName);
|
store.checkbox->setText(info.displayName);
|
||||||
store.checkbox->setChecked(store.isEnabled);
|
store.checkbox->setChecked(store.isEnabled);
|
||||||
@@ -154,7 +153,6 @@ void TargetSetupWidget::addBuildInfo(const BuildInfo &info, bool isImport)
|
|||||||
[this, checkBox = store.checkbox](bool b) { checkBoxToggled(checkBox, b); });
|
[this, checkBox = store.checkbox](bool b) { checkBoxToggled(checkBox, b); });
|
||||||
connect(store.pathChooser, &PathChooser::rawPathChanged, this,
|
connect(store.pathChooser, &PathChooser::rawPathChanged, this,
|
||||||
[this, pathChooser = store.pathChooser] { pathChanged(pathChooser); });
|
[this, pathChooser = store.pathChooser] { pathChanged(pathChooser); });
|
||||||
}
|
|
||||||
|
|
||||||
store.hasIssues = false;
|
store.hasIssues = false;
|
||||||
m_infoStore.emplace_back(std::move(store));
|
m_infoStore.emplace_back(std::move(store));
|
||||||
@@ -283,8 +281,7 @@ void TargetSetupWidget::clear()
|
|||||||
void TargetSetupWidget::updateDefaultBuildDirectories()
|
void TargetSetupWidget::updateDefaultBuildDirectories()
|
||||||
{
|
{
|
||||||
for (const BuildInfo &buildInfo : buildInfoList(m_kit, m_projectPath)) {
|
for (const BuildInfo &buildInfo : buildInfoList(m_kit, m_projectPath)) {
|
||||||
if (!buildInfo.factory)
|
QTC_ASSERT(buildInfo.factory, continue);
|
||||||
continue;
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (BuildInfoStore &buildInfoStore : m_infoStore) {
|
for (BuildInfoStore &buildInfoStore : m_infoStore) {
|
||||||
if (buildInfoStore.buildInfo.typeName == buildInfo.typeName) {
|
if (buildInfoStore.buildInfo.typeName == buildInfo.typeName) {
|
||||||
@@ -348,16 +345,14 @@ void TargetSetupWidget::reportIssues(int index)
|
|||||||
|
|
||||||
QPair<Task::TaskType, QString> TargetSetupWidget::findIssues(const BuildInfo &info)
|
QPair<Task::TaskType, QString> TargetSetupWidget::findIssues(const BuildInfo &info)
|
||||||
{
|
{
|
||||||
if (m_projectPath.isEmpty() || !info.factory)
|
QTC_ASSERT(info.factory, return std::make_pair(Task::Unknown, QString()));
|
||||||
|
if (m_projectPath.isEmpty())
|
||||||
return {Task::Unknown, {}};
|
return {Task::Unknown, {}};
|
||||||
|
|
||||||
Tasks issues;
|
const Tasks issues = info.factory->reportIssues(m_kit, m_projectPath, info.buildDirectory);
|
||||||
if (info.factory)
|
|
||||||
issues = info.factory->reportIssues(m_kit, m_projectPath, info.buildDirectory);
|
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
Task::TaskType highestType = Task::Unknown;
|
Task::TaskType highestType = Task::Unknown;
|
||||||
for (const Task &t : std::as_const(issues)) {
|
for (const Task &t : issues) {
|
||||||
if (!text.isEmpty())
|
if (!text.isEmpty())
|
||||||
text.append(QLatin1String("<br>"));
|
text.append(QLatin1String("<br>"));
|
||||||
// set severity:
|
// set severity:
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
#include <utils/mimeconstants.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/temporarydirectory.h>
|
#include <utils/temporarydirectory.h>
|
||||||
|
|
||||||
@@ -108,6 +109,8 @@ Kit *QtProjectImporter::createTemporaryKit(const QtVersionData &versionData,
|
|||||||
|
|
||||||
#if WITH_TESTS
|
#if WITH_TESTS
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <extensionsystem/pluginspec.h>
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/buildinfo.h>
|
#include <projectexplorer/buildinfo.h>
|
||||||
|
|
||||||
@@ -117,6 +120,23 @@ Kit *QtProjectImporter::createTemporaryKit(const QtVersionData &versionData,
|
|||||||
|
|
||||||
namespace QtSupport::Internal {
|
namespace QtSupport::Internal {
|
||||||
|
|
||||||
|
class TestBuildConfigFactory : public BuildConfigurationFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TestBuildConfigFactory()
|
||||||
|
{
|
||||||
|
for (ExtensionSystem::PluginSpec * const spec : ExtensionSystem::PluginManager::plugins()) {
|
||||||
|
if (spec->id() == "qmakeprojectmanager") {
|
||||||
|
if (spec->state() == ExtensionSystem::PluginSpec::Running)
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
registerBuildConfiguration<BuildConfiguration>("QtSupport.Test");
|
||||||
|
setSupportedProjectMimeTypeName(Utils::Constants::PROFILE_MIMETYPE);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct DirectoryData {
|
struct DirectoryData {
|
||||||
DirectoryData(const QString &ip,
|
DirectoryData(const QString &ip,
|
||||||
Kit *k = nullptr, bool ink = false,
|
Kit *k = nullptr, bool ink = false,
|
||||||
@@ -162,6 +182,7 @@ protected:
|
|||||||
void deleteDirectoryData(void *directoryData) const override;
|
void deleteDirectoryData(void *directoryData) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const TestBuildConfigFactory m_bcFactory;
|
||||||
const QList<void *> m_testData;
|
const QList<void *> m_testData;
|
||||||
mutable Utils::FilePath m_path;
|
mutable Utils::FilePath m_path;
|
||||||
mutable QVector<void*> m_deletedTestData;
|
mutable QVector<void*> m_deletedTestData;
|
||||||
@@ -443,7 +464,7 @@ void QtProjectImporterTest::testQtProjectImporter_oneProject()
|
|||||||
|
|
||||||
// Finally set up importer:
|
// Finally set up importer:
|
||||||
// Copy the directoryData so that importer is free to delete it later.
|
// Copy the directoryData so that importer is free to delete it later.
|
||||||
TestQtProjectImporter importer(tempDir1.path(),
|
TestQtProjectImporter importer(tempDir1.filePath("test.pro"),
|
||||||
Utils::transform(testData, [](DirectoryData *i) {
|
Utils::transform(testData, [](DirectoryData *i) {
|
||||||
return static_cast<void *>(new DirectoryData(*i));
|
return static_cast<void *>(new DirectoryData(*i));
|
||||||
}));
|
}));
|
||||||
@@ -456,7 +477,7 @@ void QtProjectImporterTest::testQtProjectImporter_oneProject()
|
|||||||
const QList<BuildInfo> buildInfo = importer.import(Utils::FilePath::fromString(appDir), true);
|
const QList<BuildInfo> buildInfo = importer.import(Utils::FilePath::fromString(appDir), true);
|
||||||
|
|
||||||
// VALIDATE: Basic TestImporter state:
|
// VALIDATE: Basic TestImporter state:
|
||||||
QCOMPARE(importer.projectFilePath(), tempDir1.path());
|
QCOMPARE(importer.projectFilePath(), tempDir1.filePath("test.pro"));
|
||||||
QCOMPARE(importer.allDeleted(), true);
|
QCOMPARE(importer.allDeleted(), true);
|
||||||
|
|
||||||
// VALIDATE: Result looks reasonable:
|
// VALIDATE: Result looks reasonable:
|
||||||
@@ -560,7 +581,7 @@ void QtProjectImporterTest::testQtProjectImporter_oneProject()
|
|||||||
QCOMPARE(newKitId, newKitIdAfterImport);
|
QCOMPARE(newKitId, newKitIdAfterImport);
|
||||||
|
|
||||||
// VALIDATE: Importer state
|
// VALIDATE: Importer state
|
||||||
QCOMPARE(importer.projectFilePath(), tempDir1.path());
|
QCOMPARE(importer.projectFilePath(), tempDir1.filePath("test.pro"));
|
||||||
QCOMPARE(importer.allDeleted(), true);
|
QCOMPARE(importer.allDeleted(), true);
|
||||||
|
|
||||||
if (kitIsPersistent) {
|
if (kitIsPersistent) {
|
||||||
|
Reference in New Issue
Block a user