forked from qt-creator/qt-creator
CMakeProjectManager: Hide kit aspect factory implementation
Also avoid re-instantiation of factories in the build configurations. Closer to the setups of the other kit aspect(factories). Change-Id: I1b74a68287b63ee94ff18106d3a00b23624a601b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -63,6 +63,60 @@ static Id defaultCMakeToolId()
|
||||
return defaultTool ? defaultTool->id() : Id();
|
||||
}
|
||||
|
||||
// Factories
|
||||
|
||||
class CMakeKitAspectFactory : public KitAspectFactory
|
||||
{
|
||||
public:
|
||||
CMakeKitAspectFactory();
|
||||
|
||||
// KitAspect interface
|
||||
Tasks validate(const Kit *k) const final;
|
||||
void setup(Kit *k) final;
|
||||
void fix(Kit *k) final;
|
||||
ItemList toUserOutput(const Kit *k) const final;
|
||||
KitAspect *createKitAspect(Kit *k) const final;
|
||||
|
||||
void addToMacroExpander(Kit *k, Utils::MacroExpander *expander) const final;
|
||||
|
||||
QSet<Utils::Id> availableFeatures(const Kit *k) const final;
|
||||
};
|
||||
|
||||
class CMakeGeneratorKitAspectFactory : public KitAspectFactory
|
||||
{
|
||||
public:
|
||||
CMakeGeneratorKitAspectFactory();
|
||||
|
||||
Tasks validate(const Kit *k) const final;
|
||||
void setup(Kit *k) final;
|
||||
void fix(Kit *k) final;
|
||||
void upgrade(Kit *k) final;
|
||||
ItemList toUserOutput(const Kit *k) const final;
|
||||
KitAspect *createKitAspect(Kit *k) const final;
|
||||
void addToBuildEnvironment(const Kit *k, Utils::Environment &env) const final;
|
||||
|
||||
private:
|
||||
QVariant defaultValue(const Kit *k) const;
|
||||
};
|
||||
|
||||
class CMakeConfigurationKitAspectFactory : public KitAspectFactory
|
||||
{
|
||||
public:
|
||||
CMakeConfigurationKitAspectFactory();
|
||||
|
||||
// KitAspect interface
|
||||
Tasks validate(const Kit *k) const final;
|
||||
void setup(Kit *k) final;
|
||||
void fix(Kit *k) final;
|
||||
ItemList toUserOutput(const Kit *k) const final;
|
||||
KitAspect *createKitAspect(Kit *k) const final;
|
||||
|
||||
private:
|
||||
QVariant defaultValue(const Kit *k) const;
|
||||
};
|
||||
|
||||
// Implementations
|
||||
|
||||
class CMakeKitAspectImpl final : public KitAspect
|
||||
{
|
||||
public:
|
||||
@@ -602,7 +656,7 @@ QStringList CMakeGeneratorKitAspect::generatorArguments(const Kit *k)
|
||||
return result;
|
||||
}
|
||||
|
||||
CMakeConfig CMakeGeneratorKitAspect::generatorCMakeConfig(const ProjectExplorer::Kit *k)
|
||||
CMakeConfig CMakeGeneratorKitAspect::generatorCMakeConfig(const Kit *k)
|
||||
{
|
||||
CMakeConfig config;
|
||||
|
||||
@@ -1028,14 +1082,14 @@ void CMakeConfigurationKitAspect::setConfiguration(Kit *k, const CMakeConfig &co
|
||||
k->setValue(CONFIGURATION_ID, tmp);
|
||||
}
|
||||
|
||||
QString CMakeConfigurationKitAspect::additionalConfiguration(const ProjectExplorer::Kit *k)
|
||||
QString CMakeConfigurationKitAspect::additionalConfiguration(const Kit *k)
|
||||
{
|
||||
if (!k)
|
||||
return QString();
|
||||
return k->value(ADDITIONAL_CONFIGURATION_ID).toString();
|
||||
}
|
||||
|
||||
void CMakeConfigurationKitAspect::setAdditionalConfiguration(ProjectExplorer::Kit *k, const QString &config)
|
||||
void CMakeConfigurationKitAspect::setAdditionalConfiguration(Kit *k, const QString &config)
|
||||
{
|
||||
if (!k)
|
||||
return;
|
||||
@@ -1095,7 +1149,7 @@ void CMakeConfigurationKitAspect::setCMakePreset(Kit *k, const QString &presetNa
|
||||
setConfiguration(k, config);
|
||||
}
|
||||
|
||||
CMakeConfigItem CMakeConfigurationKitAspect::cmakePresetConfigItem(const ProjectExplorer::Kit *k)
|
||||
CMakeConfigItem CMakeConfigurationKitAspect::cmakePresetConfigItem(const Kit *k)
|
||||
{
|
||||
const CMakeConfig config = configuration(k);
|
||||
return Utils::findOrDefault(config, [](const CMakeConfigItem &item) {
|
||||
@@ -1230,4 +1284,25 @@ KitAspect *CMakeConfigurationKitAspectFactory::createKitAspect(Kit *k) const
|
||||
return new CMakeConfigurationKitAspectWidget(k, this);
|
||||
}
|
||||
|
||||
// Factory instances;
|
||||
|
||||
const CMakeKitAspectFactory theCMakeKitAspectFactory;
|
||||
const CMakeGeneratorKitAspectFactory theCMakeGeneratorKitAspectFactory;
|
||||
const CMakeConfigurationKitAspectFactory theCMakeConfigurationKitAspectFactory;
|
||||
|
||||
KitAspect *CMakeKitAspect::createKitAspect(Kit *k)
|
||||
{
|
||||
return theCMakeKitAspectFactory.createKitAspect(k);
|
||||
}
|
||||
|
||||
KitAspect *CMakeGeneratorKitAspect::createKitAspect(Kit *k)
|
||||
{
|
||||
return theCMakeGeneratorKitAspectFactory.createKitAspect(k);
|
||||
}
|
||||
|
||||
KitAspect *CMakeConfigurationKitAspect::createKitAspect(Kit *k)
|
||||
{
|
||||
return theCMakeConfigurationKitAspectFactory.createKitAspect(k);
|
||||
}
|
||||
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
Reference in New Issue
Block a user