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"
|
2017-05-04 12:16:38 +02:00
|
|
|
#include "qbsinstallstep.h"
|
2017-06-16 15:57:56 +02:00
|
|
|
#include "qbskitinformation.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>
|
2017-09-06 16:04:54 +02:00
|
|
|
#include <coreplugin/helpmanager.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>
|
2017-03-03 18:16:34 +01:00
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
|
|
|
|
#include <projectexplorer/projecttree.h>
|
2019-03-13 12:22:44 +01:00
|
|
|
#include <projectexplorer/runcontrol.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>
|
2017-03-03 18:16:34 +01:00
|
|
|
|
2013-04-17 12:40:40 +02:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
#include <qmljstools/qmljstoolsconstants.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>
|
|
|
|
|
|
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();
|
2017-12-04 13:53:38 +01:00
|
|
|
return doc ? ProjectTree::nodeForFile(doc->filePath()) : nullptr;
|
2014-04-08 16:53:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QbsProject *currentEditorProject()
|
|
|
|
|
{
|
|
|
|
|
Core::IDocument *doc = Core::EditorManager::currentDocument();
|
2017-12-04 13:53:38 +01:00
|
|
|
return doc ? qobject_cast<QbsProject *>(SessionManager::projectForFile(doc->filePath())) : nullptr;
|
2014-04-08 16:53:21 +02:00
|
|
|
}
|
|
|
|
|
|
2018-02-06 16:36:01 +01:00
|
|
|
class QbsProjectManagerPluginPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QbsManager manager;
|
|
|
|
|
QbsBuildConfigurationFactory buildConfigFactory;
|
|
|
|
|
QbsBuildStepFactory buildStepFactory;
|
|
|
|
|
QbsCleanStepFactory cleanStepFactory;
|
|
|
|
|
QbsInstallStepFactory installStepFactory;
|
|
|
|
|
QbsRunConfigurationFactory runConfigFactory;
|
2019-03-13 12:22:44 +01:00
|
|
|
SimpleRunWorkerFactory<QbsRunConfiguration> runWorkerFactory;
|
2018-02-06 16:36:01 +01:00
|
|
|
QbsProfilesSettingsPage profilesSetttingsPage;
|
2019-03-14 09:17:59 +01:00
|
|
|
QbsKitAspect qbsKitAspect;
|
2018-02-06 16:36:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QbsProjectManagerPlugin::~QbsProjectManagerPlugin()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2018-02-06 16:36:01 +01:00
|
|
|
d = new QbsProjectManagerPluginPrivate;
|
|
|
|
|
|
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");
|
2018-09-19 14:39:46 +02:00
|
|
|
Core::HelpManager::registerDocumentation({Core::HelpManager::documentationPath() + "/qbs.qch"});
|
2013-04-17 12:40:40 +02:00
|
|
|
|
2017-03-03 18:16:34 +01:00
|
|
|
ProjectManager::registerProjectType<QbsProject>(QmlJSTools::Constants::QBS_MIMETYPE);
|
|
|
|
|
|
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
|
|
|
|
2017-04-07 13:46:50 +02:00
|
|
|
m_cleanProductCtx = new QAction(tr("Clean"), this);
|
|
|
|
|
command = Core::ActionManager::registerAction(
|
|
|
|
|
m_cleanProductCtx, Constants::ACTION_CLEAN_PRODUCT_CONTEXT, projectContext);
|
|
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
|
|
|
|
connect(m_cleanProductCtx, &QAction::triggered,
|
|
|
|
|
this, &QbsProjectManagerPlugin::cleanProductContextMenu);
|
|
|
|
|
|
|
|
|
|
m_cleanProduct = new Utils::ParameterAction(tr("Clean Product"), tr("Clean Product \"%1\""),
|
|
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
|
|
|
|
command = Core::ActionManager::registerAction(m_cleanProduct, Constants::ACTION_CLEAN_PRODUCT);
|
|
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_CLEAN);
|
|
|
|
|
connect(m_cleanProduct, &QAction::triggered, this, &QbsProjectManagerPlugin::cleanProduct);
|
|
|
|
|
|
|
|
|
|
m_rebuildProductCtx = new QAction(tr("Rebuild"), this);
|
|
|
|
|
command = Core::ActionManager::registerAction(
|
|
|
|
|
m_rebuildProductCtx, Constants::ACTION_REBUILD_PRODUCT_CONTEXT, projectContext);
|
|
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
|
|
|
|
connect(m_rebuildProductCtx, &QAction::triggered,
|
|
|
|
|
this, &QbsProjectManagerPlugin::rebuildProductContextMenu);
|
|
|
|
|
|
|
|
|
|
m_rebuildProduct = new Utils::ParameterAction(
|
|
|
|
|
tr("Rebuild Product"), tr("Rebuild Product \"%1\""),
|
|
|
|
|
Utils::ParameterAction::AlwaysEnabled, this);
|
|
|
|
|
command = Core::ActionManager::registerAction(m_rebuildProduct,
|
|
|
|
|
Constants::ACTION_REBUILD_PRODUCT);
|
|
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_REBUILD);
|
|
|
|
|
connect(m_rebuildProduct, &QAction::triggered, this, &QbsProjectManagerPlugin::rebuildProduct);
|
|
|
|
|
|
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
|
|
|
|
2017-04-07 13:46:50 +02:00
|
|
|
m_cleanSubprojectCtx = new QAction(tr("Clean"), this);
|
|
|
|
|
command = Core::ActionManager::registerAction(
|
|
|
|
|
m_cleanSubprojectCtx, Constants::ACTION_CLEAN_SUBPROJECT_CONTEXT, projectContext);
|
|
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
|
|
|
|
connect(m_cleanSubprojectCtx, &QAction::triggered,
|
|
|
|
|
this, &QbsProjectManagerPlugin::cleanSubprojectContextMenu);
|
|
|
|
|
|
|
|
|
|
m_rebuildSubprojectCtx = new QAction(tr("Rebuild"), this);
|
|
|
|
|
command = Core::ActionManager::registerAction(
|
|
|
|
|
m_rebuildSubprojectCtx, Constants::ACTION_REBUILD_SUBPROJECT_CONTEXT,
|
|
|
|
|
projectContext);
|
|
|
|
|
command->setAttribute(Core::Command::CA_Hide);
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
|
|
|
|
connect(m_rebuildSubprojectCtx, &QAction::triggered,
|
|
|
|
|
this, &QbsProjectManagerPlugin::rebuildSubprojectContextMenu);
|
|
|
|
|
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
// Connect
|
2014-11-19 17:58:33 +01:00
|
|
|
connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged,
|
2017-02-24 10:02:39 +01:00
|
|
|
this, &QbsProjectManagerPlugin::updateContextActions);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(BuildManager::instance(), &BuildManager::buildStateChanged,
|
2017-02-24 12:33:33 +01:00
|
|
|
this, &QbsProjectManagerPlugin::projectChanged);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged,
|
2017-02-24 12:33:33 +01:00
|
|
|
this, &QbsProjectManagerPlugin::updateBuildActions);
|
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,
|
2017-02-24 12:33:33 +01:00
|
|
|
this, &QbsProjectManagerPlugin::updateBuildActions);
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(SessionManager::instance(), &SessionManager::startupProjectChanged,
|
2017-02-24 12:33:33 +01:00
|
|
|
this, &QbsProjectManagerPlugin::updateReparseQbsAction);
|
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)
|
|
|
|
|
{
|
2018-07-27 12:10:20 +02:00
|
|
|
auto qbsProject = qobject_cast<QbsProject *>(project);
|
2014-04-08 14:59:14 +02:00
|
|
|
|
|
|
|
|
if (!qbsProject)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-07-13 10:51:15 +02:00
|
|
|
connect(qbsProject, &Project::parsingStarted,
|
2017-02-24 12:33:33 +01:00
|
|
|
this, &QbsProjectManagerPlugin::projectChanged);
|
2017-07-13 10:51:15 +02:00
|
|
|
connect(qbsProject, &Project::parsingFinished,
|
2017-02-24 12:33:33 +01:00
|
|
|
this, &QbsProjectManagerPlugin::projectChanged);
|
2014-04-08 16:53:21 +02:00
|
|
|
}
|
|
|
|
|
|
2014-04-08 16:41:12 +02:00
|
|
|
void QbsProjectManagerPlugin::updateContextActions()
|
|
|
|
|
{
|
2018-07-27 12:10:20 +02:00
|
|
|
auto project = qobject_cast<Internal::QbsProject *>(ProjectTree::currentProject());
|
2017-05-31 15:48:45 +02:00
|
|
|
const Node *node = ProjectTree::findCurrentNode();
|
2017-02-24 10:02:39 +01:00
|
|
|
bool isEnabled = !BuildManager::isBuilding(project)
|
|
|
|
|
&& project && !project->isParsing()
|
|
|
|
|
&& node && node->isEnabled();
|
|
|
|
|
|
2019-02-28 17:19:18 +01:00
|
|
|
const bool isFile = project && node && node->asFileNode();
|
2017-05-31 15:48:45 +02:00
|
|
|
const bool isProduct = project && node && dynamic_cast<const QbsProductNode *>(node);
|
2018-07-27 12:10:20 +02:00
|
|
|
const auto subproject = dynamic_cast<const QbsProjectNode *>(node);
|
2017-02-24 10:02:39 +01:00
|
|
|
bool isSubproject = project && subproject && subproject != project->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);
|
2017-04-07 13:46:50 +02:00
|
|
|
m_cleanProductCtx->setVisible(isEnabled && isProduct);
|
|
|
|
|
m_rebuildProductCtx->setVisible(isEnabled && isProduct);
|
2014-04-08 16:44:50 +02:00
|
|
|
m_buildSubprojectCtx->setVisible(isEnabled && isSubproject);
|
2017-04-07 13:46:50 +02:00
|
|
|
m_cleanSubprojectCtx->setVisible(isEnabled && isSubproject);
|
|
|
|
|
m_rebuildSubprojectCtx->setVisible(isEnabled && isSubproject);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::updateReparseQbsAction()
|
|
|
|
|
{
|
2018-07-27 12:10:20 +02:00
|
|
|
auto project = qobject_cast<QbsProject *>(SessionManager::startupProject());
|
2017-02-24 12:33:33 +01:00
|
|
|
m_reparseQbs->setEnabled(project
|
|
|
|
|
&& !BuildManager::isBuilding(project)
|
|
|
|
|
&& !project->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;
|
2013-05-27 14:36:59 +02:00
|
|
|
|
2014-04-08 16:56:32 +02:00
|
|
|
QString fileName;
|
|
|
|
|
QString productName;
|
|
|
|
|
|
2017-02-24 12:33:33 +01:00
|
|
|
if (Node *editorNode = currentEditorNode()) {
|
|
|
|
|
fileName = editorNode->filePath().fileName();
|
2014-04-08 16:56:32 +02:00
|
|
|
|
2019-02-26 16:47:40 +01:00
|
|
|
ProjectNode *parentProjectNode = editorNode->parentProjectNode();
|
2019-03-13 14:15:33 +01:00
|
|
|
const QbsProductNode *productNode = nullptr;
|
|
|
|
|
for (const ProjectNode *potentialProductNode = parentProjectNode;
|
|
|
|
|
potentialProductNode && !productNode;
|
|
|
|
|
potentialProductNode = potentialProductNode->parentProjectNode()) {
|
|
|
|
|
productNode = dynamic_cast<const QbsProductNode *>(potentialProductNode);
|
|
|
|
|
}
|
2019-02-26 16:47:40 +01:00
|
|
|
|
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
|
|
|
}
|
2019-02-26 16:35:47 +01:00
|
|
|
|
|
|
|
|
if (QbsProject *editorProject = currentEditorProject()) {
|
|
|
|
|
enabled = !BuildManager::isBuilding(editorProject) && !editorProject->isParsing();
|
2019-02-26 16:47:40 +01:00
|
|
|
fileVisible = productNode
|
|
|
|
|
|| dynamic_cast<QbsProjectNode *>(parentProjectNode)
|
|
|
|
|
|| dynamic_cast<QbsGroupNode *>(parentProjectNode);
|
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);
|
2017-04-07 13:46:50 +02:00
|
|
|
m_cleanProduct->setEnabled(enabled);
|
|
|
|
|
m_cleanProduct->setVisible(productVisible);
|
|
|
|
|
m_cleanProduct->setParameter(productName);
|
|
|
|
|
m_rebuildProduct->setEnabled(enabled);
|
|
|
|
|
m_rebuildProduct->setVisible(productVisible);
|
|
|
|
|
m_rebuildProduct->setParameter(productName);
|
2013-05-27 14:36:59 +02:00
|
|
|
}
|
|
|
|
|
|
2017-02-24 12:33:33 +01:00
|
|
|
void QbsProjectManagerPlugin::projectChanged()
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2018-07-27 12:10:20 +02:00
|
|
|
auto project = qobject_cast<QbsProject *>(sender());
|
2014-04-08 15:13:05 +02:00
|
|
|
|
2017-02-24 12:33:33 +01:00
|
|
|
if (!project || project == SessionManager::startupProject())
|
2013-01-30 18:19:31 +01:00
|
|
|
updateReparseQbsAction();
|
2014-04-08 15:13:05 +02:00
|
|
|
|
2017-02-24 10:02:39 +01:00
|
|
|
if (!project || project == ProjectTree::currentProject())
|
2014-04-08 16:41:12 +02:00
|
|
|
updateContextActions();
|
2014-04-08 16:53:21 +02:00
|
|
|
|
2017-02-24 12:33:33 +01:00
|
|
|
if (!project || project == currentEditorProject())
|
2014-04-08 16:53:21 +02:00
|
|
|
updateBuildActions();
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
void QbsProjectManagerPlugin::buildFileContextMenu()
|
|
|
|
|
{
|
2017-05-31 15:48:45 +02:00
|
|
|
const Node *node = ProjectTree::findCurrentNode();
|
2017-02-24 10:02:39 +01:00
|
|
|
QTC_ASSERT(node, return);
|
2018-07-27 12:10:20 +02:00
|
|
|
auto project = dynamic_cast<QbsProject *>(ProjectTree::currentProject());
|
2017-02-24 10:02:39 +01:00
|
|
|
QTC_ASSERT(project, return);
|
|
|
|
|
buildSingleFile(project, node->filePath().toString());
|
2013-05-27 14:36:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::buildFile()
|
|
|
|
|
{
|
2017-02-24 12:33:33 +01:00
|
|
|
Node *node = currentEditorNode();
|
|
|
|
|
QbsProject *project = currentEditorProject();
|
|
|
|
|
if (!project || !node)
|
2013-05-27 14:36:59 +02:00
|
|
|
return;
|
|
|
|
|
|
2017-02-24 12:33:33 +01:00
|
|
|
buildSingleFile(project, node->filePath().toString());
|
2013-05-27 14:36:59 +02:00
|
|
|
}
|
|
|
|
|
|
2013-06-10 15:40:18 +02:00
|
|
|
void QbsProjectManagerPlugin::buildProductContextMenu()
|
2017-04-07 13:46:50 +02:00
|
|
|
{
|
|
|
|
|
runStepsForProductContextMenu({Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD)});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::cleanProductContextMenu()
|
|
|
|
|
{
|
|
|
|
|
runStepsForProductContextMenu({Core::Id(ProjectExplorer::Constants::BUILDSTEPS_CLEAN)});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::rebuildProductContextMenu()
|
|
|
|
|
{
|
|
|
|
|
runStepsForProductContextMenu({
|
|
|
|
|
Core::Id(ProjectExplorer::Constants::BUILDSTEPS_CLEAN),
|
|
|
|
|
Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::runStepsForProductContextMenu(const QList<Core::Id> &stepTypes)
|
2013-06-10 15:40:18 +02:00
|
|
|
{
|
2017-05-31 15:48:45 +02:00
|
|
|
const Node *node = ProjectTree::findCurrentNode();
|
2017-02-24 10:02:39 +01:00
|
|
|
QTC_ASSERT(node, return);
|
2018-07-27 12:10:20 +02:00
|
|
|
auto project = dynamic_cast<QbsProject *>(ProjectTree::currentProject());
|
2017-02-24 10:02:39 +01:00
|
|
|
QTC_ASSERT(project, return);
|
2013-06-10 15:40:18 +02:00
|
|
|
|
2018-07-27 12:10:20 +02:00
|
|
|
const auto * const productNode = dynamic_cast<const QbsProductNode *>(node);
|
2014-11-17 16:45:38 +01:00
|
|
|
QTC_ASSERT(productNode, return);
|
|
|
|
|
|
2017-04-07 13:46:50 +02:00
|
|
|
runStepsForProducts(project, {QbsProject::uniqueProductName(productNode->qbsProductData())},
|
|
|
|
|
{stepTypes});
|
2013-06-10 15:40:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::buildProduct()
|
2017-04-07 13:46:50 +02:00
|
|
|
{
|
|
|
|
|
runStepsForProduct({Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD)});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::cleanProduct()
|
|
|
|
|
{
|
|
|
|
|
runStepsForProduct({Core::Id(ProjectExplorer::Constants::BUILDSTEPS_CLEAN)});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::rebuildProduct()
|
|
|
|
|
{
|
|
|
|
|
runStepsForProduct({
|
|
|
|
|
Core::Id(ProjectExplorer::Constants::BUILDSTEPS_CLEAN),
|
|
|
|
|
Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::runStepsForProduct(const QList<Core::Id> &stepTypes)
|
2013-06-10 15:40:18 +02:00
|
|
|
{
|
2017-02-24 12:33:33 +01:00
|
|
|
Node *node = currentEditorNode();
|
|
|
|
|
if (!node)
|
2014-04-08 17:10:25 +02:00
|
|
|
return;
|
2018-07-27 12:10:20 +02:00
|
|
|
auto product = dynamic_cast<QbsProductNode *>(node->parentProjectNode());
|
2014-04-08 17:10:25 +02:00
|
|
|
if (!product)
|
2013-06-10 15:40:18 +02:00
|
|
|
return;
|
2017-02-24 12:33:33 +01:00
|
|
|
QbsProject *project = currentEditorProject();
|
|
|
|
|
if (!project)
|
|
|
|
|
return;
|
2017-04-07 13:46:50 +02:00
|
|
|
runStepsForProducts(project, {QbsProject::uniqueProductName(product->qbsProductData())},
|
|
|
|
|
{stepTypes});
|
2013-06-10 15:40:18 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-10 17:28:15 +01:00
|
|
|
void QbsProjectManagerPlugin::buildSubprojectContextMenu()
|
2017-04-07 13:46:50 +02:00
|
|
|
{
|
|
|
|
|
runStepsForSubprojectContextMenu({Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD)});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::cleanSubprojectContextMenu()
|
|
|
|
|
{
|
|
|
|
|
runStepsForSubprojectContextMenu({Core::Id(ProjectExplorer::Constants::BUILDSTEPS_CLEAN)});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::rebuildSubprojectContextMenu()
|
|
|
|
|
{
|
|
|
|
|
runStepsForSubprojectContextMenu({
|
|
|
|
|
Core::Id(ProjectExplorer::Constants::BUILDSTEPS_CLEAN),
|
|
|
|
|
Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::runStepsForSubprojectContextMenu(const QList<Core::Id> &stepTypes)
|
2014-02-10 17:28:15 +01:00
|
|
|
{
|
2017-05-31 15:48:45 +02:00
|
|
|
const Node *node = ProjectTree::findCurrentNode();
|
2017-02-24 10:02:39 +01:00
|
|
|
QTC_ASSERT(node, return);
|
2018-07-27 12:10:20 +02:00
|
|
|
auto project = dynamic_cast<QbsProject *>(ProjectTree::currentProject());
|
2017-02-24 10:02:39 +01:00
|
|
|
QTC_ASSERT(project, return);
|
2014-02-10 17:28:15 +01:00
|
|
|
|
2018-07-27 12:10:20 +02:00
|
|
|
const auto subProject = dynamic_cast<const QbsProjectNode *>(node);
|
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
|
|
|
|
2017-04-07 13:46:50 +02:00
|
|
|
runStepsForProducts(project, toBuild, {stepTypes});
|
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;
|
2018-07-27 12:10:20 +02:00
|
|
|
auto bc = qobject_cast<QbsBuildConfiguration *>(t->activeBuildConfiguration());
|
2013-01-30 18:19:31 +01:00
|
|
|
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
|
|
|
|
2018-01-05 15:47:41 +01:00
|
|
|
BuildManager::buildList(bc->stepList(buildStep));
|
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)
|
|
|
|
|
{
|
2017-02-22 15:09:35 +01:00
|
|
|
buildFiles(project, QStringList(file), QStringList({"obj", "hpp"}));
|
2013-07-24 16:47:02 +02:00
|
|
|
}
|
|
|
|
|
|
2017-04-07 13:46:50 +02:00
|
|
|
void QbsProjectManagerPlugin::runStepsForProducts(QbsProject *project,
|
|
|
|
|
const QStringList &products, const QList<Core::Id> &stepTypes)
|
2013-06-10 15:40:18 +02:00
|
|
|
{
|
|
|
|
|
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;
|
2018-07-27 12:10:20 +02:00
|
|
|
auto bc = qobject_cast<QbsBuildConfiguration *>(t->activeBuildConfiguration());
|
2013-06-10 15:40:18 +02:00
|
|
|
if (!bc)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-04-07 13:46:50 +02:00
|
|
|
if (stepTypes.contains(ProjectExplorer::Constants::BUILDSTEPS_BUILD)
|
|
|
|
|
&& !ProjectExplorerPlugin::saveModifiedFiles()) {
|
2013-06-10 15:40:18 +02:00
|
|
|
return;
|
2017-04-07 13:46:50 +02:00
|
|
|
}
|
2013-06-10 15:40:18 +02:00
|
|
|
|
|
|
|
|
bc->setChangedFiles(QStringList());
|
|
|
|
|
bc->setProducts(products);
|
2017-04-07 13:46:50 +02:00
|
|
|
QList<ProjectExplorer::BuildStepList *> stepLists;
|
|
|
|
|
QStringList stepListNames;
|
|
|
|
|
for (const Core::Id &stepType : stepTypes) {
|
|
|
|
|
stepLists << bc->stepList(stepType);
|
|
|
|
|
stepListNames <<ProjectExplorerPlugin::displayNameForStepId(stepType);
|
|
|
|
|
}
|
|
|
|
|
BuildManager::buildLists(stepLists, stepListNames);
|
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
|
|
|
{
|
2017-02-24 10:02:39 +01:00
|
|
|
reparseProject(dynamic_cast<QbsProject *>(ProjectTree::currentProject()));
|
2014-04-08 15:13:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProjectManagerPlugin::reparseCurrentProject()
|
|
|
|
|
{
|
2017-02-24 12:33:33 +01:00
|
|
|
reparseProject(dynamic_cast<QbsProject *>(SessionManager::startupProject()));
|
2014-04-08 15:13:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|