Commit 223a1df8 authored by Tobias Hunger's avatar Tobias Hunger

Wire in Deployment logic

parent 43a7cbc1
......@@ -414,12 +414,26 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps)
void BuildManager::buildProjects(const QList<BuildConfiguration *> &configurations)
{
QList<BuildStep *> steps;
foreach(BuildConfiguration *bc, configurations) {
foreach(BuildConfiguration *bc, configurations)
steps.append(bc->steps(BuildStep::Build));
// TODO: Verify that this is indeed what we want.
steps.append(bc->steps(BuildStep::Deploy));
bool success = buildQueueAppend(steps);
if (!success) {
m_outputWindow->popup(false);
return;
}
if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput)
m_outputWindow->popup(false);
startBuildQueue();
}
void BuildManager::deployProjects(const QList<BuildConfiguration *> &configurations)
{
QList<BuildStep *> steps;
foreach(BuildConfiguration *bc, configurations)
steps.append(bc->steps(BuildStep::Deploy));
bool success = buildQueueAppend(steps);
if (!success) {
m_outputWindow->popup(false);
......@@ -453,6 +467,11 @@ void BuildManager::buildProject(BuildConfiguration *configuration)
buildProjects(QList<BuildConfiguration *>() << configuration);
}
void BuildManager::deployProject(BuildConfiguration *configuration)
{
deployProjects(QList<BuildConfiguration *>() << configuration);
}
void BuildManager::cleanProject(BuildConfiguration *configuration)
{
cleanProjects(QList<BuildConfiguration *>() << configuration);
......
......@@ -74,6 +74,8 @@ public:
void buildProject(BuildConfiguration *bc);
void buildProjects(const QList<BuildConfiguration *> &configurations);
void deployProject(BuildConfiguration *bc);
void deployProjects(const QList<BuildConfiguration *> &configurations);
void cleanProject(BuildConfiguration *configuration);
void cleanProjects(const QList<BuildConfiguration *> &configurations);
bool isBuilding(Project *p);
......
......@@ -146,6 +146,10 @@ struct ProjectExplorerPluginPrivate {
Utils::ParameterAction *m_rebuildActionContextMenu;
QAction *m_rebuildSessionAction;
QAction *m_cleanProjectOnlyAction;
QAction *m_deployProjectOnlyAction;
Utils::ParameterAction *m_deployAction;
Utils::ParameterAction *m_deployActionContextMenu;
QAction *m_deploySessionAction;
Utils::ParameterAction *m_cleanAction;
Utils::ParameterAction *m_cleanActionContextMenu;
QAction *m_cleanSessionAction;
......@@ -569,6 +573,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);
// deploy session
d->m_deploySessionAction = new QAction(tr("Deploy All"), this);
cmd = am->registerAction(d->m_deploySessionAction, Constants::DEPLOYSESSION, globalcontext);
mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);
// clean session
QIcon cleanIcon(Constants::ICON_CLEAN);
cleanIcon.addFile(Constants::ICON_CLEAN_SMALL);
......@@ -594,6 +604,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
cmd->setDefaultText(d->m_rebuildAction->text());
mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);
// deploy action
d->m_deployAction = new Utils::ParameterAction(tr("Deploy Project"), tr("Deploy Project \"%1\""),
Utils::ParameterAction::AlwaysEnabled, this);
cmd = am->registerAction(d->m_deployAction, Constants::DEPLOY, globalcontext);
cmd->setAttribute(Core::Command::CA_UpdateText);
cmd->setDefaultText(d->m_deployAction->text());
mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);
// clean action
d->m_cleanAction = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""),
Utils::ParameterAction::AlwaysEnabled, this);
......@@ -618,6 +636,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
cmd->setDefaultText(d->m_rebuildActionContextMenu->text());
mproject->addAction(cmd, Constants::G_PROJECT_BUILD);
// deploy action (context menu)
d->m_deployActionContextMenu = new Utils::ParameterAction(tr("Deploy Project"), tr("Deploy Project \"%1\""),
Utils::ParameterAction::AlwaysEnabled, this);
cmd = am->registerAction(d->m_rebuildActionContextMenu, Constants::DEPLOYCM, globalcontext);
cmd->setAttribute(Core::Command::CA_UpdateText);
cmd->setDefaultText(d->m_deployActionContextMenu->text());
mproject->addAction(cmd, Constants::G_PROJECT_BUILD);
// clean action (context menu)
d->m_cleanActionContextMenu = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""),
Utils::ParameterAction::AlwaysEnabled, this);
......@@ -634,6 +660,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
d->m_rebuildProjectOnlyAction = new QAction(tr("Rebuild Without Dependencies"), this);
cmd = am->registerAction(d->m_rebuildProjectOnlyAction, Constants::REBUILDPROJECTONLY, globalcontext);
// deploy without dependencies action
d->m_deployProjectOnlyAction = new QAction(tr("Deploy Without Dependencies"), this);
cmd = am->registerAction(d->m_deployProjectOnlyAction, Constants::DEPLOYPROJECTONLY, globalcontext);
// clean without dependencies action
d->m_cleanProjectOnlyAction = new QAction(tr("Clean Without Dependencies"), this);
cmd = am->registerAction(d->m_cleanProjectOnlyAction, Constants::CLEANPROJECTONLY, globalcontext);
......@@ -748,7 +778,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
}
if (QSettings *s = core->settings()) {
d->m_projectExplorerSettings.buildBeforeRun = s->value("ProjectExplorer/Settings/BuildBeforeRun", true).toBool();
d->m_projectExplorerSettings.buildBeforeDeploy = s->value("ProjectExplorer/Settings/BuildBeforeDeploy", true).toBool();
d->m_projectExplorerSettings.deployBeforeRun = s->value("ProjectExplorer/Settings/DeployBeforeRun", true).toBool();
d->m_projectExplorerSettings.saveBeforeBuild = s->value("ProjectExplorer/Settings/SaveBeforeBuild", false).toBool();
d->m_projectExplorerSettings.showCompilerOutput = s->value("ProjectExplorer/Settings/ShowCompilerOutput", false).toBool();
d->m_projectExplorerSettings.cleanOldAppOutput = s->value("ProjectExplorer/Settings/CleanOldAppOutput", false).toBool();
......@@ -771,6 +802,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(d->m_rebuildAction, SIGNAL(triggered()), this, SLOT(rebuildProject()));
connect(d->m_rebuildActionContextMenu, SIGNAL(triggered()), this, SLOT(rebuildProjectContextMenu()));
connect(d->m_rebuildSessionAction, SIGNAL(triggered()), this, SLOT(rebuildSession()));
connect(d->m_deployProjectOnlyAction, SIGNAL(triggered()), this, SLOT(deployProjectOnly()));
connect(d->m_deployAction, SIGNAL(triggered()), this, SLOT(deployProject()));
connect(d->m_deployActionContextMenu, SIGNAL(triggered()), this, SLOT(deployProjectContextMenu()));
connect(d->m_deploySessionAction, SIGNAL(triggered()), this, SLOT(deploySession()));
connect(d->m_cleanProjectOnlyAction, SIGNAL(triggered()), this, SLOT(cleanProjectOnly()));
connect(d->m_cleanAction, SIGNAL(triggered()), this, SLOT(cleanProject()));
connect(d->m_cleanActionContextMenu, SIGNAL(triggered()), this, SLOT(cleanProjectContextMenu()));
......@@ -998,7 +1033,8 @@ void ProjectExplorerPlugin::savePersistentSettings()
s->setValue("ProjectExplorer/RecentProjects/FileNames", fileNames);
s->setValue("ProjectExplorer/RecentProjects/DisplayNames", displayNames);
s->setValue("ProjectExplorer/Settings/BuildBeforeRun", d->m_projectExplorerSettings.buildBeforeRun);
s->setValue("ProjectExplorer/Settings/BuildBeforeDeploy", d->m_projectExplorerSettings.buildBeforeDeploy);
s->setValue("ProjectExplorer/Settings/DeployBeforeRun", d->m_projectExplorerSettings.deployBeforeRun);
s->setValue("ProjectExplorer/Settings/SaveBeforeBuild", d->m_projectExplorerSettings.saveBeforeBuild);
s->setValue("ProjectExplorer/Settings/ShowCompilerOutput", d->m_projectExplorerSettings.showCompilerOutput);
s->setValue("ProjectExplorer/Settings/CleanOldAppOutput", d->m_projectExplorerSettings.cleanOldAppOutput);
......@@ -1261,7 +1297,6 @@ void ProjectExplorerPlugin::executeRunConfiguration(RunConfiguration *runConfigu
RunControl *control = runControlFactory->create(runConfiguration, runMode);
startRunControl(control, runMode);
}
}
void ProjectExplorerPlugin::startRunControl(RunControl *runControl, const QString &runMode)
......@@ -1362,19 +1397,18 @@ void ProjectExplorerPlugin::updateActions()
if (debug)
qDebug() << "ProjectExplorerPlugin::updateActions";
Project *startupProject = session()->startupProject();
bool enableBuildActions = startupProject
&& ! (d->m_buildManager->isBuilding(startupProject))
&& hasBuildSettings(startupProject);
Project *project = startupProject();
bool enableBuildActions = project
&& ! (d->m_buildManager->isBuilding(project))
&& hasBuildSettings(project);
bool enableBuildActionsContextMenu = d->m_currentProject
&& ! (d->m_buildManager->isBuilding(d->m_currentProject))
&& hasBuildSettings(d->m_currentProject);
bool hasProjects = !d->m_session->projects().isEmpty();
bool building = d->m_buildManager->isBuilding();
QString projectName = startupProject ? startupProject->displayName() : QString();
QString projectName = project ? project->displayName() : QString();
QString projectNameContextMenu = d->m_currentProject ? d->m_currentProject->displayName() : QString();
if (debug)
......@@ -1411,7 +1445,7 @@ void ProjectExplorerPlugin::updateActions()
d->m_projectSelectorAction->setEnabled(!session()->projects().isEmpty());
d->m_projectSelectorActionMenu->setEnabled(!session()->projects().isEmpty());
updateRunActions();
updateDeployActions();
}
// NBS TODO check projectOrder()
......@@ -1575,6 +1609,54 @@ void ProjectExplorerPlugin::rebuildSession()
}
}
void ProjectExplorerPlugin::deployProjectOnly()
{
if (!saveModifiedFiles())
return;
d->m_buildManager->deployProject(session()->startupProject()->activeTarget()->activeBuildConfiguration());
}
void ProjectExplorerPlugin::deployProject()
{
if (!saveModifiedFiles())
return;
const QList<Project *> &projects = d->m_session->projectOrder(session()->startupProject());
QList<BuildConfiguration *> configurations;
foreach (Project *pro, projects)
if (pro->activeTarget()->activeBuildConfiguration())
configurations << pro->activeTarget()->activeBuildConfiguration();
d->m_buildManager->deployProjects(configurations);
}
void ProjectExplorerPlugin::deployProjectContextMenu()
{
if (!saveModifiedFiles())
return;
QList<BuildConfiguration *> configurations;
foreach (Project *pro, d->m_session->projectOrder(d->m_currentProject))
if (pro->activeTarget()->activeBuildConfiguration())
configurations << pro->activeTarget()->activeBuildConfiguration();
d->m_buildManager->deployProjects(configurations);
}
void ProjectExplorerPlugin::deploySession()
{
if (!saveModifiedFiles())
return;
const QList<Project *> & projects = d->m_session->projectOrder();
QList<BuildConfiguration *> configurations;
foreach (Project *pro, projects)
if (pro->activeTarget()->activeBuildConfiguration())
configurations << pro->activeTarget()->activeBuildConfiguration();
d->m_buildManager->deployProjects(configurations);
}
void ProjectExplorerPlugin::cleanProjectOnly()
{
if (debug)
......@@ -1648,34 +1730,58 @@ bool ProjectExplorerPlugin::hasBuildSettings(Project *pro)
return false;
}
bool ProjectExplorerPlugin::hasDeploySettings(Project *pro)
{
const QList<Project *> & projects = d->m_session->projectOrder(pro);
foreach(Project *project, projects)
if (project->activeTarget()->activeBuildConfiguration() &&
!project->activeTarget()->activeBuildConfiguration()->steps(BuildStep::Deploy).isEmpty())
return true;
return false;
}
void ProjectExplorerPlugin::runProjectImpl(Project *pro, QString mode)
{
if (!pro)
return;
if (d->m_projectExplorerSettings.buildBeforeRun && hasBuildSettings(pro)) {
if (!pro->activeTarget()->activeRunConfiguration()->isEnabled()) {
if (!showBuildConfigDialog())
if (!pro->activeTarget()->activeRunConfiguration()->isEnabled()) {
if (!showBuildConfigDialog())
return;
}
if (!saveModifiedFiles())
return;
bool delayRun = false;
// Deploy/build first?
if (d->m_projectExplorerSettings.deployBeforeRun) {
const QList<Project *> & projects = d->m_session->projectOrder(pro);
QList<BuildConfiguration *> configurations;
foreach(Project *project, projects)
if (project->activeTarget()->activeBuildConfiguration())
configurations << project->activeTarget()->activeBuildConfiguration();
if (d->m_projectExplorerSettings.buildBeforeDeploy && hasBuildSettings(pro)) {
if (!d->m_buildManager->buildProjects(configurations))
return;
delayRun = true;
}
if (saveModifiedFiles()) {
d->m_runMode = mode;
d->m_delayedRunConfiguration = pro->activeTarget()->activeRunConfiguration();
const QList<Project *> & projects = d->m_session->projectOrder(pro);
QList<BuildConfiguration *> configurations;
foreach(Project *project, projects)
if (project->activeTarget()->activeBuildConfiguration())
configurations << project->activeTarget()->activeBuildConfiguration();
d->m_buildManager->buildProjects(configurations);
updateRunActions();
if (hasDeploySettings(pro)) {
if (!d->m_buildManager->deployProjects(configurations))
return;
delayRun = true;
}
}
// Actually run (delayed)
if (delayRun) {
d->m_runMode = mode;
d->m_delayedRunConfiguration = pro->activeTarget()->activeRunConfiguration();
} else {
// TODO this ignores RunConfiguration::isEnabled()
if (saveModifiedFiles())
executeRunConfiguration(pro->activeTarget()->activeRunConfiguration(), mode);
executeRunConfiguration(pro->activeTarget()->activeRunConfiguration(), mode);
}
updateRunActions();
}
void ProjectExplorerPlugin::debugProject()
......@@ -1735,7 +1841,7 @@ void ProjectExplorerPlugin::startupProjectChanged()
this, SLOT(updateRunActions()));
disconnect(previousStartupProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
this, SLOT(updateRunActions()));
this, SLOT(updateDeployActions()));
disconnect(previousStartupProject->activeTarget()->activeRunConfiguration(),
SIGNAL(isEnabledChanged(bool)), this, SLOT(updateRunActions()));
......@@ -1748,7 +1854,7 @@ void ProjectExplorerPlugin::startupProjectChanged()
if (project) {
connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
this, SLOT(updateRunActions()));
this, SLOT(updateDeployActions()));
connect(project->activeTarget(), SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
this, SLOT(updateRunActions()));
......@@ -1776,6 +1882,35 @@ IRunControlFactory *ProjectExplorerPlugin::findRunControlFactory(RunConfiguratio
return 0;
}
void ProjectExplorerPlugin::updateDeployActions()
{
Project *project = startupProject();
bool enableDeployActions = project
&& ! (d->m_buildManager->isBuilding(project))
&& hasDeploySettings(project);
bool enableDeployActionsContextMenu = d->m_currentProject
&& ! (d->m_buildManager->isBuilding(d->m_currentProject))
&& hasDeploySettings(d->m_currentProject);
const QString projectName = project ? project->displayName() : QString();
const QString projectNameContextMenu = d->m_currentProject ? d->m_currentProject->displayName() : QString();
bool hasProjects = !d->m_session->projects().isEmpty();
bool building = d->m_buildManager->isBuilding();
d->m_deployAction->setParameter(projectName);
d->m_deployAction->setEnabled(enableDeployActions);
d->m_deployActionContextMenu->setParameter(projectNameContextMenu);
d->m_deployActionContextMenu->setEnabled(enableDeployActionsContextMenu);
d->m_deployProjectOnlyAction->setEnabled(enableDeployActions);
d->m_deploySessionAction->setEnabled(hasProjects && !building);
updateRunActions();
}
void ProjectExplorerPlugin::updateRunActions()
{
const Project *project = startupProject();
......
......@@ -140,6 +140,10 @@ private slots:
void rebuildProject();
void rebuildProjectContextMenu();
void rebuildSession();
void deployProjectOnly();
void deployProject();
void deployProjectContextMenu();
void deploySession();
void cleanProjectOnly();
void cleanProject();
void cleanProjectContextMenu();
......@@ -182,6 +186,7 @@ private slots:
void runControlFinished();
void startupProjectChanged(); // Calls updateRunAction
void updateDeployActions();
void updateRunActions();
void loadProject(const QString &project) { openProject(project); }
......@@ -207,6 +212,8 @@ private:
void runProjectImpl(Project *pro, QString mode);
void executeRunConfiguration(RunConfiguration *, const QString &mode);
bool hasBuildSettings(Project *pro);
bool hasDeploySettings(Project *pro);
bool showBuildConfigDialog();
void setCurrent(Project *project, QString filePath, Node *node);
......
......@@ -53,6 +53,10 @@ const char * const REBUILDPROJECTONLY = "ProjectExplorer.RebuildProjectOnly";
const char * const REBUILD = "ProjectExplorer.Rebuild";
const char * const REBUILDCM = "ProjectExplorer.RebuildCM";
const char * const REBUILDSESSION = "ProjectExplorer.RebuildSession";
const char * const DEPLOYPROJECTONLY = "ProjectExplorer.DeployProjectOnly";
const char * const DEPLOY = "ProjectExplorer.Deploy";
const char * const DEPLOYCM = "ProjectExplorer.DeployCM";
const char * const DEPLOYSESSION = "ProjectExplorer.DeploySession";
const char * const CLEANPROJECTONLY = "ProjectExplorer.CleanProjectOnly";
const char * const CLEAN = "ProjectExplorer.Clean";
const char * const CLEANCM = "ProjectExplorer.CleanCM";
......
......@@ -37,11 +37,11 @@ namespace Internal {
struct ProjectExplorerSettings
{
ProjectExplorerSettings() : buildBeforeRun(true), saveBeforeBuild(false),
showCompilerOutput(false),
cleanOldAppOutput(false), useJom(true) {}
ProjectExplorerSettings() : buildBeforeDeploy(true), deployBeforeRun(true), saveBeforeBuild(false),
showCompilerOutput(false), cleanOldAppOutput(false), useJom(true) {}
bool buildBeforeRun;
bool buildBeforeDeploy;
bool deployBeforeRun;
bool saveBeforeBuild;
bool showCompilerOutput;
bool cleanOldAppOutput;
......@@ -54,7 +54,8 @@ struct ProjectExplorerSettings
inline bool operator==(const ProjectExplorerSettings &p1, const ProjectExplorerSettings &p2)
{
return p1.buildBeforeRun == p2.buildBeforeRun
return p1.buildBeforeDeploy == p2.buildBeforeDeploy
&& p1.deployBeforeRun == p2.deployBeforeRun
&& p1.saveBeforeBuild == p2.saveBeforeBuild
&& p1.showCompilerOutput == p2.showCompilerOutput
&& p1.cleanOldAppOutput == p2.cleanOldAppOutput
......
......@@ -65,7 +65,8 @@ void ProjectExplorerSettingsWidget::setJomVisible(bool v)
ProjectExplorerSettings ProjectExplorerSettingsWidget::settings() const
{
ProjectExplorerSettings pes;
pes.buildBeforeRun = m_ui.buildProjectBeforeRunCheckBox->isChecked();
pes.buildBeforeDeploy = m_ui.buildProjectBeforeDeployCheckBox->isChecked();
pes.deployBeforeRun = m_ui.deployProjectBeforeRunCheckBox->isChecked();
pes.saveBeforeBuild = m_ui.saveAllFilesCheckBox->isChecked();
pes.showCompilerOutput = m_ui.showCompileOutputCheckBox->isChecked();
pes.cleanOldAppOutput = m_ui.cleanOldAppOutputCheckBox->isChecked();
......@@ -75,7 +76,8 @@ ProjectExplorerSettings ProjectExplorerSettingsWidget::settings() const
void ProjectExplorerSettingsWidget::setSettings(const ProjectExplorerSettings &pes) const
{
m_ui.buildProjectBeforeRunCheckBox->setChecked(pes.buildBeforeRun);
m_ui.buildProjectBeforeDeployCheckBox->setChecked(pes.buildBeforeDeploy);
m_ui.deployProjectBeforeRunCheckBox->setChecked(pes.deployBeforeRun);
m_ui.saveAllFilesCheckBox->setChecked(pes.saveBeforeBuild);
m_ui.showCompileOutputCheckBox->setChecked(pes.showCompilerOutput);
m_ui.cleanOldAppOutputCheckBox->setChecked(pes.cleanOldAppOutput);
......
......@@ -63,9 +63,16 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="buildProjectBeforeRunCheckBox">
<widget class="QCheckBox" name="buildProjectBeforeDeployCheckBox">
<property name="text">
<string>Always build project before running</string>
<string>Always build project before deploying it</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="deployProjectBeforeRunCheckBox">
<property name="text">
<string>Always deploy project before running it</string>
</property>
</widget>
</item>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment