forked from qt-creator/qt-creator
CMake: Fix cmake preloadCache file support
* Make it work at all again for cmake configurations without a preloadCache file * Fix the KitInformation to provide the getters/setters like all the other KitInformation do * Use those setters consistently * Remove useless conversion from QString to QByteArray and back Change-Id: I8fc43b3531da2c04034c89b29915a29c331fe064 Reviewed-by: Cristian Adam <cristian.adam@gmail.com> Reviewed-by: Benjamin Zeller <benjamin.zeller@canonical.com> Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -597,7 +597,7 @@ void CMakeRunPage::runCMake()
|
||||
m_argumentsLineEdit->text(), m_cmakeWizard->sourceDirectory(),
|
||||
m_buildDirectory, env,
|
||||
QString::fromLatin1(generatorInfo.generatorArgument()),
|
||||
QString::fromLatin1(generatorInfo.preLoadScriptFileArgument()));
|
||||
generatorInfo.preLoadCacheFileArgument());
|
||||
} else {
|
||||
m_runCMake->setEnabled(true);
|
||||
m_argumentsLineEdit->setEnabled(true);
|
||||
|
||||
@@ -77,7 +77,7 @@ void CMakePreloadCacheKitConfigWidget::makeReadOnly()
|
||||
void CMakePreloadCacheKitConfigWidget::refresh()
|
||||
{
|
||||
if (!m_ignoreChange)
|
||||
m_lineEdit->setText(m_kit->value(CMakePreloadCacheKitInformation::id()).toString());
|
||||
m_lineEdit->setText(CMakePreloadCacheKitInformation::preloadCacheFile(m_kit));
|
||||
}
|
||||
|
||||
void CMakePreloadCacheKitConfigWidget::preloadFileWasChanged(const QString &text)
|
||||
|
||||
@@ -78,8 +78,7 @@ void CMakePreloadCacheKitInformation::fix(Kit *k)
|
||||
|
||||
KitInformation::ItemList CMakePreloadCacheKitInformation::toUserOutput(const Kit *k) const
|
||||
{
|
||||
return ItemList()
|
||||
<< qMakePair(tr("CMake Preload"), k->value(id()).toString());
|
||||
return ItemList() << qMakePair(tr("CMake Preload"), k->value(id()).toString());
|
||||
}
|
||||
|
||||
KitConfigWidget *CMakePreloadCacheKitInformation::createConfigWidget(Kit *k) const
|
||||
@@ -87,4 +86,18 @@ KitConfigWidget *CMakePreloadCacheKitInformation::createConfigWidget(Kit *k) con
|
||||
return new Internal::CMakePreloadCacheKitConfigWidget(k, this);
|
||||
}
|
||||
|
||||
void CMakePreloadCacheKitInformation::setPreloadCacheFile(Kit *k, const QString &preload)
|
||||
{
|
||||
if (!k)
|
||||
return;
|
||||
k->setValue(CMakePreloadCacheKitInformation::id(), preload);
|
||||
}
|
||||
|
||||
QString CMakePreloadCacheKitInformation::preloadCacheFile(const Kit *k)
|
||||
{
|
||||
if (!k)
|
||||
return QString();
|
||||
return k->value(CMakePreloadCacheKitInformation::id()).toString();
|
||||
}
|
||||
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
@@ -49,8 +49,11 @@ public:
|
||||
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;
|
||||
ItemList toUserOutput(const ProjectExplorer::Kit *k) const override;
|
||||
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const override;
|
||||
|
||||
static void setPreloadCacheFile(ProjectExplorer::Kit *k, const QString &preload);
|
||||
static QString preloadCacheFile(const ProjectExplorer::Kit *k);
|
||||
};
|
||||
|
||||
} // namespace CMakeProjectManager
|
||||
|
||||
@@ -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);
|
||||
if (!preloadCache.isEmpty())
|
||||
Utils::QtcProcess::addArg(&args, preloadCache);
|
||||
proc->setCommand(executable, args);
|
||||
proc->start();
|
||||
|
||||
@@ -94,15 +94,10 @@ QByteArray GeneratorInfo::generatorArgument() const
|
||||
return QByteArray("-GCodeBlocks - ") + tmp;
|
||||
}
|
||||
|
||||
QByteArray GeneratorInfo::preLoadScriptFileArgument() const
|
||||
QString GeneratorInfo::preLoadCacheFileArgument() const
|
||||
{
|
||||
if (!m_kit)
|
||||
return QByteArray();
|
||||
|
||||
QByteArray tmp = m_kit->value(CMakePreloadCacheKitInformation::id()).toByteArray();
|
||||
if (tmp.isEmpty())
|
||||
return tmp;
|
||||
return QByteArray("-C") + tmp;
|
||||
const QString tmp = CMakePreloadCacheKitInformation::preloadCacheFile(m_kit);
|
||||
return tmp.isEmpty() ? QString() : QString::fromLatin1("-C") + tmp;
|
||||
}
|
||||
|
||||
QString GeneratorInfo::displayName() const
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
QString displayName() const;
|
||||
QByteArray generatorArgument() const;
|
||||
QByteArray generator() const;
|
||||
QByteArray preLoadScriptFileArgument() const;
|
||||
QString preLoadCacheFileArgument() const;
|
||||
|
||||
private:
|
||||
ProjectExplorer::Kit *m_kit;
|
||||
|
||||
Reference in New Issue
Block a user