2013-01-30 18:19:31 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qbsprojectmanagerplugin.h"
|
|
|
|
|
|
|
|
|
|
#include "qbsbuildconfiguration.h"
|
|
|
|
|
#include "qbsbuildstep.h"
|
|
|
|
|
#include "qbscleanstep.h"
|
2013-05-06 11:16:41 +02:00
|
|
|
#include "qbsdeployconfigurationfactory.h"
|
2016-02-09 15:56:48 +01:00
|
|
|
#include "qbsinfopage.h"
|
2013-04-12 16:19:52 +02:00
|
|
|
#include "qbsinstallstep.h"
|
2013-05-27 14:36:59 +02:00
|
|
|
#include "qbsnodes.h"
|
2014-10-31 14:51:55 +01:00
|
|
|
#include "qbsprofilessettingspage.h"
|
2013-01-30 18:19:31 +01:00
|
|
|
#include "qbsproject.h"
|
|
|
|
|
#include "qbsprojectmanager.h"
|
|
|
|
|
#include "qbsprojectmanagerconstants.h"
|
2013-05-15 13:39:00 +02:00
|
|
|
#include "qbsrunconfiguration.h"
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2013-05-27 14:36:59 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
2013-07-26 17:28:06 +02:00
|
|
|
#include <coreplugin/featureprovider.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2015-02-26 13:38:54 +01:00
|
|
|
#include <coreplugin/idocument.h>
|
2013-04-17 12:40:40 +02:00
|
|
|
#include <coreplugin/fileiconprovider.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2014-11-19 17:58:33 +01:00
|
|
|
#include <projectexplorer/projecttree.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2013-05-27 14:36:59 +02:00
|
|
|
#include <projectexplorer/session.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <projectexplorer/target.h>
|
2013-04-17 12:40:40 +02:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
2015-01-10 23:40:32 +02:00
|
|
|
|
|
|
|
|
#include <utils/fileutils.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QtPlugin>
|
|
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
namespace QbsProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-04-08 16:53:21 +02:00
|
|
|
static Node *currentEditorNode()
|
|
|
|
|
{
|
|
|
|
|
Core::IDocument *doc = Core::EditorManager::currentDocument();
|
2015-02-02 00:37:38 +02:00
|
|
|
return doc ? SessionManager::nodeForFile(doc->filePath()) : 0;
|
2014-04-08 16:53:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QbsProject *currentEditorProject()
|
|
|
|
|
{
|
|
|
|
|
Core::IDocument *doc = Core::EditorManager::currentDocument();
|
2015-02-02 00:37:38 +02:00
|
|
|
return doc ? qobject_cast<QbsProject *>(SessionManager::projectForFile(doc->filePath())) : 0;
|
2014-04-08 16:53:21 +02:00
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
QbsProjectManagerPlugin::QbsProjectManagerPlugin() :
|
2014-04-08 11:52:52 +02:00
|
|
|
m_selectedProject(0),
|
2014-04-08 15:13:05 +02:00
|
|
|
m_selectedNode(0),
|
2014-04-08 16:53:21 +02:00
|
|
|
m_currentProject(0),
|
|
|
|
|
m_editorProject(0),
|
|
|
|
|
m_editorNode(0)
|
2013-01-30 18:19:31 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|
|
|
|
{
|
2013-09-12 16:06:33 +02:00
|
|
|
Q_UNUSED(arguments);
|
2013-02-06 14:46:41 +01:00
|
|
|
Q_UNUSED(errorMessage);
|
2013-09-12 16:06:33 +02:00
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
const Core::Context projectContext(::QbsProjectManager::Constants::PROJECT_ID);
|
|
|
|
|
|
2016-04-22 15:42:30 +02:00
|
|
|
Core::FileIconProvider::registerIconOverlayForSuffix(ProjectExplorer::Constants::FILEOVERLAY_QT, "qbs");
|
2013-04-17 12:40:40 +02:00
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
//create and register objects
|
2014-05-07 18:46:17 +02:00
|
|
|
addAutoReleasedObject(new QbsManager);
|
2013-01-30 18:19:31 +01:00
|
|
|
addAutoReleasedObject(new QbsBuildConfigurationFactory);
|
|
|
|
|
addAutoReleasedObject(new QbsBuildStepFactory);
|
|
|
|
|
addAutoReleasedObject(new QbsCleanStepFactory);
|
2013-04-12 16:19:52 +02:00
|
|
|
addAutoReleasedObject(new QbsInstallStepFactory);
|
2013-05-06 11:16:41 +02:00
|
|
|
addAutoReleasedObject(new QbsDeployConfigurationFactory);
|
2013-05-15 13:39:00 +02:00
|
|
|
addAutoReleasedObject(new QbsRunConfigurationFactory);
|
2014-10-31 14:51:55 +01:00
|
|
|
addAutoReleasedObject(new QbsProfilesSettingsPage);
|
2016-02-09 15:56:48 +01:00
|
|
|
addAutoReleasedObject(new QbsInfoPage);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
//menus
|
|
|
|
|
// Build Menu:
|
|
|
|
|
Core::ActionContainer *mbuild =
|
|
|
|
|
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT);
|
|
|
|
|
// PE Context menu for projects
|
|
|
|
|
Core::ActionContainer *mproject =
|
|
|
|
|
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT);
|
2013-06-10 15:40:18 +02:00
|
|
|
Core::ActionContainer *msubproject =
|
|
|
|
|
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT);
|
2013-01-30 18:19:31 +01:00
|
|
|
Core::ActionContainer *mfile =
|
|
|
|
|
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_FILECONTEXT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//register actions
|
|
|
|
|
Core::Command *command;
|
|
|
|
|
|
|
|
|
|
m_reparseQbs = new QAction(tr("Reparse Qbs"), this);
|
|
|
|
|
command = Core::ActionManager::registerAction(m_reparseQbs, Constants::ACTION_REPARSE_QBS, projectContext);
|
|
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(m_reparseQbs, &QAction::triggered,
|
|
|
|
|
this, &QbsProjectManagerPlugin::reparseCurrentProject);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
m_reparseQbsCtx = new QAction(tr("Reparse Qbs"), this);
|
|
|
|
|
command = Core::ActionManager::registerAction(m_reparseQbsCtx, Constants::ACTION_REPARSE_QBS_CONTEXT, projectContext);
|
|
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(m_reparseQbsCtx, &QAction::triggered,
|
|
|
|
|
this, &QbsProjectManagerPlugin::reparseSelectedProject);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2014-04-08 11:35:37 +02:00
|
|
|
m_buildFileCtx = new QAction(tr("Build"), this);
|
|
|
|
|
command = Core::ActionManager::registerAction(m_buildFileCtx, Constants::ACTION_BUILD_FILE_CONTEXT, projectContext);
|
2013-01-30 18:19:31 +01:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
mfile->addAction(command, ProjectExplorer::Constants::G_FILE_OTHER);
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(m_buildFileCtx, &QAction::triggered,
|
|
|
|
|
this, &QbsProjectManagerPlugin::buildFileContextMenu);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2013-05-27 14:36:59 +02:00
|
|
|
m_buildFile = new Utils::ParameterAction(tr("Build File"), tr("Build File \"%1\""),
|
|
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
2015-02-19 11:35:47 +01:00
|
|
|
command = Core::ActionManager::registerAction(m_buildFile, Constants::ACTION_BUILD_FILE);
|
2013-05-27 14:36:59 +02:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
command->setDescription(m_buildFile->text());
|
|
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+B")));
|
|
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(m_buildFile, &QAction::triggered, this, &QbsProjectManagerPlugin::buildFile);
|
2013-05-27 14:36:59 +02:00
|
|
|
|
2014-04-08 11:35:37 +02:00
|
|
|
m_buildProductCtx = new QAction(tr("Build"), this);
|
|
|
|
|
command = Core::ActionManager::registerAction(m_buildProductCtx, Constants::ACTION_BUILD_PRODUCT_CONTEXT, projectContext);
|
2013-06-10 15:40:18 +02:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(m_buildProductCtx, &QAction::triggered,
|
|
|
|
|
this, &QbsProjectManagerPlugin::buildProductContextMenu);
|
2013-06-10 15:40:18 +02:00
|
|
|
|
|
|
|
|
m_buildProduct = new Utils::ParameterAction(tr("Build Product"), tr("Build Product \"%1\""),
|
|
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
2015-02-19 11:35:47 +01:00
|
|
|
command = Core::ActionManager::registerAction(m_buildProduct, Constants::ACTION_BUILD_PRODUCT);
|
2013-06-10 15:40:18 +02:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
command->setDescription(m_buildFile->text());
|
|
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Shift+B")));
|
|
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(m_buildProduct, &QAction::triggered, this, &QbsProjectManagerPlugin::buildProduct);
|
2013-06-10 15:40:18 +02:00
|
|
|
|
2014-04-08 11:35:37 +02:00
|
|
|
m_buildSubprojectCtx = new QAction(tr("Build"), this);
|
|
|
|
|
command = Core::ActionManager::registerAction(m_buildSubprojectCtx, Constants::ACTION_BUILD_SUBPROJECT_CONTEXT, projectContext);
|
2014-02-10 17:28:15 +01:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(m_buildSubprojectCtx, &QAction::triggered,
|
|
|
|
|
this, &QbsProjectManagerPlugin::buildSubprojectContextMenu);
|
2014-02-10 17:28:15 +01:00
|
|
|
|
|
|
|
|
m_buildSubproject = new Utils::ParameterAction(tr("Build Subproject"), tr("Build Subproject \"%1\""),
|
|
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
2015-02-19 11:35:47 +01:00
|
|
|
command = Core::ActionManager::registerAction(m_buildSubproject, Constants::ACTION_BUILD_SUBPROJECT);
|
2014-02-10 17:28:15 +01:00
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
command->setDescription(m_buildFile->text());
|
|
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+B")));
|
|
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(m_buildSubproject, &QAction::triggered, this, &QbsProjectManagerPlugin::buildSubproject);
|
2014-02-10 17:28:15 +01:00
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
// Connect
|
2014-11-19 17:58:33 +01:00
|
|
|
connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged,
|
|
|
|
|
this, &QbsProjectManagerPlugin::nodeSelectionChanged);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(BuildManager::instance(), &BuildManager::buildStateChanged,
|
|
|
|
|
this, &QbsProjectManagerPlugin::buildStateChanged);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged,
|
|
|
|
|
this, &QbsProjectManagerPlugin::currentEditorChanged);
|
2013-05-27 14:36:59 +02:00
|
|
|
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(SessionManager::instance(), &SessionManager::projectAdded,
|
|
|
|
|
this, &QbsProjectManagerPlugin::projectWasAdded);
|
|
|
|
|
connect(SessionManager::instance(), &SessionManager::projectRemoved,
|
|
|
|
|
this, &QbsProjectManagerPlugin::projectWasRemoved);
|
|
|
|
|
connect(SessionManager::instance(), &SessionManager::startupProjectChanged,
|
|
|
|
|
this, &QbsProjectManagerPlugin::currentProjectWasChanged);
|
2014-04-08 14:59:14 +02:00
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
// Run initial setup routines
|
2014-04-08 16:41:12 +02:00
|
|
|
updateContextActions();
|
2013-01-30 18:19:31 +01:00
|
|
|
updateReparseQbsAction();
|
2013-06-10 15:40:18 +02:00
|
|
|
updateBuildActions();
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::extensionsInitialized()
|
|
|
|
|
{ }
|
|
|
|
|
|
2014-04-08 14:59:14 +02:00
|
|
|
void QbsProjectManagerPlugin::projectWasAdded(Project *project)
|
|
|
|
|
{
|
|
|
|
|
QbsProject *qbsProject = qobject_cast<QbsProject *>(project);
|
|
|
|
|
|
|
|
|
|
if (!qbsProject)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(qbsProject, &QbsProject::projectParsingStarted,
|
|
|
|
|
this, &QbsProjectManagerPlugin::parsingStateChanged);
|
|
|
|
|
connect(qbsProject, &QbsProject::projectParsingDone,
|
|
|
|
|
this, &QbsProjectManagerPlugin::parsingStateChanged);
|
2014-04-08 14:59:14 +02:00
|
|
|
}
|
|
|
|
|
|
2014-04-08 15:13:05 +02:00
|
|
|
void QbsProjectManagerPlugin::currentProjectWasChanged(Project *project)
|
|
|
|
|
{
|
|
|
|
|
m_currentProject = qobject_cast<QbsProject *>(project);
|
|
|
|
|
|
|
|
|
|
updateReparseQbsAction();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 16:53:21 +02:00
|
|
|
void QbsProjectManagerPlugin::projectWasRemoved()
|
|
|
|
|
{
|
|
|
|
|
m_editorNode = currentEditorNode();
|
|
|
|
|
m_editorProject = currentEditorProject();
|
|
|
|
|
|
|
|
|
|
updateBuildActions();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 16:41:12 +02:00
|
|
|
void QbsProjectManagerPlugin::nodeSelectionChanged(Node *node, Project *project)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2014-04-08 11:52:52 +02:00
|
|
|
m_selectedNode = node;
|
|
|
|
|
m_selectedProject = qobject_cast<Internal::QbsProject *>(project);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2014-04-08 16:41:12 +02:00
|
|
|
updateContextActions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::updateContextActions()
|
|
|
|
|
{
|
2014-04-08 16:44:50 +02:00
|
|
|
bool isEnabled = !BuildManager::isBuilding(m_selectedProject)
|
|
|
|
|
&& m_selectedProject && !m_selectedProject->isParsing()
|
|
|
|
|
&& m_selectedNode && m_selectedNode->isEnabled();
|
|
|
|
|
|
2016-10-31 13:33:13 +01:00
|
|
|
bool isFile = m_selectedProject && m_selectedNode && (m_selectedNode->nodeType() == NodeType::File);
|
2015-01-09 15:50:06 +01:00
|
|
|
bool isProduct = m_selectedProject && m_selectedNode && dynamic_cast<QbsProductNode *>(m_selectedNode->projectNode());
|
|
|
|
|
QbsProjectNode *subproject = dynamic_cast<QbsProjectNode *>(m_selectedNode);
|
2014-04-08 11:52:52 +02:00
|
|
|
bool isSubproject = m_selectedProject && subproject && subproject != m_selectedProject->rootProjectNode();
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2014-04-08 16:44:50 +02:00
|
|
|
m_reparseQbsCtx->setEnabled(isEnabled);
|
|
|
|
|
m_buildFileCtx->setEnabled(isEnabled && isFile);
|
|
|
|
|
m_buildProductCtx->setVisible(isEnabled && isProduct);
|
|
|
|
|
m_buildSubprojectCtx->setVisible(isEnabled && isSubproject);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::updateReparseQbsAction()
|
|
|
|
|
{
|
2014-04-08 15:13:05 +02:00
|
|
|
m_reparseQbs->setEnabled(m_currentProject
|
|
|
|
|
&& !BuildManager::isBuilding(m_currentProject)
|
|
|
|
|
&& !m_currentProject->isParsing());
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2013-06-10 15:40:18 +02:00
|
|
|
void QbsProjectManagerPlugin::updateBuildActions()
|
2013-05-27 14:36:59 +02:00
|
|
|
{
|
2014-02-10 17:28:15 +01:00
|
|
|
bool enabled = false;
|
2013-06-10 15:40:18 +02:00
|
|
|
bool fileVisible = false;
|
|
|
|
|
bool productVisible = false;
|
2014-02-10 17:28:15 +01:00
|
|
|
bool subprojectVisible = false;
|
2013-05-27 14:36:59 +02:00
|
|
|
|
2014-04-08 16:56:32 +02:00
|
|
|
QString fileName;
|
|
|
|
|
QString productName;
|
|
|
|
|
QString subprojectName;
|
|
|
|
|
|
2014-04-08 16:53:21 +02:00
|
|
|
if (m_editorNode) {
|
2014-04-08 16:58:27 +02:00
|
|
|
enabled = m_editorProject
|
|
|
|
|
&& !BuildManager::isBuilding(m_editorProject)
|
|
|
|
|
&& !m_editorProject->isParsing();
|
2013-06-10 15:40:18 +02:00
|
|
|
|
2015-10-29 17:53:47 +01:00
|
|
|
fileName = m_editorNode->filePath().fileName();
|
2015-01-09 15:50:06 +01:00
|
|
|
fileVisible = m_editorProject && m_editorNode && dynamic_cast<QbsBaseProjectNode *>(m_editorNode->projectNode());
|
2014-04-08 16:56:32 +02:00
|
|
|
|
2014-02-10 17:28:15 +01:00
|
|
|
QbsProductNode *productNode
|
2015-01-09 15:50:06 +01:00
|
|
|
= dynamic_cast<QbsProductNode *>(m_editorNode ? m_editorNode->projectNode() : 0);
|
2014-02-10 17:28:15 +01:00
|
|
|
if (productNode) {
|
2013-06-10 15:40:18 +02:00
|
|
|
productVisible = true;
|
2014-04-08 16:56:32 +02:00
|
|
|
productName = productNode->displayName();
|
2013-06-10 15:40:18 +02:00
|
|
|
}
|
2014-02-10 17:28:15 +01:00
|
|
|
QbsProjectNode *subprojectNode
|
2015-01-09 15:50:06 +01:00
|
|
|
= dynamic_cast<QbsProjectNode *>(productNode ? productNode->parentFolderNode() : 0);
|
2014-12-08 20:38:10 -08:00
|
|
|
if (subprojectNode && m_editorProject && subprojectNode != m_editorProject->rootProjectNode()) {
|
2014-02-10 17:28:15 +01:00
|
|
|
subprojectVisible = true;
|
2014-04-08 16:56:32 +02:00
|
|
|
subprojectName = subprojectNode->displayName();
|
2014-02-10 17:28:15 +01:00
|
|
|
}
|
2013-05-27 14:36:59 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-10 17:28:15 +01:00
|
|
|
m_buildFile->setEnabled(enabled);
|
2013-06-10 15:40:18 +02:00
|
|
|
m_buildFile->setVisible(fileVisible);
|
2014-04-08 16:56:32 +02:00
|
|
|
m_buildFile->setParameter(fileName);
|
2013-06-10 15:40:18 +02:00
|
|
|
|
2014-02-10 17:28:15 +01:00
|
|
|
m_buildProduct->setEnabled(enabled);
|
2013-06-10 15:40:18 +02:00
|
|
|
m_buildProduct->setVisible(productVisible);
|
2014-04-08 16:56:32 +02:00
|
|
|
m_buildProduct->setParameter(productName);
|
2014-02-10 17:28:15 +01:00
|
|
|
|
|
|
|
|
m_buildSubproject->setEnabled(enabled);
|
|
|
|
|
m_buildSubproject->setVisible(subprojectVisible);
|
2014-04-08 16:56:32 +02:00
|
|
|
m_buildSubproject->setParameter(subprojectName);
|
2013-05-27 14:36:59 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
void QbsProjectManagerPlugin::buildStateChanged(Project *project)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2014-04-08 15:13:05 +02:00
|
|
|
if (project == m_currentProject)
|
2013-01-30 18:19:31 +01:00
|
|
|
updateReparseQbsAction();
|
2014-04-08 15:13:05 +02:00
|
|
|
|
2014-04-08 16:58:27 +02:00
|
|
|
if (project == m_selectedProject)
|
2014-04-08 16:41:12 +02:00
|
|
|
updateContextActions();
|
2014-04-08 16:58:27 +02:00
|
|
|
|
2014-06-24 16:10:18 +02:00
|
|
|
m_editorNode = currentEditorNode();
|
|
|
|
|
m_editorProject = currentEditorProject();
|
2014-04-08 16:58:27 +02:00
|
|
|
if (project == m_editorProject)
|
2013-06-10 15:40:18 +02:00
|
|
|
updateBuildActions();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::parsingStateChanged()
|
|
|
|
|
{
|
2014-04-08 15:13:05 +02:00
|
|
|
QbsProject *project = qobject_cast<QbsProject *>(sender());
|
|
|
|
|
|
|
|
|
|
if (!project || project == m_currentProject)
|
2013-01-30 18:19:31 +01:00
|
|
|
updateReparseQbsAction();
|
2014-04-08 15:13:05 +02:00
|
|
|
|
|
|
|
|
if (!project || project == m_selectedProject)
|
2014-04-08 16:41:12 +02:00
|
|
|
updateContextActions();
|
2014-04-08 16:53:21 +02:00
|
|
|
|
|
|
|
|
m_editorNode = currentEditorNode();
|
|
|
|
|
m_editorProject = currentEditorProject();
|
|
|
|
|
if (!project || project == m_editorProject)
|
|
|
|
|
updateBuildActions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::currentEditorChanged()
|
|
|
|
|
{
|
|
|
|
|
m_editorNode = currentEditorNode();
|
|
|
|
|
m_editorProject = currentEditorProject();
|
|
|
|
|
|
|
|
|
|
updateBuildActions();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::buildFileContextMenu()
|
|
|
|
|
{
|
2014-04-08 11:52:52 +02:00
|
|
|
QTC_ASSERT(m_selectedNode, return);
|
|
|
|
|
QTC_ASSERT(m_selectedProject, return);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2015-10-29 17:53:47 +01:00
|
|
|
buildSingleFile(m_selectedProject, m_selectedNode->filePath().toString());
|
2013-05-27 14:36:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::buildFile()
|
|
|
|
|
{
|
2014-04-08 17:10:25 +02:00
|
|
|
if (!m_editorProject || !m_editorNode)
|
2013-05-27 14:36:59 +02:00
|
|
|
return;
|
|
|
|
|
|
2015-10-29 17:53:47 +01:00
|
|
|
buildSingleFile(m_editorProject, m_editorNode->filePath().toString());
|
2013-05-27 14:36:59 +02:00
|
|
|
}
|
|
|
|
|
|
2013-06-10 15:40:18 +02:00
|
|
|
void QbsProjectManagerPlugin::buildProductContextMenu()
|
|
|
|
|
{
|
2014-04-08 11:52:52 +02:00
|
|
|
QTC_ASSERT(m_selectedNode, return);
|
|
|
|
|
QTC_ASSERT(m_selectedProject, return);
|
2013-06-10 15:40:18 +02:00
|
|
|
|
2015-01-09 15:50:06 +01:00
|
|
|
const QbsProductNode * const productNode = dynamic_cast<QbsProductNode *>(m_selectedNode);
|
2014-11-17 16:45:38 +01:00
|
|
|
QTC_ASSERT(productNode, return);
|
|
|
|
|
|
|
|
|
|
buildProducts(m_selectedProject,
|
|
|
|
|
QStringList(QbsProject::uniqueProductName(productNode->qbsProductData())));
|
2013-06-10 15:40:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::buildProduct()
|
|
|
|
|
{
|
2014-04-08 17:10:25 +02:00
|
|
|
if (!m_editorProject || !m_editorNode)
|
|
|
|
|
return;
|
2013-06-10 15:40:18 +02:00
|
|
|
|
2015-01-09 15:50:06 +01:00
|
|
|
QbsProductNode *product = dynamic_cast<QbsProductNode *>(m_editorNode->projectNode());
|
2013-06-10 15:40:18 +02:00
|
|
|
|
2014-04-08 17:10:25 +02:00
|
|
|
if (!product)
|
2013-06-10 15:40:18 +02:00
|
|
|
return;
|
|
|
|
|
|
2014-11-17 16:45:38 +01:00
|
|
|
buildProducts(m_editorProject,
|
|
|
|
|
QStringList(QbsProject::uniqueProductName(product->qbsProductData())));
|
2013-06-10 15:40:18 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-10 17:28:15 +01:00
|
|
|
void QbsProjectManagerPlugin::buildSubprojectContextMenu()
|
|
|
|
|
{
|
2014-04-08 11:52:52 +02:00
|
|
|
QTC_ASSERT(m_selectedNode, return);
|
|
|
|
|
QTC_ASSERT(m_selectedProject, return);
|
2014-02-10 17:28:15 +01:00
|
|
|
|
2015-01-09 15:50:06 +01:00
|
|
|
QbsProjectNode *subProject = dynamic_cast<QbsProjectNode *>(m_selectedNode);
|
2014-02-10 17:28:15 +01:00
|
|
|
QTC_ASSERT(subProject, return);
|
|
|
|
|
|
|
|
|
|
QStringList toBuild;
|
|
|
|
|
foreach (const qbs::ProductData &data, subProject->qbsProjectData().allProducts())
|
2014-09-05 12:08:15 +02:00
|
|
|
toBuild << QbsProject::uniqueProductName(data);
|
2014-02-10 17:28:15 +01:00
|
|
|
|
2014-04-08 11:52:52 +02:00
|
|
|
buildProducts(m_selectedProject, toBuild);
|
2014-02-10 17:28:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::buildSubproject()
|
|
|
|
|
{
|
2014-04-08 17:10:25 +02:00
|
|
|
if (!m_editorNode || !m_editorProject)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-02-10 17:28:15 +01:00
|
|
|
QbsProjectNode *subproject = 0;
|
2015-01-09 15:50:06 +01:00
|
|
|
QbsBaseProjectNode *start = dynamic_cast<QbsBaseProjectNode *>(m_editorNode->projectNode());
|
2014-04-08 17:10:25 +02:00
|
|
|
while (start && start != m_editorProject->rootProjectNode()) {
|
2015-01-09 15:50:06 +01:00
|
|
|
QbsProjectNode *tmp = dynamic_cast<QbsProjectNode *>(start);
|
2014-04-08 17:10:25 +02:00
|
|
|
if (tmp) {
|
|
|
|
|
subproject = tmp;
|
|
|
|
|
break;
|
2014-02-10 17:28:15 +01:00
|
|
|
}
|
2015-01-09 15:50:06 +01:00
|
|
|
start = dynamic_cast<QbsProjectNode *>(start->parentFolderNode());
|
2014-02-10 17:28:15 +01:00
|
|
|
}
|
|
|
|
|
|
2014-04-08 17:10:25 +02:00
|
|
|
if (!subproject)
|
2014-02-10 17:28:15 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QStringList toBuild;
|
|
|
|
|
foreach (const qbs::ProductData &data, subproject->qbsProjectData().allProducts())
|
2014-09-05 12:08:15 +02:00
|
|
|
toBuild << QbsProject::uniqueProductName(data);
|
2014-02-10 17:28:15 +01:00
|
|
|
|
2014-04-08 17:10:25 +02:00
|
|
|
buildProducts(m_editorProject, toBuild);
|
2014-02-10 17:28:15 +01:00
|
|
|
}
|
|
|
|
|
|
2013-07-24 16:47:02 +02:00
|
|
|
void QbsProjectManagerPlugin::buildFiles(QbsProject *project, const QStringList &files,
|
|
|
|
|
const QStringList &activeFileTags)
|
2013-05-27 14:36:59 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(project, return);
|
|
|
|
|
QTC_ASSERT(!files.isEmpty(), return);
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
Target *t = project->activeTarget();
|
2013-01-30 18:19:31 +01:00
|
|
|
if (!t)
|
|
|
|
|
return;
|
|
|
|
|
QbsBuildConfiguration *bc = qobject_cast<QbsBuildConfiguration *>(t->activeBuildConfiguration());
|
|
|
|
|
if (!bc)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-09-12 01:08:28 +02:00
|
|
|
if (!ProjectExplorerPlugin::saveModifiedFiles())
|
2013-01-30 18:19:31 +01:00
|
|
|
return;
|
|
|
|
|
|
2013-05-27 14:36:59 +02:00
|
|
|
bc->setChangedFiles(files);
|
2013-07-24 16:47:02 +02:00
|
|
|
bc->setActiveFileTags(activeFileTags);
|
2013-06-10 15:40:18 +02:00
|
|
|
bc->setProducts(QStringList());
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2013-09-05 14:36:20 +02:00
|
|
|
const Core::Id buildStep = ProjectExplorer::Constants::BUILDSTEPS_BUILD;
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
const QString name = ProjectExplorerPlugin::displayNameForStepId(buildStep);
|
2013-09-05 14:36:20 +02:00
|
|
|
BuildManager::buildList(bc->stepList(buildStep), name);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
bc->setChangedFiles(QStringList());
|
2014-04-14 10:36:08 +02:00
|
|
|
bc->setActiveFileTags(QStringList());
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2013-07-24 16:47:02 +02:00
|
|
|
void QbsProjectManagerPlugin::buildSingleFile(QbsProject *project, const QString &file)
|
|
|
|
|
{
|
|
|
|
|
buildFiles(project, QStringList(file), QStringList()
|
|
|
|
|
<< QLatin1String("obj") << QLatin1String("hpp"));
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-10 15:40:18 +02:00
|
|
|
void QbsProjectManagerPlugin::buildProducts(QbsProject *project, const QStringList &products)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(project, return);
|
|
|
|
|
QTC_ASSERT(!products.isEmpty(), return);
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
Target *t = project->activeTarget();
|
2013-06-10 15:40:18 +02:00
|
|
|
if (!t)
|
|
|
|
|
return;
|
|
|
|
|
QbsBuildConfiguration *bc = qobject_cast<QbsBuildConfiguration *>(t->activeBuildConfiguration());
|
|
|
|
|
if (!bc)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-09-12 01:08:28 +02:00
|
|
|
if (!ProjectExplorerPlugin::saveModifiedFiles())
|
2013-06-10 15:40:18 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bc->setChangedFiles(QStringList());
|
|
|
|
|
bc->setProducts(products);
|
|
|
|
|
|
2013-09-05 14:36:20 +02:00
|
|
|
const Core::Id buildStep = ProjectExplorer::Constants::BUILDSTEPS_BUILD;
|
2013-06-10 15:40:18 +02:00
|
|
|
|
2013-09-05 14:36:20 +02:00
|
|
|
const QString name = ProjectExplorerPlugin::displayNameForStepId(buildStep);
|
|
|
|
|
BuildManager::buildList(bc->stepList(buildStep), name);
|
2013-06-10 15:40:18 +02:00
|
|
|
|
|
|
|
|
bc->setProducts(QStringList());
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 14:50:20 +02:00
|
|
|
void QbsProjectManagerPlugin::reparseSelectedProject()
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2014-04-08 15:13:05 +02:00
|
|
|
reparseProject(m_selectedProject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::reparseCurrentProject()
|
|
|
|
|
{
|
|
|
|
|
reparseProject(m_currentProject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::reparseProject(QbsProject *project)
|
|
|
|
|
{
|
2014-07-11 12:44:12 +02:00
|
|
|
if (!project)
|
2014-03-03 14:15:46 +01:00
|
|
|
return;
|
|
|
|
|
|
2014-07-11 12:44:12 +02:00
|
|
|
// Qbs does update the build graph during the build. So we cannot
|
|
|
|
|
// start to parse while a build is running or we will lose information.
|
|
|
|
|
if (BuildManager::isBuilding(project))
|
|
|
|
|
project->scheduleParsing();
|
|
|
|
|
else
|
2014-07-17 12:02:56 +02:00
|
|
|
project->parseCurrentBuildConfiguration();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QbsProjectManager
|