forked from qt-creator/qt-creator
CompilationDatabase: Allow to set custom build step and run command
In addition export the ProcessStep class from ProjectExplorer not to duplicate the code. Task-number: QTCREATORBUG-21727 Change-Id: I43d0c83b0338995fdb37ace940092c83ce2b6820 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -33,10 +33,15 @@
|
|||||||
#include <cpptools/cppkitinfo.h>
|
#include <cpptools/cppkitinfo.h>
|
||||||
#include <cpptools/cppprojectupdater.h>
|
#include <cpptools/cppprojectupdater.h>
|
||||||
#include <cpptools/projectinfo.h>
|
#include <cpptools/projectinfo.h>
|
||||||
|
#include <projectexplorer/buildinfo.h>
|
||||||
|
#include <projectexplorer/buildsteplist.h>
|
||||||
|
#include <projectexplorer/buildtargetinfo.h>
|
||||||
#include <projectexplorer/gcctoolchain.h>
|
#include <projectexplorer/gcctoolchain.h>
|
||||||
#include <projectexplorer/headerpath.h>
|
#include <projectexplorer/headerpath.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
#include <projectexplorer/kitmanager.h>
|
#include <projectexplorer/kitmanager.h>
|
||||||
|
#include <projectexplorer/namedwidget.h>
|
||||||
|
#include <projectexplorer/processstep.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/projectnodes.h>
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
@@ -560,5 +565,65 @@ CompilationDatabaseEditorFactory::CompilationDatabaseEditorFactory()
|
|||||||
setCodeFoldingSupported(true);
|
setCodeFoldingSupported(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompilationDatabaseBuildConfiguration::CompilationDatabaseBuildConfiguration(
|
||||||
|
ProjectExplorer::Target *target, Core::Id id)
|
||||||
|
: ProjectExplorer::BuildConfiguration(target, id)
|
||||||
|
{
|
||||||
|
BuildTargetInfoList appTargetList;
|
||||||
|
BuildTargetInfo bti;
|
||||||
|
appTargetList.list.append(bti);
|
||||||
|
target->setApplicationTargets(appTargetList);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompilationDatabaseBuildConfiguration::initialize(const ProjectExplorer::BuildInfo &info)
|
||||||
|
{
|
||||||
|
ProjectExplorer::BuildConfiguration::initialize(info);
|
||||||
|
BuildStepList *buildSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
||||||
|
buildSteps->appendStep(new ProjectExplorer::ProcessStep(buildSteps));
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectExplorer::NamedWidget *CompilationDatabaseBuildConfiguration::createConfigWidget()
|
||||||
|
{
|
||||||
|
return new ProjectExplorer::NamedWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectExplorer::BuildConfiguration::BuildType CompilationDatabaseBuildConfiguration::buildType() const
|
||||||
|
{
|
||||||
|
return ProjectExplorer::BuildConfiguration::Release;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompilationDatabaseBuildConfigurationFactory::CompilationDatabaseBuildConfigurationFactory()
|
||||||
|
{
|
||||||
|
registerBuildConfiguration<CompilationDatabaseBuildConfiguration>(
|
||||||
|
"CompilationDatabase.CompilationDatabaseBuildConfiguration");
|
||||||
|
|
||||||
|
setSupportedProjectType(Constants::COMPILATIONDATABASEPROJECT_ID);
|
||||||
|
setSupportedProjectMimeTypeName(Constants::COMPILATIONDATABASEMIMETYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static QList<ProjectExplorer::BuildInfo> defaultBuildInfos(
|
||||||
|
const ProjectExplorer::BuildConfigurationFactory *factory, const QString &name)
|
||||||
|
{
|
||||||
|
ProjectExplorer::BuildInfo info(factory);
|
||||||
|
info.typeName = name;
|
||||||
|
info.displayName = name;
|
||||||
|
info.buildType = BuildConfiguration::Release;
|
||||||
|
QList<ProjectExplorer::BuildInfo> buildInfos;
|
||||||
|
buildInfos << info;
|
||||||
|
return buildInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<ProjectExplorer::BuildInfo> CompilationDatabaseBuildConfigurationFactory::availableBuilds(
|
||||||
|
const ProjectExplorer::Target * /*parent*/) const
|
||||||
|
{
|
||||||
|
return defaultBuildInfos(this, tr("Release"));
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<ProjectExplorer::BuildInfo> CompilationDatabaseBuildConfigurationFactory::availableSetups(
|
||||||
|
const ProjectExplorer::Kit * /*k*/, const QString & /*projectPath*/) const
|
||||||
|
{
|
||||||
|
return defaultBuildInfos(this, tr("Release"));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace CompilationDatabaseProjectManager
|
} // namespace CompilationDatabaseProjectManager
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/treescanner.h>
|
#include <projectexplorer/treescanner.h>
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
@@ -51,7 +52,7 @@ public:
|
|||||||
explicit CompilationDatabaseProject(const Utils::FileName &filename);
|
explicit CompilationDatabaseProject(const Utils::FileName &filename);
|
||||||
~CompilationDatabaseProject() override;
|
~CompilationDatabaseProject() override;
|
||||||
bool needsConfiguration() const override { return false; }
|
bool needsConfiguration() const override { return false; }
|
||||||
bool needsBuildConfigurations() const override { return false; }
|
bool needsBuildConfigurations() const override { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
|
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
|
||||||
@@ -77,5 +78,30 @@ public:
|
|||||||
CompilationDatabaseEditorFactory();
|
CompilationDatabaseEditorFactory();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CompilationDatabaseBuildConfiguration : public ProjectExplorer::BuildConfiguration
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CompilationDatabaseBuildConfiguration(ProjectExplorer::Target *target, Core::Id id);
|
||||||
|
ProjectExplorer::NamedWidget *createConfigWidget() override;
|
||||||
|
BuildType buildType() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void initialize(const ProjectExplorer::BuildInfo &info) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CompilationDatabaseBuildConfigurationFactory
|
||||||
|
: public ProjectExplorer::BuildConfigurationFactory
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CompilationDatabaseBuildConfigurationFactory();
|
||||||
|
|
||||||
|
QList<ProjectExplorer::BuildInfo> availableBuilds(
|
||||||
|
const ProjectExplorer::Target *parent) const override;
|
||||||
|
QList<ProjectExplorer::BuildInfo> availableSetups(const ProjectExplorer::Kit *k,
|
||||||
|
const QString &projectPath) const override;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace CompilationDatabaseProjectManager
|
} // namespace CompilationDatabaseProjectManager
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ private:
|
|||||||
QList<QObject *> createTestObjects() const final;
|
QList<QObject *> createTestObjects() const final;
|
||||||
|
|
||||||
CompilationDatabaseEditorFactory factory;
|
CompilationDatabaseEditorFactory factory;
|
||||||
|
CompilationDatabaseBuildConfigurationFactory buildConfigFactory;
|
||||||
QAction *m_changeProjectRootDirectoryAction;
|
QAction *m_changeProjectRootDirectoryAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,12 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "processstep.h"
|
#include "processstep.h"
|
||||||
#include "buildstep.h"
|
|
||||||
#include "buildconfiguration.h"
|
#include "buildconfiguration.h"
|
||||||
|
#include "buildstep.h"
|
||||||
|
#include "kit.h"
|
||||||
#include "processparameters.h"
|
#include "processparameters.h"
|
||||||
#include "projectexplorerconstants.h"
|
#include "projectexplorerconstants.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "kit.h"
|
|
||||||
|
|
||||||
#include <coreplugin/variablechooser.h>
|
#include <coreplugin/variablechooser.h>
|
||||||
|
|
||||||
@@ -38,7 +38,6 @@
|
|||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
const char PROCESS_STEP_ID[] = "ProjectExplorer.ProcessStep";
|
const char PROCESS_STEP_ID[] = "ProjectExplorer.ProcessStep";
|
||||||
const char PROCESS_COMMAND_KEY[] = "ProjectExplorer.ProcessStep.Command";
|
const char PROCESS_COMMAND_KEY[] = "ProjectExplorer.ProcessStep.Command";
|
||||||
@@ -137,5 +136,4 @@ ProcessStepFactory::ProcessStepFactory()
|
|||||||
setDisplayName(ProcessStep::tr("Custom Process Step", "item in combobox"));
|
setDisplayName(ProcessStep::tr("Custom Process Step", "item in combobox"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Internal
|
|
||||||
} // ProjectExplorer
|
} // ProjectExplorer
|
||||||
|
|||||||
@@ -27,9 +27,9 @@
|
|||||||
|
|
||||||
#include "abstractprocessstep.h"
|
#include "abstractprocessstep.h"
|
||||||
#include "projectconfigurationaspects.h"
|
#include "projectconfigurationaspects.h"
|
||||||
|
#include "projectexplorer_export.h"
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class ProcessStepFactory : public BuildStepFactory
|
class ProcessStepFactory : public BuildStepFactory
|
||||||
{
|
{
|
||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
ProcessStepFactory();
|
ProcessStepFactory();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProcessStep : public AbstractProcessStep
|
class PROJECTEXPLORER_EXPORT ProcessStep : public AbstractProcessStep
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
friend class ProcessStepFactory;
|
friend class ProcessStepFactory;
|
||||||
@@ -56,5 +56,4 @@ private:
|
|||||||
ProjectExplorer::BaseStringAspect *m_workingDirectory;
|
ProjectExplorer::BaseStringAspect *m_workingDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
|||||||
Reference in New Issue
Block a user