2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +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.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "cmakeprojectplugin.h"
|
2014-08-20 00:07:43 +02:00
|
|
|
|
|
|
|
|
#include "cmakeeditor.h"
|
2016-01-07 12:33:52 +01:00
|
|
|
#include "cmakebuildstep.h"
|
2016-11-14 15:18:25 +01:00
|
|
|
#include "cmakeproject.h"
|
|
|
|
|
#include "cmakeprojectconstants.h"
|
2008-12-02 14:09:21 +01:00
|
|
|
#include "cmakeprojectmanager.h"
|
2016-11-14 15:18:25 +01:00
|
|
|
#include "cmakeprojectnodes.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "cmakebuildconfiguration.h"
|
2008-12-09 14:13:29 +01:00
|
|
|
#include "cmakerunconfiguration.h"
|
2010-03-30 12:11:32 +02:00
|
|
|
#include "cmakeprojectconstants.h"
|
2011-10-21 23:17:58 +02:00
|
|
|
#include "cmakelocatorfilter.h"
|
2014-09-12 13:02:40 +04:00
|
|
|
#include "cmakesettingspage.h"
|
2015-02-04 17:54:46 +01:00
|
|
|
#include "cmaketoolmanager.h"
|
2015-02-24 21:57:00 +01:00
|
|
|
#include "cmakekitinformation.h"
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2016-11-09 14:25:30 +01:00
|
|
|
#include <coreplugin/fileiconprovider.h>
|
2018-03-10 18:45:06 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2015-02-24 21:57:00 +01:00
|
|
|
#include <projectexplorer/kitmanager.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <projectexplorer/projecttree.h>
|
2017-04-24 15:52:04 +02:00
|
|
|
#include <texteditor/snippets/snippetprovider.h>
|
|
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <utils/parameteraction.h>
|
2016-11-09 14:25:30 +01:00
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
using namespace Core;
|
|
|
|
|
using namespace ProjectExplorer;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-02-09 15:35:02 +01:00
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class CMakeProjectPluginPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Utils::ParameterAction *m_buildTargetContextAction = nullptr;
|
|
|
|
|
QMetaObject::Connection m_actionConnect;
|
|
|
|
|
|
|
|
|
|
CMakeSettingsPage settingsPage;
|
2018-03-10 18:45:06 +01:00
|
|
|
static const std::unique_ptr<CMakeSpecificSettings> projectTypeSpecificSettings;
|
2018-02-09 15:35:02 +01:00
|
|
|
CMakeManager manager;
|
|
|
|
|
CMakeBuildStepFactory buildStepFactory;
|
|
|
|
|
CMakeRunConfigurationFactory runConfigFactory;
|
|
|
|
|
CMakeBuildConfigurationFactory buildConfigFactory;
|
|
|
|
|
CMakeEditorFactory editorFactor;
|
|
|
|
|
CMakeLocatorFilter locatorFiler;
|
|
|
|
|
};
|
|
|
|
|
|
2018-03-10 18:45:06 +01:00
|
|
|
const std::unique_ptr<CMakeSpecificSettings>
|
|
|
|
|
CMakeProjectPluginPrivate::projectTypeSpecificSettings{std::make_unique<CMakeSpecificSettings>()};
|
|
|
|
|
|
|
|
|
|
CMakeSpecificSettings *CMakeProjectPlugin::projectTypeSpecificSettings()
|
|
|
|
|
{
|
|
|
|
|
return CMakeProjectPluginPrivate::projectTypeSpecificSettings.get();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-09 15:35:02 +01:00
|
|
|
CMakeProjectPlugin::~CMakeProjectPlugin()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:21:14 +01:00
|
|
|
bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-02-04 09:32:46 +01:00
|
|
|
Q_UNUSED(errorMessage)
|
2018-02-09 15:35:02 +01:00
|
|
|
|
|
|
|
|
d = new CMakeProjectPluginPrivate;
|
2018-03-10 18:45:06 +01:00
|
|
|
CMakeProjectPluginPrivate::projectTypeSpecificSettings->fromSettings(ICore::settings());
|
|
|
|
|
new CMakeSpecificSettingsPage(CMakeProjectPluginPrivate::projectTypeSpecificSettings.get(),
|
|
|
|
|
this); //do not store as this will be cleaned after program close
|
2018-02-09 15:35:02 +01:00
|
|
|
|
2017-12-20 11:13:26 +01:00
|
|
|
const Context projectContext(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
|
2016-11-14 15:18:25 +01:00
|
|
|
|
2016-11-09 14:25:30 +01:00
|
|
|
Core::FileIconProvider::registerIconOverlayForSuffix(Constants::FILEOVERLAY_CMAKE, "cmake");
|
2018-03-10 18:45:06 +01:00
|
|
|
Core::FileIconProvider::registerIconOverlayForFilename(Constants::FILEOVERLAY_CMAKE,
|
|
|
|
|
"CMakeLists.txt");
|
2016-11-09 14:25:30 +01:00
|
|
|
|
2017-04-24 15:52:04 +02:00
|
|
|
TextEditor::SnippetProvider::registerGroup(Constants::CMAKE_SNIPPETS_GROUP_ID,
|
|
|
|
|
tr("CMake", "SnippetProvider"));
|
2017-03-03 18:16:34 +01:00
|
|
|
ProjectManager::registerProjectType<CMakeProject>(Constants::CMAKEPROJECTMIMETYPE);
|
|
|
|
|
|
2015-02-04 17:54:46 +01:00
|
|
|
new CMakeToolManager(this);
|
2014-06-26 00:27:27 +02:00
|
|
|
|
2018-07-03 11:49:25 +02:00
|
|
|
KitManager::registerKitInformation<CMakeKitInformation>();
|
|
|
|
|
KitManager::registerKitInformation<CMakeGeneratorKitInformation>();
|
|
|
|
|
KitManager::registerKitInformation<CMakeConfigurationKitInformation>();
|
2016-11-14 15:18:25 +01:00
|
|
|
|
|
|
|
|
//menus
|
|
|
|
|
ActionContainer *msubproject =
|
|
|
|
|
ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT);
|
|
|
|
|
|
|
|
|
|
//register actions
|
|
|
|
|
Command *command = nullptr;
|
|
|
|
|
|
2018-02-09 15:35:02 +01:00
|
|
|
d->m_buildTargetContextAction = new Utils::ParameterAction(tr("Build"), tr("Build \"%1\""),
|
|
|
|
|
Utils::ParameterAction::AlwaysEnabled/*handled manually*/,
|
|
|
|
|
this);
|
2018-03-10 18:45:06 +01:00
|
|
|
command = ActionManager::registerAction(d->m_buildTargetContextAction,
|
|
|
|
|
Constants::BUILD_TARGET_CONTEXTMENU, projectContext);
|
2016-11-14 15:18:25 +01:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2018-02-09 15:35:02 +01:00
|
|
|
command->setDescription(d->m_buildTargetContextAction->text());
|
2016-11-14 15:18:25 +01:00
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
|
|
|
|
|
|
|
|
|
// Wire up context menu updates:
|
|
|
|
|
connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged,
|
|
|
|
|
this, &CMakeProjectPlugin::updateContextActions);
|
2015-02-24 21:57:00 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeProjectPlugin::extensionsInitialized()
|
|
|
|
|
{
|
2015-03-04 13:32:31 +01:00
|
|
|
//restore the cmake tools before loading the kits
|
|
|
|
|
CMakeToolManager::restoreCMakeTools();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2016-11-14 15:18:25 +01:00
|
|
|
|
2017-02-24 10:02:39 +01:00
|
|
|
void CMakeProjectPlugin::updateContextActions()
|
2016-11-14 15:18:25 +01:00
|
|
|
{
|
2017-02-24 10:02:39 +01:00
|
|
|
Project *project = ProjectTree::currentProject();
|
2017-05-31 15:48:45 +02:00
|
|
|
const Node *node = ProjectTree::findCurrentNode();
|
2018-11-04 23:09:41 +01:00
|
|
|
auto targetNode = dynamic_cast<const CMakeTargetNode *>(node);
|
2016-12-08 22:31:43 +01:00
|
|
|
// as targetNode can be deleted while the menu is open, we keep only the
|
|
|
|
|
const QString targetDisplayName = targetNode ? targetNode->displayName() : QString();
|
2018-11-04 23:09:41 +01:00
|
|
|
auto cmProject = dynamic_cast<CMakeProject *>(project);
|
2016-11-14 15:18:25 +01:00
|
|
|
|
|
|
|
|
// Build Target:
|
2018-02-09 15:35:02 +01:00
|
|
|
disconnect(d->m_actionConnect);
|
|
|
|
|
d->m_buildTargetContextAction->setParameter(targetDisplayName);
|
|
|
|
|
d->m_buildTargetContextAction->setEnabled(targetNode);
|
|
|
|
|
d->m_buildTargetContextAction->setVisible(targetNode);
|
2016-11-14 15:18:25 +01:00
|
|
|
if (cmProject && targetNode) {
|
2018-02-09 15:35:02 +01:00
|
|
|
d->m_actionConnect = connect(d->m_buildTargetContextAction, &Utils::ParameterAction::triggered,
|
2018-03-10 18:45:06 +01:00
|
|
|
cmProject, [cmProject, targetDisplayName]() {
|
|
|
|
|
cmProject->buildCMakeTarget(targetDisplayName);
|
|
|
|
|
});
|
2016-11-14 15:18:25 +01:00
|
|
|
}
|
|
|
|
|
}
|
2018-02-09 15:35:02 +01:00
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // CMakeProjectManager
|
|
|
|
|
|