forked from qt-creator/qt-creator
ProjectExplorer: Collapse BuildInfo hierarchy
... to pass it around as real values, avoiding, among others, the need of occasional explicit deletion. The formerly extra members of the derived stuff are handled via an extra variant (for data) and via a functor in the build configuration factory. The change is mechanical. Change-Id: I19ca4e0c5f0a5b196fc16dfb98bb005dc679f855 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
#include "qbsbuildconfiguration.h"
|
||||
|
||||
#include "qbsbuildconfigurationwidget.h"
|
||||
#include "qbsbuildinfo.h"
|
||||
#include "qbsbuildstep.h"
|
||||
#include "qbscleanstep.h"
|
||||
#include "qbsinstallstep.h"
|
||||
@@ -36,7 +35,8 @@
|
||||
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/deployconfiguration.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
@@ -46,7 +46,11 @@
|
||||
#include <projectexplorer/projectmacroexpander.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -82,21 +86,20 @@ QbsBuildConfiguration::QbsBuildConfiguration(Target *target, Core::Id id)
|
||||
connect(project(), &Project::parsingFinished, this, &BuildConfiguration::enabledChanged);
|
||||
}
|
||||
|
||||
void QbsBuildConfiguration::initialize(const BuildInfo *info)
|
||||
void QbsBuildConfiguration::initialize(const BuildInfo &info)
|
||||
{
|
||||
BuildConfiguration::initialize(info);
|
||||
|
||||
const auto * const bi = static_cast<const QbsBuildInfo *>(info);
|
||||
QVariantMap configData = bi->config;
|
||||
QVariantMap configData = info.extraInfo.value<QVariantMap>();
|
||||
configData.insert(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY),
|
||||
(info->buildType == BuildConfiguration::Debug)
|
||||
(info.buildType == BuildConfiguration::Debug)
|
||||
? QLatin1String(Constants::QBS_VARIANT_DEBUG)
|
||||
: QLatin1String(Constants::QBS_VARIANT_RELEASE));
|
||||
|
||||
Utils::FileName buildDir = info->buildDirectory;
|
||||
Utils::FileName buildDir = info.buildDirectory;
|
||||
if (buildDir.isEmpty())
|
||||
buildDir = defaultBuildDirectory(target()->project()->projectFilePath().toString(),
|
||||
target()->kit(), info->displayName, info->buildType);
|
||||
target()->kit(), info.displayName, info.buildType);
|
||||
setBuildDirectory(buildDir);
|
||||
|
||||
// Add the build configuration.
|
||||
@@ -104,13 +107,13 @@ void QbsBuildConfiguration::initialize(const BuildInfo *info)
|
||||
QString configName = bd.take("configName").toString();
|
||||
if (configName.isEmpty()) {
|
||||
configName = "qtc_" + target()->kit()->fileSystemFriendlyName() + '_'
|
||||
+ Utils::FileUtils::fileSystemFriendlyName(info->displayName);
|
||||
+ Utils::FileUtils::fileSystemFriendlyName(info.displayName);
|
||||
}
|
||||
setConfigurationName(configName);
|
||||
|
||||
BuildStepList *buildSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
||||
auto bs = new QbsBuildStep(buildSteps);
|
||||
if (info->buildType == Release)
|
||||
if (info.buildType == Release)
|
||||
bs->setQmlDebuggingEnabled(false);
|
||||
bs->setQbsConfiguration(bd);
|
||||
buildSteps->appendStep(bs);
|
||||
@@ -401,44 +404,51 @@ QbsBuildConfigurationFactory::QbsBuildConfigurationFactory()
|
||||
registerBuildConfiguration<QbsBuildConfiguration>(Constants::QBS_BC_ID);
|
||||
setSupportedProjectType(Constants::PROJECT_ID);
|
||||
setSupportedProjectMimeTypeName(Constants::MIME_TYPE);
|
||||
setIssueReporter([](Kit *k, const QString &projectPath, const QString &buildDir) -> QList<Task> {
|
||||
const QtSupport::BaseQtVersion * const version = QtSupport::QtKitInformation::qtVersion(k);
|
||||
return version ? version->reportIssues(projectPath, buildDir)
|
||||
: QList<ProjectExplorer::Task>();
|
||||
});
|
||||
}
|
||||
|
||||
BuildInfo *QbsBuildConfigurationFactory::createBuildInfo(const Kit *k,
|
||||
BuildConfiguration::BuildType type) const
|
||||
BuildInfo QbsBuildConfigurationFactory::createBuildInfo(const Kit *k,
|
||||
BuildConfiguration::BuildType type) const
|
||||
{
|
||||
auto info = new QbsBuildInfo(this);
|
||||
info->typeName = tr("Build");
|
||||
info->kitId = k->id();
|
||||
info->buildType = type;
|
||||
info->config.insert("configName", type == BuildConfiguration::Debug ? "Debug" : "Release");
|
||||
BuildInfo info(this);
|
||||
info.kitId = k->id();
|
||||
info.buildType = type;
|
||||
info.typeName = tr("Build");
|
||||
QVariantMap config;
|
||||
config.insert("configName", type == BuildConfiguration::Debug ? "Debug" : "Release");
|
||||
info.extraInfo = config;
|
||||
return info;
|
||||
}
|
||||
|
||||
QList<BuildInfo *> QbsBuildConfigurationFactory::availableBuilds(const Target *parent) const
|
||||
QList<BuildInfo> QbsBuildConfigurationFactory::availableBuilds(const Target *parent) const
|
||||
{
|
||||
return {createBuildInfo(parent->kit(), BuildConfiguration::Debug)};
|
||||
}
|
||||
|
||||
QList<BuildInfo *> QbsBuildConfigurationFactory::availableSetups(const Kit *k, const QString &projectPath) const
|
||||
QList<BuildInfo> QbsBuildConfigurationFactory::availableSetups(const Kit *k, const QString &projectPath) const
|
||||
{
|
||||
QList<BuildInfo *> result;
|
||||
QList<BuildInfo> result;
|
||||
|
||||
BuildInfo *info = createBuildInfo(k, BuildConfiguration::Debug);
|
||||
BuildInfo info = createBuildInfo(k, BuildConfiguration::Debug);
|
||||
//: The name of the debug build configuration created by default for a qbs project.
|
||||
info->displayName = tr("Debug");
|
||||
info.displayName = tr("Debug");
|
||||
//: Non-ASCII characters in directory suffix may cause build issues.
|
||||
info->buildDirectory
|
||||
info.buildDirectory
|
||||
= defaultBuildDirectory(projectPath, k, tr("Debug", "Shadow build directory suffix"),
|
||||
info->buildType);
|
||||
info.buildType);
|
||||
result << info;
|
||||
|
||||
info = createBuildInfo(k, BuildConfiguration::Release);
|
||||
//: The name of the release build configuration created by default for a qbs project.
|
||||
info->displayName = tr("Release");
|
||||
info.displayName = tr("Release");
|
||||
//: Non-ASCII characters in directory suffix may cause build issues.
|
||||
info->buildDirectory
|
||||
info.buildDirectory
|
||||
= defaultBuildDirectory(projectPath, k, tr("Release", "Shadow build directory suffix"),
|
||||
info->buildType);
|
||||
info.buildType);
|
||||
result << info;
|
||||
|
||||
return result;
|
||||
|
||||
@@ -49,7 +49,7 @@ class QbsBuildConfiguration : public ProjectExplorer::BuildConfiguration
|
||||
QbsBuildConfiguration(ProjectExplorer::Target *target, Core::Id id);
|
||||
|
||||
public:
|
||||
void initialize(const ProjectExplorer::BuildInfo *info) override;
|
||||
void initialize(const ProjectExplorer::BuildInfo &info) override;
|
||||
ProjectExplorer::NamedWidget *createConfigWidget() override;
|
||||
|
||||
QbsBuildStep *qbsStep() const;
|
||||
@@ -104,12 +104,12 @@ class QbsBuildConfigurationFactory : public ProjectExplorer::BuildConfigurationF
|
||||
public:
|
||||
QbsBuildConfigurationFactory();
|
||||
|
||||
QList<ProjectExplorer::BuildInfo *> availableBuilds(const ProjectExplorer::Target *parent) const override;
|
||||
QList<ProjectExplorer::BuildInfo *> availableSetups(const ProjectExplorer::Kit *k,
|
||||
const QString &projectPath) const override;
|
||||
QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Target *parent) const override;
|
||||
QList<ProjectExplorer::BuildInfo> availableSetups(const ProjectExplorer::Kit *k,
|
||||
const QString &projectPath) const override;
|
||||
|
||||
private:
|
||||
ProjectExplorer::BuildInfo *createBuildInfo(const ProjectExplorer::Kit *k,
|
||||
ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k,
|
||||
ProjectExplorer::BuildConfiguration::BuildType type) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qbsbuildinfo.h"
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
namespace QbsProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
QbsBuildInfo::QbsBuildInfo(const ProjectExplorer::BuildConfigurationFactory *f)
|
||||
: ProjectExplorer::BuildInfo(f)
|
||||
{
|
||||
}
|
||||
|
||||
QList<ProjectExplorer::Task> QbsBuildInfo::reportIssues(const QString &projectPath,
|
||||
const QString &buildDir) const
|
||||
{
|
||||
const ProjectExplorer::Kit * const k = ProjectExplorer::KitManager::kit(kitId);
|
||||
const QtSupport::BaseQtVersion * const version = QtSupport::QtKitInformation::qtVersion(k);
|
||||
return version ? version->reportIssues(projectPath, buildDir)
|
||||
: QList<ProjectExplorer::Task>();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QbsProjectManager
|
||||
@@ -1,48 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
namespace QbsProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class QbsBuildInfo final : public ProjectExplorer::BuildInfo
|
||||
{
|
||||
public:
|
||||
QbsBuildInfo(const ProjectExplorer::BuildConfigurationFactory *f);
|
||||
|
||||
QVariantMap config;
|
||||
|
||||
private:
|
||||
QList<ProjectExplorer::Task> reportIssues(const QString &projectPath,
|
||||
const QString &buildDir) const override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QbsProjectManager
|
||||
@@ -686,7 +686,7 @@ QString QbsProject::uniqueProductName(const qbs::ProductData &product)
|
||||
|
||||
void QbsProject::configureAsExampleProject(const QSet<Id> &platforms)
|
||||
{
|
||||
QList<const BuildInfo *> infoList;
|
||||
QList<BuildInfo> infoList;
|
||||
QList<Kit *> kits = KitManager::kits();
|
||||
const auto qtVersionMatchesPlatform = [platforms](const QtSupport::BaseQtVersion *version) {
|
||||
return platforms.isEmpty() || platforms.intersects(version->targetDeviceTypes());
|
||||
@@ -696,16 +696,10 @@ void QbsProject::configureAsExampleProject(const QSet<Id> &platforms)
|
||||
= QtSupport::QtKitInformation::qtVersion(k);
|
||||
if (!qtVersion || !qtVersionMatchesPlatform(qtVersion))
|
||||
continue;
|
||||
const BuildConfigurationFactory * const factory
|
||||
= BuildConfigurationFactory::find(k, projectFilePath().toString());
|
||||
if (!factory)
|
||||
continue;
|
||||
const auto &buildInfos = factory->availableSetups(k, projectFilePath().toString());
|
||||
for (BuildInfo * const info : buildInfos)
|
||||
infoList << info;
|
||||
if (auto factory = BuildConfigurationFactory::find(k, projectFilePath().toString()))
|
||||
infoList << factory->allAvailableSetups(k, projectFilePath().toString());
|
||||
}
|
||||
setup(infoList);
|
||||
qDeleteAll(infoList);
|
||||
prepareForParsing();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
#include "qbsprojectimporter.h"
|
||||
|
||||
#include "qbsbuildconfiguration.h"
|
||||
#include "qbsbuildinfo.h"
|
||||
#include "qbspmlogging.h"
|
||||
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
@@ -221,26 +221,26 @@ Kit *QbsProjectImporter::createKit(void *directoryData) const
|
||||
});
|
||||
}
|
||||
|
||||
QList<BuildInfo *> QbsProjectImporter::buildInfoListForKit(const Kit *k, void *directoryData) const
|
||||
const QList<BuildInfo> QbsProjectImporter::buildInfoListForKit(const Kit *k, void *directoryData) const
|
||||
{
|
||||
qCDebug(qbsPmLog) << "creating build info for kit" << k->displayName();
|
||||
QList<BuildInfo *> result;
|
||||
const auto factory = qobject_cast<QbsBuildConfigurationFactory *>(
|
||||
BuildConfigurationFactory::find(k, projectFilePath().toString()));
|
||||
if (!factory) {
|
||||
qCDebug(qbsPmLog) << "no build config factory found";
|
||||
return result;
|
||||
return {};
|
||||
}
|
||||
const auto * const bgData = static_cast<BuildGraphData *>(directoryData);
|
||||
auto * const buildInfo = new QbsBuildInfo(factory);
|
||||
buildInfo->displayName = bgData->bgFilePath.toFileInfo().completeBaseName();
|
||||
buildInfo->buildType = bgData->buildVariant == "debug"
|
||||
BuildInfo info(factory);
|
||||
info.displayName = bgData->bgFilePath.toFileInfo().completeBaseName();
|
||||
info.buildType = bgData->buildVariant == "debug"
|
||||
? BuildConfiguration::Debug : BuildConfiguration::Release;
|
||||
buildInfo->kitId = k->id();
|
||||
buildInfo->buildDirectory = bgData->bgFilePath.parentDir().parentDir();
|
||||
buildInfo->config = bgData->overriddenProperties;
|
||||
buildInfo->config.insert("configName", buildInfo->displayName);
|
||||
return result << buildInfo;
|
||||
info.kitId = k->id();
|
||||
info.buildDirectory = bgData->bgFilePath.parentDir().parentDir();
|
||||
QVariantMap config = bgData->overriddenProperties;
|
||||
config.insert("configName", info.displayName);
|
||||
info.extraInfo = config;
|
||||
return {info};
|
||||
}
|
||||
|
||||
void QbsProjectImporter::deleteDirectoryData(void *directoryData) const
|
||||
|
||||
@@ -42,8 +42,8 @@ private:
|
||||
QList<void *> examineDirectory(const Utils::FileName &importPath) const override;
|
||||
bool matchKit(void *directoryData, const ProjectExplorer::Kit *k) const override;
|
||||
ProjectExplorer::Kit *createKit(void *directoryData) const override;
|
||||
QList<ProjectExplorer::BuildInfo *> buildInfoListForKit(const ProjectExplorer::Kit *k,
|
||||
void *directoryData) const override;
|
||||
const QList<ProjectExplorer::BuildInfo> buildInfoListForKit(const ProjectExplorer::Kit *k,
|
||||
void *directoryData) const override;
|
||||
void deleteDirectoryData(void *directoryData) const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ HEADERS = \
|
||||
propertyprovider.h \
|
||||
qbsbuildconfiguration.h \
|
||||
qbsbuildconfigurationwidget.h \
|
||||
qbsbuildinfo.h \
|
||||
qbsbuildstep.h \
|
||||
qbscleanstep.h \
|
||||
qbskitinformation.h \
|
||||
@@ -49,7 +48,6 @@ SOURCES = \
|
||||
defaultpropertyprovider.cpp \
|
||||
qbsbuildconfiguration.cpp \
|
||||
qbsbuildconfigurationwidget.cpp \
|
||||
qbsbuildinfo.cpp \
|
||||
qbsbuildstep.cpp \
|
||||
qbscleanstep.cpp \
|
||||
qbsinstallstep.cpp \
|
||||
|
||||
@@ -72,8 +72,6 @@ QtcPlugin {
|
||||
"qbsbuildconfiguration.h",
|
||||
"qbsbuildconfigurationwidget.cpp",
|
||||
"qbsbuildconfigurationwidget.h",
|
||||
"qbsbuildinfo.cpp",
|
||||
"qbsbuildinfo.h",
|
||||
"qbsbuildstep.cpp",
|
||||
"qbsbuildstep.h",
|
||||
"qbsbuildstepconfigwidget.ui",
|
||||
|
||||
Reference in New Issue
Block a user