2013-01-30 18:19:31 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2013-01-30 18:19:31 +01:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
|
|
|
|
**
|
|
|
|
|
** 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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qbsprojectmanagerplugin.h"
|
|
|
|
|
|
|
|
|
|
#include "qbsbuildconfiguration.h"
|
|
|
|
|
#include "qbsbuildstep.h"
|
|
|
|
|
#include "qbscleanstep.h"
|
2013-05-06 11:16:41 +02:00
|
|
|
#include "qbsdeployconfigurationfactory.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>
|
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>
|
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();
|
2014-12-21 21:54:30 +02:00
|
|
|
return doc ? SessionManager::nodeForFile(doc->filePath().toString()) : 0;
|
2014-04-08 16:53:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QbsProject *currentEditorProject()
|
|
|
|
|
{
|
|
|
|
|
Core::IDocument *doc = Core::EditorManager::currentDocument();
|
2014-12-21 21:54:30 +02:00
|
|
|
return doc ? qobject_cast<QbsProject *>(SessionManager::projectForFile(doc->filePath().toString())) : 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);
|
2013-06-10 15:40:18 +02:00
|
|
|
const Core::Context globalcontext(Core::Constants::C_GLOBAL);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2013-09-12 16:06:33 +02:00
|
|
|
Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "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);
|
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);
|
2014-04-08 15:13:05 +02:00
|
|
|
connect(m_reparseQbs, SIGNAL(triggered()), this, SLOT(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);
|
2014-04-08 14:50:20 +02:00
|
|
|
connect(m_reparseQbsCtx, SIGNAL(triggered()), this, SLOT(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);
|
2014-04-08 11:35:37 +02:00
|
|
|
connect(m_buildFileCtx, SIGNAL(triggered()), this, SLOT(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);
|
|
|
|
|
command = Core::ActionManager::registerAction(m_buildFile, Constants::ACTION_BUILD_FILE, globalcontext);
|
|
|
|
|
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);
|
|
|
|
|
connect(m_buildFile, SIGNAL(triggered()), this, SLOT(buildFile()));
|
|
|
|
|
|
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);
|
2014-04-08 11:35:37 +02:00
|
|
|
connect(m_buildProductCtx, SIGNAL(triggered()), this, SLOT(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);
|
|
|
|
|
command = Core::ActionManager::registerAction(m_buildProduct, Constants::ACTION_BUILD_PRODUCT, globalcontext);
|
|
|
|
|
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);
|
|
|
|
|
connect(m_buildProduct, SIGNAL(triggered()), this, SLOT(buildProduct()));
|
|
|
|
|
|
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);
|
2014-04-08 11:35:37 +02:00
|
|
|
connect(m_buildSubprojectCtx, SIGNAL(triggered()), this, SLOT(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);
|
|
|
|
|
command = Core::ActionManager::registerAction(m_buildSubproject, Constants::ACTION_BUILD_SUBPROJECT, globalcontext);
|
|
|
|
|
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);
|
|
|
|
|
connect(m_buildSubproject, SIGNAL(triggered()), this, SLOT(buildSubproject()));
|
|
|
|
|
|
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
|
|
|
|
2013-09-05 14:36:20 +02:00
|
|
|
connect(BuildManager::instance(), SIGNAL(buildStateChanged(ProjectExplorer::Project*)),
|
2013-01-30 18:19:31 +01:00
|
|
|
this, SLOT(buildStateChanged(ProjectExplorer::Project*)));
|
|
|
|
|
|
2013-05-27 14:36:59 +02:00
|
|
|
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
|
2014-04-08 16:53:21 +02:00
|
|
|
this, SLOT(currentEditorChanged()));
|
2013-05-27 14:36:59 +02:00
|
|
|
|
2014-04-08 14:59:14 +02:00
|
|
|
connect(SessionManager::instance(), SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectWasAdded(ProjectExplorer::Project*)));
|
2014-04-08 16:53:21 +02:00
|
|
|
connect(SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectWasRemoved()));
|
2014-04-08 15:13:05 +02:00
|
|
|
connect(SessionManager::instance(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(currentProjectWasChanged(ProjectExplorer::Project*)));
|
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;
|
|
|
|
|
|
|
|
|
|
connect(qbsProject, SIGNAL(projectParsingStarted()), this, SLOT(parsingStateChanged()));
|
|
|
|
|
connect(qbsProject, SIGNAL(projectParsingDone(bool)), this, SLOT(parsingStateChanged()));
|
|
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
|
|
|
2014-04-08 16:41:12 +02:00
|
|
|
bool isFile = m_selectedProject && m_selectedNode && (m_selectedNode->nodeType() == ProjectExplorer::FileNodeType);
|
|
|
|
|
bool isProduct = m_selectedProject && m_selectedNode && qobject_cast<QbsProductNode *>(m_selectedNode->projectNode());
|
|
|
|
|
QbsProjectNode *subproject = qobject_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
|
|
|
|
2014-04-08 16:56:32 +02:00
|
|
|
fileName = QFileInfo(m_editorNode->path()).fileName();
|
|
|
|
|
fileVisible = m_editorProject && m_editorNode && qobject_cast<QbsBaseProjectNode *>(m_editorNode->projectNode());
|
|
|
|
|
|
2014-02-10 17:28:15 +01:00
|
|
|
QbsProductNode *productNode
|
2014-04-08 16:53:21 +02:00
|
|
|
= qobject_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
|
|
|
|
|
= qobject_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
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
void QbsProjectManagerPlugin::buildStateChanged(ProjectExplorer::Project *project)
|
|
|
|
|
{
|
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
|
|
|
|
2014-04-08 11:52:52 +02:00
|
|
|
buildSingleFile(m_selectedProject, m_selectedNode->path());
|
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;
|
|
|
|
|
|
2014-04-08 17:10:25 +02:00
|
|
|
buildSingleFile(m_editorProject, m_editorNode->path());
|
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
|
|
|
|
2014-11-17 16:45:38 +01:00
|
|
|
const QbsProductNode * const productNode = qobject_cast<QbsProductNode *>(m_selectedNode);
|
|
|
|
|
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
|
|
|
|
2014-04-08 17:10:25 +02:00
|
|
|
QbsProductNode *product = qobject_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
|
|
|
|
2014-04-08 11:52:52 +02:00
|
|
|
QbsProjectNode *subProject = qobject_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;
|
2014-04-08 17:10:25 +02:00
|
|
|
QbsBaseProjectNode *start = qobject_cast<QbsBaseProjectNode *>(m_editorNode->projectNode());
|
|
|
|
|
while (start && start != m_editorProject->rootProjectNode()) {
|
|
|
|
|
QbsProjectNode *tmp = qobject_cast<QbsProjectNode *>(start);
|
|
|
|
|
if (tmp) {
|
|
|
|
|
subproject = tmp;
|
|
|
|
|
break;
|
2014-02-10 17:28:15 +01:00
|
|
|
}
|
2014-04-08 17:10:25 +02:00
|
|
|
start = qobject_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);
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::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
|
|
|
|
|
|
|
|
const QString name = ProjectExplorer::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);
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::Target *t = project->activeTarget();
|
|
|
|
|
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
|