forked from qt-creator/qt-creator
CMake: add preload cache cmake script file per kit
Change-Id: I51c33610f2eb300ef5de2e565c567d799eddc9cf Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 <projectexplorer/kit.h>
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
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.<br>"
|
||||
"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
|
||||
@@ -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 <projectexplorer/kitconfigwidget.h>
|
||||
|
||||
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
|
||||
@@ -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 <utils/qtcassert.h>
|
||||
#include <projectexplorer/task.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
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<Task> CMakePreloadCacheKitInformation::validate(const Kit *k) const
|
||||
{
|
||||
Q_UNUSED(k);
|
||||
return QList<Task>();
|
||||
}
|
||||
|
||||
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
|
||||
@@ -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 <projectexplorer/kitmanager.h>
|
||||
|
||||
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<ProjectExplorer::Task> 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
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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 &);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "cmakesettingspage.h"
|
||||
#include "cmaketoolmanager.h"
|
||||
#include "cmakekitinformation.h"
|
||||
#include "cmakepreloadcachekitinformation.h"
|
||||
|
||||
#include <coreplugin/featureprovider.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <baremetal/baremetalconstants.h>
|
||||
#include <remotelinux/remotelinux_constants.h>
|
||||
#include <qnx/qnxconstants.h>
|
||||
#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)
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
QString displayName() const;
|
||||
QByteArray generatorArgument() const;
|
||||
QByteArray generator() const;
|
||||
QByteArray preLoadScriptFileArgument() const;
|
||||
|
||||
private:
|
||||
ProjectExplorer::Kit *m_kit;
|
||||
|
||||
Reference in New Issue
Block a user