ProjectExplorer: Merge BuildConfigurationFactory::availableBuilds

... and availableSetups as far as mechanically possible.

Change-Id: Ia1d7babe943eea25da97cef7838187c234378673
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-06-27 10:22:13 +02:00
parent f94e55b807
commit 5dbfd46bcf
17 changed files with 118 additions and 209 deletions

View File

@@ -97,28 +97,18 @@ AutotoolsBuildConfigurationFactory::AutotoolsBuildConfigurationFactory()
setSupportedProjectMimeTypeName(Constants::MAKEFILE_MIMETYPE); setSupportedProjectMimeTypeName(Constants::MAKEFILE_MIMETYPE);
} }
QList<BuildInfo> AutotoolsBuildConfigurationFactory::availableBuilds(const Kit *k, const FilePath &projectPath) const QList<BuildInfo> AutotoolsBuildConfigurationFactory::availableBuilds
{ (const Kit *k, const FilePath &projectPath, bool forSetup) const
return {createBuildInfo(k, projectPath)};
}
QList<BuildInfo> AutotoolsBuildConfigurationFactory::availableSetups(const Kit *k, const FilePath &projectPath) const
{
const QString path = projectPath.toFileInfo().absolutePath();
BuildInfo info = createBuildInfo(k, Utils::FilePath::fromString(path));
//: The name of the build configuration created by default for a autotools project.
info.displayName = tr("Default");
return {info};
}
BuildInfo AutotoolsBuildConfigurationFactory::createBuildInfo(const Kit *k,
const Utils::FilePath &buildDir) const
{ {
BuildInfo info(this); BuildInfo info(this);
info.typeName = tr("Build"); info.typeName = tr("Build");
info.buildDirectory = buildDir; info.buildDirectory = forSetup ? FilePath::fromString(projectPath.toFileInfo().absolutePath()) : projectPath;
info.kitId = k->id(); info.kitId = k->id();
return info; if (forSetup) {
//: The name of the build configuration created by default for a autotools project.
info.displayName = tr("Default");
}
return {info};
} }
BuildConfiguration::BuildType AutotoolsBuildConfiguration::buildType() const BuildConfiguration::BuildType AutotoolsBuildConfiguration::buildType() const

View File

@@ -29,8 +29,6 @@
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
namespace Utils { class FilePath; }
namespace AutotoolsProjectManager { namespace AutotoolsProjectManager {
namespace Internal { namespace Internal {
@@ -54,11 +52,8 @@ public:
private: private:
QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k, QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k,
const Utils::FilePath &projectPath) const override; const Utils::FilePath &projectPath,
QList<ProjectExplorer::BuildInfo> availableSetups(const ProjectExplorer::Kit *k, bool forSetup) const override;
const Utils::FilePath &projectPath) const override;
ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k, const Utils::FilePath &buildDir) const;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -481,31 +481,21 @@ BuildConfiguration::BuildType CMakeBuildConfigurationFactory::cmakeBuildTypeToBu
return BuildConfiguration::Unknown; return BuildConfiguration::Unknown;
} }
QList<BuildInfo> QList<BuildInfo> CMakeBuildConfigurationFactory::availableBuilds
CMakeBuildConfigurationFactory::availableBuilds(const Kit *k, const FilePath &projectPath) const (const Kit *k, const FilePath &projectPath, bool forSetup) const
{ {
QList<BuildInfo> result; QList<BuildInfo> result;
FilePath path = forSetup ? Project::projectDirectory(projectPath) : projectPath;
for (int type = BuildTypeNone; type != BuildTypeLast; ++type) { for (int type = BuildTypeNone; type != BuildTypeLast; ++type) {
result << createBuildInfo(k, BuildInfo info = createBuildInfo(k, path.toString(), BuildType(type));
projectPath.toString(), if (forSetup) {
BuildType(type));
}
return result;
}
QList<BuildInfo>
CMakeBuildConfigurationFactory::availableSetups(const Kit *k, const FilePath &projectPath) const
{
QList<BuildInfo> result;
for (int type = BuildTypeDebug; type != BuildTypeLast; ++type) {
BuildInfo info = createBuildInfo(k,
ProjectExplorer::Project::projectDirectory(projectPath).toString(),
BuildType(type));
info.displayName = info.typeName; info.displayName = info.typeName;
info.buildDirectory info.buildDirectory
= CMakeBuildConfiguration::shadowBuildDirectory(projectPath, k, = CMakeBuildConfiguration::shadowBuildDirectory(projectPath, k,
info.displayName, info.buildType); info.displayName, info.buildType);
}
result << info; result << info;
} }
return result; return result;

View File

@@ -135,9 +135,8 @@ public:
static ProjectExplorer::BuildConfiguration::BuildType cmakeBuildTypeToBuildType(const BuildType &in); static ProjectExplorer::BuildConfiguration::BuildType cmakeBuildTypeToBuildType(const BuildType &in);
QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k, QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k,
const Utils::FilePath &projectPath) const override; const Utils::FilePath &projectPath,
QList<ProjectExplorer::BuildInfo> availableSetups(const ProjectExplorer::Kit *k, bool forSetup) const override;
const Utils::FilePath &projectPath) const override;
private: private:
ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k, ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k,

View File

@@ -59,6 +59,7 @@
#endif #endif
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
namespace CompilationDatabaseProjectManager { namespace CompilationDatabaseProjectManager {
namespace Internal { namespace Internal {
@@ -529,26 +530,15 @@ CompilationDatabaseBuildConfigurationFactory::CompilationDatabaseBuildConfigurat
setSupportedProjectMimeTypeName(Constants::COMPILATIONDATABASEMIMETYPE); setSupportedProjectMimeTypeName(Constants::COMPILATIONDATABASEMIMETYPE);
} }
static QList<ProjectExplorer::BuildInfo> defaultBuildInfos( QList<BuildInfo> CompilationDatabaseBuildConfigurationFactory::availableBuilds
const ProjectExplorer::BuildConfigurationFactory *factory, const QString &name) (const Kit *, const FilePath &, bool) const
{ {
ProjectExplorer::BuildInfo info(factory); const QString name = tr("Release");
ProjectExplorer::BuildInfo info(this);
info.typeName = name; info.typeName = name;
info.displayName = name; info.displayName = name;
info.buildType = BuildConfiguration::Release; info.buildType = BuildConfiguration::Release;
QList<ProjectExplorer::BuildInfo> buildInfos; return {info};
buildInfos << info;
return buildInfos;
}
QList<BuildInfo> CompilationDatabaseBuildConfigurationFactory::availableBuilds(const Kit *, const Utils::FilePath &) const
{
return defaultBuildInfos(this, tr("Release"));
}
QList<BuildInfo> CompilationDatabaseBuildConfigurationFactory::availableSetups(const Kit *, const Utils::FilePath &) const
{
return defaultBuildInfos(this, tr("Release"));
} }
} // namespace Internal } // namespace Internal

View File

@@ -104,10 +104,9 @@ class CompilationDatabaseBuildConfigurationFactory
public: public:
CompilationDatabaseBuildConfigurationFactory(); CompilationDatabaseBuildConfigurationFactory();
QList<ProjectExplorer::BuildInfo> availableBuilds( QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k,
const ProjectExplorer::Kit *k, const Utils::FilePath &projectPath) const override; const Utils::FilePath &projectPath,
QList<ProjectExplorer::BuildInfo> availableSetups( bool forSetup) const override;
const ProjectExplorer::Kit *k, const Utils::FilePath &projectPath) const override;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -85,31 +85,20 @@ GenericBuildConfigurationFactory::GenericBuildConfigurationFactory()
setSupportedProjectMimeTypeName(Constants::GENERICMIMETYPE); setSupportedProjectMimeTypeName(Constants::GENERICMIMETYPE);
} }
GenericBuildConfigurationFactory::~GenericBuildConfigurationFactory() = default; QList<BuildInfo> GenericBuildConfigurationFactory::availableBuilds
(const Kit *k, const FilePath &projectPath, bool forSetup) const
QList<BuildInfo>
GenericBuildConfigurationFactory::availableBuilds(const Kit *k, const FilePath &projectPath) const
{
return {createBuildInfo(k, projectPath)};
}
QList<BuildInfo>
GenericBuildConfigurationFactory::availableSetups(const Kit *k, const FilePath &projectPath) const
{
BuildInfo info = createBuildInfo(k, Project::projectDirectory(projectPath));
//: The name of the build configuration created by default for a generic project.
info.displayName = tr("Default");
return {info};
}
BuildInfo
GenericBuildConfigurationFactory::createBuildInfo(const Kit *k, const FilePath &buildDir) const
{ {
BuildInfo info(this); BuildInfo info(this);
info.typeName = tr("Build"); info.typeName = tr("Build");
info.buildDirectory = buildDir; info.buildDirectory = forSetup ? Project::projectDirectory(projectPath) : projectPath;
info.kitId = k->id(); info.kitId = k->id();
return info;
if (forSetup) {
//: The name of the build configuration created by default for a generic project.
info.displayName = tr("Default");
}
return {info};
} }
BuildConfiguration::BuildType GenericBuildConfiguration::buildType() const BuildConfiguration::BuildType GenericBuildConfiguration::buildType() const

View File

@@ -50,15 +50,11 @@ class GenericBuildConfigurationFactory : public ProjectExplorer::BuildConfigurat
public: public:
GenericBuildConfigurationFactory(); GenericBuildConfigurationFactory();
~GenericBuildConfigurationFactory() override;
private: private:
QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k, QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k,
const Utils::FilePath &projectPath) const override; const Utils::FilePath &projectPath,
QList<ProjectExplorer::BuildInfo> availableSetups(const ProjectExplorer::Kit *k, bool forSetup) const override;
const Utils::FilePath &projectPath) const override;
ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k, const Utils::FilePath &buildDir) const;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -155,48 +155,30 @@ NimBuildConfigurationFactory::NimBuildConfigurationFactory()
setSupportedProjectMimeTypeName(Constants::C_NIM_PROJECT_MIMETYPE); setSupportedProjectMimeTypeName(Constants::C_NIM_PROJECT_MIMETYPE);
} }
QList<BuildInfo> NimBuildConfigurationFactory::availableBuilds(const Kit *k, const FilePath &) const QList<BuildInfo> NimBuildConfigurationFactory::availableBuilds
{ (const Kit *k, const FilePath &projectPath, bool forSetup) const
QList<BuildInfo> result;
for (auto buildType : {BuildConfiguration::Debug, BuildConfiguration::Release})
result.push_back(createBuildInfo(k, buildType));
return result;
}
QList<BuildInfo> NimBuildConfigurationFactory::availableSetups(const Kit *k, const FilePath &projectPath) const
{ {
QList<BuildInfo> result; QList<BuildInfo> result;
for (auto buildType : {BuildConfiguration::Debug, BuildConfiguration::Release}) { for (auto buildType : {BuildConfiguration::Debug, BuildConfiguration::Release}) {
BuildInfo info = createBuildInfo(k, buildType); BuildInfo info(this);
info.buildType = buildType;
info.kitId = k->id();
if (buildType == BuildConfiguration::Debug)
info.typeName = tr("Debug");
else if (buildType == BuildConfiguration::Profile)
info.typeName = tr("Profile");
else if (buildType == BuildConfiguration::Release)
info.typeName = tr("Release");
if (forSetup) {
info.displayName = info.typeName; info.displayName = info.typeName;
info.buildDirectory = defaultBuildDirectory(k, projectPath, info.typeName, buildType); info.buildDirectory = defaultBuildDirectory(k, projectPath, info.typeName, buildType);
}
result.push_back(info); result.push_back(info);
} }
return result; return result;
} }
BuildInfo NimBuildConfigurationFactory::createBuildInfo(const Kit *k, BuildConfiguration::BuildType buildType) const
{
BuildInfo info(this);
info.buildType = buildType;
info.kitId = k->id();
info.typeName = displayName(buildType);
return info;
}
QString NimBuildConfigurationFactory::displayName(BuildConfiguration::BuildType buildType) const
{
switch (buildType) {
case ProjectExplorer::BuildConfiguration::Debug:
return tr("Debug");
case ProjectExplorer::BuildConfiguration::Profile:
return tr("Profile");
case ProjectExplorer::BuildConfiguration::Release:
return tr("Release");
default:
return QString();
}
}
} // namespace Nim } // namespace Nim

View File

@@ -64,15 +64,8 @@ public:
private: private:
QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k, QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k,
const Utils::FilePath &projectPath) const override; const Utils::FilePath &projectPath,
bool forSetup) const override;
QList<ProjectExplorer::BuildInfo> availableSetups(const ProjectExplorer::Kit *k,
const Utils::FilePath &projectPath) const override;
ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k,
ProjectExplorer::BuildConfiguration::BuildType buildType) const;
QString displayName(ProjectExplorer::BuildConfiguration::BuildType buildType) const;
}; };
} }

View File

@@ -416,13 +416,13 @@ const Tasks BuildConfigurationFactory::reportIssues(ProjectExplorer::Kit *kit, c
const QList<BuildInfo> BuildConfigurationFactory::allAvailableBuilds(const Target *parent) const const QList<BuildInfo> BuildConfigurationFactory::allAvailableBuilds(const Target *parent) const
{ {
return availableBuilds(parent->kit(), parent->project()->projectFilePath()); return availableBuilds(parent->kit(), parent->project()->projectFilePath(), false);
} }
const QList<BuildInfo> const QList<BuildInfo>
BuildConfigurationFactory::allAvailableSetups(const Kit *k, const FilePath &projectPath) const BuildConfigurationFactory::allAvailableSetups(const Kit *k, const FilePath &projectPath) const
{ {
return availableSetups(k, projectPath); return availableBuilds(k, projectPath, /* forSetup = */ true);
} }
bool BuildConfigurationFactory::supportsTargetDeviceType(Core::Id id) const bool BuildConfigurationFactory::supportsTargetDeviceType(Core::Id id) const

View File

@@ -158,9 +158,7 @@ public:
protected: protected:
virtual QList<BuildInfo> virtual QList<BuildInfo>
availableBuilds(const Kit *k, const Utils::FilePath &projectPath) const = 0; availableBuilds(const Kit *k, const Utils::FilePath &projectPath, bool forSetup) const = 0;
virtual QList<BuildInfo>
availableSetups(const Kit *k, const Utils::FilePath &projectPath) const = 0;
bool supportsTargetDeviceType(Core::Id id) const; bool supportsTargetDeviceType(Core::Id id) const;
void setSupportedProjectType(Core::Id id); void setSupportedProjectType(Core::Id id);

View File

@@ -369,30 +369,12 @@ QbsBuildConfigurationFactory::QbsBuildConfigurationFactory()
}); });
} }
BuildInfo QbsBuildConfigurationFactory::createBuildInfo(const Kit *k, QList<BuildInfo> QbsBuildConfigurationFactory::availableBuilds(const Kit *k, const FilePath &projectPath, bool forSetup) const
BuildConfiguration::BuildType type) const
{
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 Kit *k, const FilePath &) const
{
return {createBuildInfo(k, BuildConfiguration::Debug)};
}
QList<BuildInfo>
QbsBuildConfigurationFactory::availableSetups(const Kit *k, const FilePath &projectPath) const
{ {
QList<BuildInfo> result; QList<BuildInfo> result;
if (forSetup) {
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. //: The name of the debug build configuration created by default for a qbs project.
info.displayName = tr("Debug"); info.displayName = tr("Debug");
@@ -411,8 +393,27 @@ QList<BuildInfo>
info.buildType); info.buildType);
result << info; result << info;
} else {
result << createBuildInfo(k, BuildConfiguration::Debug);
}
return result; return result;
} }
BuildInfo QbsBuildConfigurationFactory::createBuildInfo(const Kit *k,
BuildConfiguration::BuildType type) const
{
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;
}
} // namespace Internal } // namespace Internal
} // namespace QbsProjectManager } // namespace QbsProjectManager

View File

@@ -92,10 +92,8 @@ class QbsBuildConfigurationFactory : public ProjectExplorer::BuildConfigurationF
public: public:
QbsBuildConfigurationFactory(); QbsBuildConfigurationFactory();
QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k, QList<ProjectExplorer::BuildInfo> availableBuilds
const Utils::FilePath &projectPath) const override; (const ProjectExplorer::Kit *k, const Utils::FilePath &projectPath, bool forSetup) const override;
QList<ProjectExplorer::BuildInfo> availableSetups(const ProjectExplorer::Kit *k,
const Utils::FilePath &projectPath) const override;
private: private:
ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k, ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k,

View File

@@ -665,33 +665,29 @@ static const QList<BuildConfiguration::BuildType> availableBuildTypes(const Base
return types; return types;
} }
QList<BuildInfo> QmakeBuildConfigurationFactory::availableBuilds(const Kit *k, const FilePath &projectPath) const QList<BuildInfo> QmakeBuildConfigurationFactory::availableBuilds(const Kit *k, const FilePath &projectPath, bool forSetup) const
{ {
QList<BuildInfo> result; QList<BuildInfo> result;
for (BuildConfiguration::BuildType buildType : availableBuildTypes(QtKitAspect::qtVersion(k))) { BaseQtVersion *qtVersion = QtKitAspect::qtVersion(k);
if (forSetup && (!qtVersion || !qtVersion->isValid()))
return {};
for (BuildConfiguration::BuildType buildType : availableBuildTypes(qtVersion)) {
BuildInfo info = createBuildInfo(k, projectPath, buildType); BuildInfo info = createBuildInfo(k, projectPath, buildType);
if (!forSetup) {
info.displayName.clear(); // ask for a name info.displayName.clear(); // ask for a name
info.buildDirectory.clear(); // This depends on the displayName info.buildDirectory.clear(); // This depends on the displayName
}
result << info; result << info;
} }
return result; return result;
} }
QList<BuildInfo> QmakeBuildConfigurationFactory::availableSetups(const Kit *k, const FilePath &projectPath) const
{
QList<BuildInfo> result;
BaseQtVersion *qtVersion = QtKitAspect::qtVersion(k);
if (!qtVersion || !qtVersion->isValid())
return result;
for (BuildConfiguration::BuildType buildType : availableBuildTypes(qtVersion))
result << createBuildInfo(k, projectPath, buildType);
return result;
}
BuildConfiguration::BuildType QmakeBuildConfiguration::buildType() const BuildConfiguration::BuildType QmakeBuildConfiguration::buildType() const
{ {
QMakeStep *qs = qmakeStep(); QMakeStep *qs = qmakeStep();

View File

@@ -150,9 +150,8 @@ public:
QmakeBuildConfigurationFactory(); QmakeBuildConfigurationFactory();
QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k, QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *k,
const Utils::FilePath &projectPath) const override; const Utils::FilePath &projectPath,
QList<ProjectExplorer::BuildInfo> availableSetups(const ProjectExplorer::Kit *k, bool forSetup) const override;
const Utils::FilePath &projectPath) const override;
private: private:
ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k, const Utils::FilePath &projectPath, ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k, const Utils::FilePath &projectPath,
ProjectExplorer::BuildConfiguration::BuildType type) const; ProjectExplorer::BuildConfiguration::BuildType type) const;

View File

@@ -72,13 +72,7 @@ class DummyBuildConfigurationFactory : public ProjectExplorer::BuildConfiguratio
{ {
public: public:
QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *, QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Kit *,
const FilePath &) const final const FilePath &, bool) const final
{
return {};
}
QList<ProjectExplorer::BuildInfo> availableSetups(const ProjectExplorer::Kit *,
const FilePath &) const final
{ {
return {}; return {};
} }