From f6fcfb4c9a7c71dcef450fbba15522755a83f28a Mon Sep 17 00:00:00 2001 From: Tom Deblauwe Date: Mon, 26 Oct 2015 12:07:44 +0100 Subject: [PATCH] CMake: add preload cache cmake script file per kit Change-Id: I51c33610f2eb300ef5de2e565c567d799eddc9cf Reviewed-by: Tobias Hunger --- .../cmakeopenprojectwizard.cpp | 12 ++- .../cmakepreloadcachekitconfigwidget.cpp | 91 +++++++++++++++++++ .../cmakepreloadcachekitconfigwidget.h | 69 ++++++++++++++ .../cmakepreloadcachekitinformation.cpp | 90 ++++++++++++++++++ .../cmakepreloadcachekitinformation.h | 58 ++++++++++++ .../cmakeprojectmanager.cpp | 3 +- .../cmakeprojectmanager/cmakeprojectmanager.h | 3 +- .../cmakeprojectmanager.pro | 9 +- .../cmakeprojectplugin.cpp | 2 + .../cmakeprojectmanager/generatorinfo.cpp | 12 +++ .../cmakeprojectmanager/generatorinfo.h | 1 + 11 files changed, 341 insertions(+), 9 deletions(-) create mode 100644 src/plugins/cmakeprojectmanager/cmakepreloadcachekitconfigwidget.cpp create mode 100644 src/plugins/cmakeprojectmanager/cmakepreloadcachekitconfigwidget.h create mode 100644 src/plugins/cmakeprojectmanager/cmakepreloadcachekitinformation.cpp create mode 100644 src/plugins/cmakeprojectmanager/cmakepreloadcachekitinformation.h diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp index c89765d3c8e..02f4dcb0a47 100644 --- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp @@ -587,12 +587,16 @@ void CMakeRunPage::runCMake() CMakeManager *cmakeManager = m_cmakeWizard->cmakeManager(); if (cmake && cmake->isValid()) { m_cmakeProcess = new Utils::QtcProcess(); - connect(m_cmakeProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(cmakeReadyReadStandardOutput())); - connect(m_cmakeProcess, SIGNAL(readyReadStandardError()), this, SLOT(cmakeReadyReadStandardError())); - connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished())); + connect(m_cmakeProcess, &QProcess::readyReadStandardOutput, + this, &CMakeRunPage::cmakeReadyReadStandardOutput); + connect(m_cmakeProcess, &QProcess::readyReadStandardError, + this, &CMakeRunPage::cmakeReadyReadStandardError); + connect(m_cmakeProcess, &QProcess::finished, + this, &CMakeRunPage::cmakeFinished); cmakeManager->createXmlFile(m_cmakeProcess, cmake->cmakeExecutable().toString(), m_argumentsLineEdit->text(), m_cmakeWizard->sourceDirectory(), m_buildDirectory, env, - QString::fromLatin1(generatorInfo.generatorArgument())); + QString::fromLatin1(generatorInfo.generatorArgument()), + QString::fromLatin1(generatorInfo.preLoadScriptFileArgument())); } else { m_runCMake->setEnabled(true); m_argumentsLineEdit->setEnabled(true); diff --git a/src/plugins/cmakeprojectmanager/cmakepreloadcachekitconfigwidget.cpp b/src/plugins/cmakeprojectmanager/cmakepreloadcachekitconfigwidget.cpp new file mode 100644 index 00000000000..03d365d7fd0 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakepreloadcachekitconfigwidget.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** 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 The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** 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. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "cmakepreloadcachekitconfigwidget.h" +#include "cmakepreloadcachekitinformation.h" + +#include + +#include + +namespace CMakeProjectManager { +namespace Internal { + +CMakePreloadCacheKitConfigWidget::CMakePreloadCacheKitConfigWidget(ProjectExplorer::Kit *k, const ProjectExplorer::KitInformation *ki) : + ProjectExplorer::KitConfigWidget(k, ki), + m_lineEdit(new QLineEdit) +{ + refresh(); + m_lineEdit->setToolTip(toolTip()); + connect(m_lineEdit, &QLineEdit::textEdited, + this, &CMakePreloadCacheKitConfigWidget::preloadFileWasChanged); +} + +CMakePreloadCacheKitConfigWidget::~CMakePreloadCacheKitConfigWidget() +{ + delete m_lineEdit; +} + +QWidget *CMakePreloadCacheKitConfigWidget::mainWidget() const +{ + return m_lineEdit; +} + +QString CMakePreloadCacheKitConfigWidget::displayName() const +{ + return tr("CMake preload file:"); +} + +QString CMakePreloadCacheKitConfigWidget::toolTip() const +{ + return tr("The preload cache file to use when running cmake on the project.
" + "This setting is ignored when using other build systems."); +} + +void CMakePreloadCacheKitConfigWidget::makeReadOnly() +{ + m_lineEdit->setEnabled(false); +} + +void CMakePreloadCacheKitConfigWidget::refresh() +{ + if (!m_ignoreChange) + m_lineEdit->setText(m_kit->value(CMakePreloadCacheKitInformation::id()).toString()); +} + +void CMakePreloadCacheKitConfigWidget::preloadFileWasChanged(const QString &text) +{ + m_ignoreChange = true; + m_kit->setValue(CMakePreloadCacheKitInformation::id(), text); + m_ignoreChange = false; +} + +} // namespace Internal +} // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakepreloadcachekitconfigwidget.h b/src/plugins/cmakeprojectmanager/cmakepreloadcachekitconfigwidget.h new file mode 100644 index 00000000000..b0f2b1f79c4 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakepreloadcachekitconfigwidget.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** 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 The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** 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. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef CMAKEPRELOADCACHEKITCONFIGWIDGET_H +#define CMAKEPRELOADCACHEKITCONFIGWIDGET_H + +#include + +QT_BEGIN_NAMESPACE +class QLineEdit; +QT_END_NAMESPACE + +namespace CMakeProjectManager { +namespace Internal { + +class CMakePreloadCacheKitConfigWidget : public ProjectExplorer::KitConfigWidget +{ + Q_OBJECT + +public: + CMakePreloadCacheKitConfigWidget(ProjectExplorer::Kit *k, const ProjectExplorer::KitInformation *ki); + ~CMakePreloadCacheKitConfigWidget(); + + QWidget *mainWidget() const; + QString displayName() const; + QString toolTip() const; + + void makeReadOnly(); + void refresh(); + +private slots: + void preloadFileWasChanged(const QString &text); + +private: + QLineEdit *m_lineEdit = nullptr; + bool m_ignoreChange = false; +}; + +} // namespace Internal +} // namespace CMakeProjectManager + +#endif // CMAKEPRELOADCACHEKITCONFIGWIDGET_H diff --git a/src/plugins/cmakeprojectmanager/cmakepreloadcachekitinformation.cpp b/src/plugins/cmakeprojectmanager/cmakepreloadcachekitinformation.cpp new file mode 100644 index 00000000000..4cb31191b37 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakepreloadcachekitinformation.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Canonical Ltd. +** Contact: http://www.qt.io/licensing +** +** 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 The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** 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. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#include "cmakepreloadcachekitinformation.h" +#include "cmakepreloadcachekitconfigwidget.h" +#include "cmaketoolmanager.h" +#include "cmaketool.h" + +#include +#include +#include +#include + +#include + +using namespace ProjectExplorer; + +namespace CMakeProjectManager { + +CMakePreloadCacheKitInformation::CMakePreloadCacheKitInformation() +{ + setObjectName(QLatin1String("CMakePreloadCacheKitInformation")); + setId(CMakePreloadCacheKitInformation::id()); + setPriority(20000); +} + +Core::Id CMakePreloadCacheKitInformation::id() +{ + return "CMakeProjectManager.CMakePreloadCacheKitInformation"; +} + +QVariant CMakePreloadCacheKitInformation::defaultValue(Kit *) const +{ + return QString(); +} + +QList CMakePreloadCacheKitInformation::validate(const Kit *k) const +{ + Q_UNUSED(k); + return QList(); +} + +void CMakePreloadCacheKitInformation::setup(Kit *k) +{ + Q_UNUSED(k); +} + +void CMakePreloadCacheKitInformation::fix(Kit *k) +{ + Q_UNUSED(k); +} + +KitInformation::ItemList CMakePreloadCacheKitInformation::toUserOutput(const Kit *k) const +{ + return ItemList() + << qMakePair(tr("CMake Preload"), k->value(id()).toString()); +} + +KitConfigWidget *CMakePreloadCacheKitInformation::createConfigWidget(Kit *k) const +{ + return new Internal::CMakePreloadCacheKitConfigWidget(k, this); +} + +} // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakepreloadcachekitinformation.h b/src/plugins/cmakeprojectmanager/cmakepreloadcachekitinformation.h new file mode 100644 index 00000000000..1a6a97990c7 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakepreloadcachekitinformation.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Canonical Ltd. +** Contact: http://www.qt.io/licensing +** +** 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 The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** 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. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#ifndef CMAKEPROJECTMANAGER_CMAKEPRELOADCACHEKITINFORMATION_H +#define CMAKEPROJECTMANAGER_CMAKEPRELOADCACHEKITINFORMATION_H + +#include "cmake_global.h" + +#include + +namespace CMakeProjectManager { + +class CMAKE_EXPORT CMakePreloadCacheKitInformation : public ProjectExplorer::KitInformation +{ + Q_OBJECT +public: + CMakePreloadCacheKitInformation(); + + static Core::Id id(); + + // KitInformation interface + QVariant defaultValue(ProjectExplorer::Kit *) const override; + QList validate(const ProjectExplorer::Kit *k) const override; + void setup(ProjectExplorer::Kit *k) override; + void fix(ProjectExplorer::Kit *k) override; + virtual ItemList toUserOutput(const ProjectExplorer::Kit *k) const override; + virtual ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const override; +}; + +} // namespace CMakeProjectManager + +#endif // CMAKEPROJECTMANAGER_CMAKEPRELOADCACHEKITINFORMATION_H diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index 397c769d04e..5510968bf9c 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -147,7 +147,7 @@ bool CMakeManager::preferNinja() const // sounds like a plan void CMakeManager::createXmlFile(Utils::QtcProcess *proc, const QString &executable, const QString &arguments, const QString &sourceDirectory, const QDir &buildDirectory, - const Utils::Environment &env, const QString &generator) + const Utils::Environment &env, const QString &generator, const QString &preloadCache) { QString buildDirectoryPath = buildDirectory.absolutePath(); buildDirectory.mkpath(buildDirectoryPath); @@ -160,6 +160,7 @@ void CMakeManager::createXmlFile(Utils::QtcProcess *proc, const QString &executa Utils::QtcProcess::addArg(&args, srcdir); Utils::QtcProcess::addArgs(&args, arguments); Utils::QtcProcess::addArg(&args, generator); + Utils::QtcProcess::addArg(&args, preloadCache); proc->setCommand(executable, args); proc->start(); } diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h index 0d8af0b35c2..78c1a265550 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h @@ -64,7 +64,8 @@ public: const QString &sourceDirectory, const QDir &buildDirectory, const Utils::Environment &env, - const QString &generator); + const QString &generator, + const QString &preloadCache); bool preferNinja() const; static QString findCbpFile(const QDir &); diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index a4d06cf713b..d96e4138d87 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -26,7 +26,9 @@ HEADERS = cmakebuildinfo.h \ cmakefile.h \ cmakebuildsettingswidget.h \ cmakeindenter.h \ - cmakeautocompleter.h + cmakeautocompleter.h \ + cmakepreloadcachekitinformation.h \ + cmakepreloadcachekitconfigwidget.h SOURCES = cmakeproject.cpp \ cmakeprojectplugin.cpp \ @@ -50,7 +52,8 @@ SOURCES = cmakeproject.cpp \ cmakefile.cpp \ cmakebuildsettingswidget.cpp \ cmakeindenter.cpp \ - cmakeautocompleter.cpp - + cmakeautocompleter.cpp \ + cmakepreloadcachekitinformation.cpp \ + cmakepreloadcachekitconfigwidget.cpp RESOURCES += cmakeproject.qrc diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index 9aca653fc62..669a78ec2c1 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -40,6 +40,7 @@ #include "cmakesettingspage.h" #include "cmaketoolmanager.h" #include "cmakekitinformation.h" +#include "cmakepreloadcachekitinformation.h" #include #include @@ -75,6 +76,7 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString * new CMakeToolManager(this); ProjectExplorer::KitManager::registerKitInformation(new CMakeKitInformation); + ProjectExplorer::KitManager::registerKitInformation(new CMakePreloadCacheKitInformation); return true; } diff --git a/src/plugins/cmakeprojectmanager/generatorinfo.cpp b/src/plugins/cmakeprojectmanager/generatorinfo.cpp index febd792e88b..828c13821df 100644 --- a/src/plugins/cmakeprojectmanager/generatorinfo.cpp +++ b/src/plugins/cmakeprojectmanager/generatorinfo.cpp @@ -38,6 +38,7 @@ #include #include #include +#include "cmakepreloadcachekitinformation.h" namespace CMakeProjectManager { namespace Internal { @@ -93,6 +94,17 @@ QByteArray GeneratorInfo::generatorArgument() const return QByteArray("-GCodeBlocks - ") + tmp; } +QByteArray GeneratorInfo::preLoadScriptFileArgument() const +{ + if (!m_kit) + return QByteArray(); + + QByteArray tmp = m_kit->value(CMakePreloadCacheKitInformation::id()).toByteArray(); + if (tmp.isEmpty()) + return tmp; + return QByteArray("-C") + tmp; +} + QString GeneratorInfo::displayName() const { if (!m_kit) diff --git a/src/plugins/cmakeprojectmanager/generatorinfo.h b/src/plugins/cmakeprojectmanager/generatorinfo.h index 27b0bde33ec..5b24fbfc39d 100644 --- a/src/plugins/cmakeprojectmanager/generatorinfo.h +++ b/src/plugins/cmakeprojectmanager/generatorinfo.h @@ -56,6 +56,7 @@ public: QString displayName() const; QByteArray generatorArgument() const; QByteArray generator() const; + QByteArray preLoadScriptFileArgument() const; private: ProjectExplorer::Kit *m_kit;